salla

conta_up

Aug 1st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.43 KB | None | 0 0
  1. -- Contador de década sobe e desce
  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_up is
  12.   port (
  13.     clk:in bit;
  14.     reset: in bit;
  15.      carry_out: out bit;
  16.     q: out std_logic_vector(3 downto 0)
  17.     );
  18. end conta_up;
  19.  
  20. architecture arquitetura of conta_up is
  21. begin
  22.     process(clk,reset)                                  
  23.     variable qtemp: std_logic_vector(3 downto 0);  
  24.     begin
  25.         if reset='1' then
  26.         qtemp:="0000";                                            
  27.        
  28.         else      
  29.             if clk'event and clk='1' then  
  30.                
  31.                     if qtemp<9 then     ---
  32.                     qtemp:=qtemp+1;      ---                              
  33.                     carry_out <= '0';       ---
  34.                     else                        ---     CONTADOR CRESCENTE
  35.                     qtemp:="0000";       ---                                  
  36.                     carry_out <= '1';       ---
  37.                     end if;                 ---
  38.  
  39.              
  40.             end if;
  41.         q<=qtemp;                                                
  42.         end if;
  43.     end process;                                                      
  44. end arquitetura;
Add Comment
Please, Sign In to add comment