cavala

rot_svjetlo

Jul 31st, 2021 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.06 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    11:42:36 12/15/2020
  6. -- Design Name:
  7. -- Module Name:    rot2_svjetlo - 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_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx primitives in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity rot2_svjetlo is
  35.  
  36. port(clk: in STD_LOGIC; --definiran ulaz
  37.       ledica: out STD_LOGIC_VECTOR(7 downto 0)); -- definiran izlaz za ledice sa MSB s desne strane (tj. prva ledica na sklopu je s desne strane
  38.  
  39. end rot2_svjetlo;
  40.  
  41. architecture Behavioral of rot2_svjetlo is
  42.  
  43. type stanje is(S0,S1,S2,S3,S4,S5,S6,S7); --definirana 7 stanja zbog 7 ledica
  44. signal trenutno, buduce:stanje; -- definirani signali
  45. signal clk_0:STD_LOGIC;
  46.  
  47. begin
  48. A1: entity work.freqDivGen port map(clk,clk_0); --pozivanje frenq_div_gen-a s izlaznim signalom clk_0
  49. process(clk_0)
  50. begin
  51. if(clk_0 'event and clk_0='1')then -- proces koji govori kada ce preci iz trenutnog stanja u buduce
  52. trenutno<=buduce;
  53. end if;
  54. end process;
  55.  
  56. process(trenutno)--definirani izlazi za stanja
  57. begin
  58. case trenutno is
  59. when S0=>
  60. ledica<="00000011";
  61. buduce<=S1;
  62.  
  63. when S1=>
  64. ledica<="00000110";
  65. buduce<=S2;
  66.  
  67. when S2=>
  68. ledica<="00001100";
  69. buduce<=S3;
  70.  
  71. when S3=>
  72. ledica<="00011000";
  73. buduce<=S4;
  74.  
  75. when S4=>
  76. ledica<="00110000";
  77. buduce<=S5;
  78.  
  79. when S5=>
  80. ledica<="01100000";
  81. buduce<=S6;
  82.  
  83. when S6=>
  84. ledica<="11000000";
  85. buduce<=S7;
  86.  
  87. when S7=>
  88. ledica<="10000001";
  89. buduce<=S0;
  90.  
  91. end case;
  92. end process;
  93. end Behavioral;
Add Comment
Please, Sign In to add comment