Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Contador 0 a 9
- -- Entradas: clk (clock), reset;
- -- Saída: q (Vetor 4 posições tipo BCD)
- -- Autores: João Vitor e Marcos Meira
- library IEEE;
- use IEEE.std_logic_1164.all;
- use IEEE.std_logic_unsigned.all;
- entity conta_9 is
- port (clk:in std_logic;
- reset: in std_logic;
- q: out std_logic_vector(3 downto 0));
- end conta_9;
- architecture arquitetura of conta_6 is
- begin
- process(clk,reset)
- variable qtemp: std_logic_vector(3 downto 0);
- begin
- if reset='1' then
- qtemp:="0000";
- --q <= "0000"; -- Assumir o valor da saida nas duas condicoes do IF, evita latches, retirar essa porcao do codigo para verificar RTL
- else
- if clk'event and clk='1' then
- if qtemp<9 then
- qtemp:=qtemp+1;
- else
- qtemp:="0000";
- end if;
- else
- qtemp:=qtemp;
- end if;
- q<=qtemp;
- end if;
- end process;
- end arquitetura;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement