Advertisement
thibthibaut

TP 3 Level 2

Nov 21st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.51 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    09:55:25 11/21/2014
  6. -- Design Name:
  7. -- Module Name:    Counter - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use ieee.std_logic_unsigned.all;
  23.  
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity Counter is
  34.     Port ( Reset : in  STD_LOGIC;
  35.            CLK : in  STD_LOGIC;
  36.            S : out  STD_LOGIC_VECTOR(25 downto 0));
  37. end Counter;
  38.  
  39. architecture Behavioral of Counter is
  40.  
  41. signal Add : STD_LOGIC_VECTOR(25 downto 0);
  42. signal Reg : STD_LOGIC_VECTOR(25 downto 0);
  43. signal Mux : STD_LOGIC_VECTOR(25 downto 0);
  44. signal Cmp : STD_LOGIC;
  45.  
  46. begin
  47.  
  48. Reg <= "00000000000000000000000000" when Reset = '0' else Mux when rising_edge(CLK);
  49.      
  50. Add <= Reg + "0000000000000000000000001";
  51.  
  52. Mux <= Add when Cmp = '0' else "00000000000000000000000000" when Cmp = '1';
  53.  
  54. Cmp <= '1' when Add > "0000000000000000000001000" else '0';
  55.  
  56. S <= Mux;
  57.  
  58. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement