canezzy

Untitled

Dec 5th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer: Nenad Misic
  4. --
  5. -- Create Date: 21:59:15 12/04/2018
  6. -- Design Name:
  7. -- Module Name: zadatak3 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  23.  
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. --use IEEE.NUMERIC_STD.ALL;
  27.  
  28. -- Uncomment the following library declaration if instantiating
  29. -- any Xilinx primitives in this code.
  30. --library UNISIM;
  31. --use UNISIM.VComponents.all;
  32.  
  33. entity zadatak3 is
  34. Port ( iCLK : in STD_LOGIC;
  35. inRST : in STD_LOGIC;
  36. inGO : in STD_LOGIC;
  37. inSTOP : in STD_LOGIC;
  38. oSEC : out STD_LOGIC_VECTOR (7 downto 0));
  39. end zadatak3;
  40.  
  41. architecture Behavioral of zadatak3 is
  42. signal sCNT : STD_LOGIC_VECTOR(24 downto 0);
  43. signal sTC : STD_LOGIC;
  44. signal sRES : STD_LOGIC_VECTOR(7 downto 0);
  45. signal sONOFF : STD_LOGIC;
  46. begin
  47.  
  48. process(iCLK) begin
  49. if(iCLK'event and iCLK='1') then
  50. if(inRST = '0') then
  51. sCNT <= "0000000000000000000000000";
  52. sTC <= '0';
  53.  
  54. else
  55. if(sONOFF = '0') then
  56. sCNT <= sCNT + 1;
  57. if(sCNT = "1011011100011011000000000") then
  58. sTC <= not(sTC);
  59. sCNT <= "0000000000000000000000000";
  60. else
  61. sTC <= sTC;
  62. end if;
  63. end if;
  64. end if;
  65. end if;
  66. end process;
  67.  
  68.  
  69. process(sTC) begin
  70. if(inRST = '0') then
  71. sRES <= "00111100";
  72. else
  73. if(sONOFF = '0') then
  74. sRES <= sRES(0) & sRES(7 downto 1);
  75. else
  76. sRES <= sRES;
  77. end if;
  78.  
  79. end if;
  80. end process;
  81.  
  82. process(iCLK) begin
  83. if(iCLK'event and iCLK='1') then
  84. if(inRST = '0') then
  85. sONOFF <= '1';
  86. else
  87. if(inGO = '0') then
  88. sONOFF <= '0';
  89. end if;
  90.  
  91. if(inSTOP = '0') then
  92. sONOFF <= '1';
  93. end if;
  94. end if;
  95. end if;
  96. end process;
  97. oSEC <= sRES;
  98.  
  99. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment