cursofpgavhdl

conta_decada

Nov 29th, 2019
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.21 KB | None | 0 0
  1. -- Contador de década
  2. -- Entradas: clk (clock), reset;
  3. -- Saída: q (Vetor 4 posições tipo BCD)
  4. -- Autores: João Vitor e Marcos Meira
  5. -- 02/08/2017
  6.  
  7. library IEEE;                                                        
  8. use IEEE.std_logic_1164.all;
  9. use IEEE.std_logic_unsigned.all;
  10.  
  11. entity conta_decada is
  12.   port (clk:in std_logic;
  13.     reset: in std_logic;
  14.     q: out std_logic_vector(3 downto 0));
  15. end conta_decada;
  16.  
  17. architecture arquitetura of conta_decada is
  18. begin
  19.     process(clk,reset)                                  
  20.     variable qtemp: std_logic_vector(3 downto 0);  
  21.     begin
  22.         if reset='1' then
  23.         qtemp:="0000";                                            
  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.             end if;
  33.         q<=qtemp;                                                
  34.         end if;
  35.        
  36.     end process;                                                      
  37. end arquitetura;
Advertisement
Add Comment
Please, Sign In to add comment