Contador

---------------------------------------------------------------------------------- Company: IIIE -- Engineer: Carlos Bra

Views 143 Downloads 6 File size 10KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

---------------------------------------------------------------------------------- Company: IIIE -- Engineer: Carlos Bran --- Create Date: 09:44:51 02/09/2015 -- Design Name: -- Module Name: contador - 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.numeric_std.ALL; entity contador is generic (size: integer:= 8); -- contador de 8 bits (0 a size) Port ( clk, rst, ena, up_down : in STD_LOGIC; tipo : in STD_LOGIC_VECTOR (1 downto 0); cuenta : out STD_LOGIC_VECTOR (size-1 downto 0)); end contador; architecture Behavioral of contador is signal SLOWCLKEN: std_logic; begin process (clk, rst, ena, up_down, tipo, SLOWCLKEN) variable incrementa: unsigned (3 downto 0) := (others => '0'); variable temporal: unsigned (size-1 downto 0) := (others => '0') ; begin case tipo is when "00" => incrementa:= "0001"; when "01" => incrementa:= "0010"; when "10" => incrementa:= "1000"; when others => incrementa:= "1010"; end case; if (rst = '1') then temporal := (others => '0'); elsif (clk'event and clk = '1') then if (SLOWCLKEN='1') then if (ena = '0') then if (up_down = '1') then temporal := temporal + increment a; else temporal := temporal - increment a; end if; else temporal := temporal; end if; end if;

end if; cuenta '0') then SLOWCLKEN