Advertisement
salla

conta_9 - V2

Jul 29th, 2019
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.12 KB | None | 0 0
  1. -- Contador 0 a 9
  2. -- Entradas: clk (clock), reset;
  3. -- Saída: q (Vetor 4 posições tipo BCD)
  4. -- Autores: João Vitor e Marcos Meira
  5.  
  6. library IEEE;                                                        
  7. use IEEE.std_logic_1164.all;
  8. use IEEE.std_logic_unsigned.all;
  9.  
  10. entity conta_9 is
  11.   port (clk:in std_logic;
  12.     reset: in std_logic;
  13.     q: out std_logic_vector(3 downto 0));
  14. end conta_9;
  15.  
  16. architecture arquitetura of conta_6 is
  17. begin
  18.     process(clk,reset)                                  
  19.     variable qtemp: std_logic_vector(3 downto 0);  
  20.     begin
  21.         if reset='1' then
  22.         qtemp:="0000";
  23.         --q <= "0000"; -- Assumir o valor da saida nas duas condicoes do IF, evita latches, retirar essa porcao do codigo para verificar RTL
  24.        
  25.         else       
  26.             if clk'event and clk='1' then                            
  27.                 if qtemp<9 then
  28.                 qtemp:=qtemp+1;                                        
  29.                 else
  30.                 qtemp:="0000";                                            
  31.                 end if;
  32.             else
  33.                 qtemp:=qtemp;
  34.             end if;
  35.         q<=qtemp;                                                
  36.         end if;
  37.     end process;    
  38.    
  39. end arquitetura;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement