Advertisement
filip710

test

Nov 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.09 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity moving_light is
  5.     --TO DO 1 -> deklarirati ulaz "clk" (STD_LOGIC) i izlaz "output" (STD_LOGIC_VECTOR) veličine 8 bita
  6.     Port ( clk : in STD_LOGIC;
  7.               output : out STD_LOGIC_VECTOR (7 downto 0)
  8.          );
  9. end moving_light;
  10.  
  11. architecture Behavioral of moving_light is
  12.  
  13.     --TO DO 2 -> definirati korisnički tip podataka naziva "state" koji može imati vrijednosti "state0", ... "state7"
  14.     TYPE state IS (state0, state1, state2, state3, state4, state5, state6, state7);
  15.     --TO DO 3 -> deklarirati signale "current_state" i "next_state" koji su tipa "state"
  16.     SIGNAL current_state, next_state: state;
  17.     --TO DO 4 -> deklarirati signal "clk_div" koji je tipa STD_LOGIC
  18.     SIGNAL clk_div: STD_LOGIC;
  19.  
  20. begin
  21.  
  22.     --TO DO 5 -> instancirati generički djelitelj frekvencije na način da od ulaznog singala takta kreira signal takta frekvencije 1 Hz
  23.     clk_1Hz : entity work.generic_divider generic map (50000000) port map (clk, clk_div);
  24.    
  25.     ----Lower section of FSM----
  26.     process(clk_div)
  27.     begin
  28.         --TO DO 6 -> na rastući brid signala takta "clk_div" signalu "current_state" pridružiti vrijednost signala "next_state"
  29.         if(clk_div'EVENT and clk_div='1') then
  30.             current_state<=next_state;
  31.         end if;
  32.     end process;
  33.    
  34.     ----Upper section of FSM----
  35.     process(current_state)
  36.     begin
  37.         case current_state is
  38.             --TO DO 7 -> u ovisnosti o vrijednosti signala "current_state" signalima "output" i "next_state" pridružiti odgovarajuće vrijednosti
  39.             when state0  =>
  40.                 output <= "00000001";
  41.                 next_state <= state1;
  42.             when state1 =>
  43.                 output <= "00000010";
  44.                 next_state <= state2;
  45.             when state2 =>
  46.                 output <= "00000100";
  47.                 next_state <= state3;
  48.             when state3 =>
  49.                 output <= "00001000";
  50.                 next_state <= state4;
  51.             when state4 =>
  52.                 output <= "00010000";
  53.                 next_state <= state5;
  54.             when state5 =>
  55.                 output <= "00100000";
  56.                 next_state <= state6;
  57.             when state6 =>
  58.                 output <= "01000000";
  59.                 next_state <= state7;
  60.             when state7 =>
  61.                 output <= "10000000";
  62.                 next_state <= state0;
  63.         end case;
  64.     end process;   
  65.  
  66. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement