Advertisement
Guest User

Untitled

a guest
May 25th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3.  
  4. entity Temporizador is
  5. generic(ClockFrequency : integer);
  6. port(
  7. enable : in std_logic; -- si enable = 1 funciona
  8. clk : in std_logic;
  9. nrst : in std_logic; -- rst cuando = 0
  10. segundos: inout integer;
  11. minutos : inout integer;
  12. max : inout std_logic
  13. );
  14. end entity;
  15.  
  16. architecture rtl of Temporizador is
  17. begin
  18.  
  19. component divisor is
  20. Port (
  21. clk_in : in STD_LOGIC;
  22. clk_out: out STD_LOGIC
  23. );
  24. end component;
  25. signal nclock: std_logic;
  26.  
  27. process(clk) is
  28. begin
  29. div: divisor
  30. port map(
  31. clk_in => clk,
  32. clk_out => nclk
  33. );
  34.  
  35. if rising_edge(nclk) then
  36. if nrst = '0' then
  37. segundos <= 0;
  38. minutos <= 0;
  39. max <= '0';
  40.  
  41. else
  42. --verdadero cada minuto
  43. if segundos =59 then
  44. segundos <= 0;
  45.  
  46. if minutos = 1 then
  47. segundos <= 0;
  48. minutos <= 0;
  49. max <= '1';
  50. else
  51. minutos <= minutos +1;
  52. end if;
  53. else
  54. segundos <= segundos + 1;
  55. end if;
  56.  
  57. end if;
  58. end if;
  59. end process;
  60. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement