salla

conta_99_estrutural

Jul 29th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.92 KB | None | 0 0
  1. -- Contador sobe e desce 0 a 99, com alarme
  2. -- Dependente das sub-entidades: conta_updown e decod
  3. -- Entradas: clk (clock), sobedesce e reset - Tipo bit
  4. -- Saidas: HEX0 e HEX1 (displays 7 seg) - Tipo vetor 7 posicoes
  5. -- Autores: Joao Vitor e Marcos Meira
  6. -- Data: 2/8/2017
  7.  
  8. library IEEE;                                                        
  9. use IEEE.std_logic_1164.all;
  10. use IEEE.std_logic_unsigned.all;
  11.  
  12. entity conta_99 is
  13. port (clk: in std_logic;
  14.         reset: in std_logic;
  15.         desliga: in std_logic;
  16.         sobedesce: in std_logic;
  17.         alarme: out std_logic;
  18.         HEX0, HEX1: out std_logic_vector (0 to 6));
  19. end conta_99;
  20.  
  21. architecture arquitetura of conta_99 is
  22.  
  23. component divisor_clk
  24. port (clk_in: in std_logic;
  25.         q: out std_logic);
  26. end component;
  27.  
  28. component conta_updown                     
  29. port(clk:in std_logic;                           
  30.      reset: in std_logic;                            
  31.       sobedesce: in std_logic;                   
  32.       carry_out: out std_logic;                
  33.      q: out std_logic_vector(3 downto 0));  
  34. end component;             
  35.  
  36. component decod
  37. port(bcd: in std_logic_vector (3 downto 0);
  38.       HEX: out std_logic_vector (0 to 6));
  39. end component;               
  40.  
  41. signal clk_1Hz: std_logic;
  42. signal bcd0, bcd1: std_logic_vector (3 downto 0);
  43. signal carry_out: std_logic;
  44.  
  45. begin
  46. divisor: divisor_clk port map (clk_in => clk,
  47.                                          q => clk_1Hz);
  48.  
  49. contador0: conta_updown port map(clk_1Hz, reset, sobedesce, carry_out, bcd0);
  50.                                
  51. contador1: conta_updown port map(carry_out, reset, sobedesce, open, bcd1);
  52.  
  53. decod0: decod port map(bcd0, HEX0);
  54.                                  
  55. decod1: decod port map(bcd1, HEX1);
  56.  
  57.     process (bcd0, bcd1)                                                                --Alarme=1 se a saída for 60
  58.     begin                                                                                   --
  59.         if bcd1 ="0110" and bcd0="0000" and desliga='0' then                --
  60.             alarme <= '1';                                                              --
  61.                                                                                             --
  62.         elsif desliga='1' then                                                      --
  63.             alarme <= '0';                                                              --
  64.         end if;                                                                         --
  65.     end process;                                                                        --
  66.    
  67. end arquitetura;
Add Comment
Please, Sign In to add comment