Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Company:
- -- Engineer:
- --
- -- Create Date: 09:55:25 11/21/2014
- -- Design Name:
- -- Module Name: Counter - Behavioral
- -- Project Name:
- -- Target Devices:
- -- Tool versions:
- -- Description:
- --
- -- Dependencies:
- --
- -- Revision:
- -- Revision 0.01 - File Created
- -- Additional Comments:
- --
- ----------------------------------------------------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- use ieee.std_logic_unsigned.all;
- -- Uncomment the following library declaration if using
- -- arithmetic functions with Signed or Unsigned values
- use IEEE.NUMERIC_STD.ALL;
- -- Uncomment the following library declaration if instantiating
- -- any Xilinx primitives in this code.
- --library UNISIM;
- --use UNISIM.VComponents.all;
- entity Counter is
- Port ( Reset : in STD_LOGIC;
- CLK : in STD_LOGIC;
- Enable : in STD_LOGIC;
- S : out STD_LOGIC_VECTOR(25 downto 0));
- end Counter;
- architecture Behavioral of Counter is
- signal Add : STD_LOGIC_VECTOR(25 downto 0);
- signal Reg : STD_LOGIC_VECTOR(25 downto 0);
- signal Mux1, Mux2 : STD_LOGIC_VECTOR(25 downto 0);
- signal Cmp : STD_LOGIC;
- begin
- Reg <= "00000000000000000000000000" when Reset = '0' else Mux2 when rising_edge(CLK);
- Add <= Reg + "0000000000000000000000001";
- Mux1 <= Add when Cmp = '0' else "00000000000000000000000000" when Cmp = '1';
- Mux2 <= Reg when Enable = '0' else Mux1 when Enable = '1';
- Cmp <= '1' when Add > "0000000000000000000001000" else '0';
- S <= Mux2;
- end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement