Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.std_logic_unsigned.all;
  4.  
  5. entity zadatak is
  6. port(
  7. iCLK: in std_logic;
  8. iRST: in std_logic;
  9. iGO: in std_logic;
  10. iSTOP: in std_logic;
  11. oSEC : out std_logic_vector (6 downto 0);
  12. oMUXROW: out std_logic_vector(1 downto 0)
  13. );
  14. end entity;
  15.  
  16. architecture Behavior of zadatak is
  17.  
  18. signal sCNT: std_logic_vector(23 downto 0);
  19. signal sSEC: std_logic_vector(7 downto 0);
  20. signal sTC: std_logic;
  21. signal sEN: std_logic;
  22. signal sTC1: std_logic;
  23. signal sDES: std_logic_vector(7 downto 0);
  24. signal sEN1: std_logic;
  25. signal sGO: std_logic;
  26. signal sGO_OLD: std_logic;
  27. signal s7SEGM: std_logic_vector(6 downto 0);
  28. begin
  29.  
  30.  
  31. process (iCLK, iRST) begin
  32. if (iRST = '1') then
  33. sCNT <= (others=>'0');
  34. elsif (iCLK'event and iCLK = '1') then
  35. if(sGO='1') then
  36. if(sCNT="101101110001101100000000") then
  37. sCNT<=(others=>'0'); --reset
  38. sTC<='1';
  39.  
  40. else
  41. sCNT<=sCNT+'1';
  42. sTC<='0';
  43. end if;
  44. end if;
  45. end if;
  46. sGO_OLD<=sGO;
  47. sEN<=sTC;
  48. end process;
  49.  
  50. -- sekunde
  51. process (iCLK, iRST) begin
  52. if (iRST = '1') then
  53. sSEC <= "00000000";
  54. elsif (iCLK'event and iCLK = '1') then
  55. if(sEN='1') then
  56. sSEC <= sSEC + 1;
  57. if(sSEC=9) then
  58. sSEC<=(others=>'0');--reset
  59. sTC1<='1';
  60. else
  61. sTC1<='0';
  62. end if;
  63. end if;
  64. end if;
  65. sEN1<=sTC1;
  66.  
  67. end process;
  68.  
  69. -- desetice
  70. process(iCLK,iRST) begin
  71. if(iRST='1') then
  72. sDES<="00000000";
  73. elsif(iCLK'event and iCLK='1') then
  74. if(sEN1='1') then
  75. if(sCNT="000000000000000000000001") then
  76. sDES<=sDES+'1';
  77. if(sDES=5) then
  78. sDES<=(others=>'0');
  79. end if;
  80. end if;
  81. end if;
  82. end if;
  83. end process;
  84.  
  85. -- aktivnost stoperice --
  86. process(iCLK,iRST) begin
  87. if(iRST='1') then
  88. sGO<='0';
  89. elsif(iGO='1') then
  90. sGO<='1';
  91. elsif(iSTOP='1') then
  92. sGO<='0';
  93. else
  94. sGO<=sGO_OLD;
  95. end if;
  96. end process;
  97.  
  98.  
  99.  
  100. process(s7SEGM) begin
  101. if(sCNT(15)='1') then
  102. oMUXROW<="01";
  103. if(sDES=0) then
  104. s7SEGM <= "0000001";
  105. elsif(sDES=1) then
  106. s7SEGM<="1001111";
  107. elsif(sDES=2) then
  108. s7SEGM<="0010010";
  109. elsif(sDES=3) then
  110. s7SEGM<="0000110";
  111. elsif(sDES=4) then
  112. s7SEGM<="1001100";
  113. else
  114. s7SEGM<="0100100";
  115. end if;
  116. else
  117. oMUXROW<="00";
  118. if(sSEC=0) then
  119. s7SEGM <= "0000001";
  120. elsif(sSEC=1) then
  121. s7SEGM<="1001111";
  122. elsif(sSEC=2) then
  123. s7SEGM<="0010010";
  124. elsif(sSEC=3) then
  125. s7SEGM<="0000110";
  126. elsif(sSEC=4) then
  127. s7SEGM<="1001100";
  128. elsif(sSEC=5) then
  129. s7SEGM<="0100100";
  130. elsif(sSEC=6) then
  131. s7SEGM<="0100000";
  132. elsif(sSEC=7) then
  133. s7SEGM<="0001111";
  134. elsif(sSEC=8) then
  135. s7SEGM<="0000000";
  136. else
  137. s7SEGM<="0000100";
  138. end if;
  139. end if;
  140. oSEC(6 downto 0)<=s7SEGM;
  141. end process;
  142.  
  143.  
  144. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement