Advertisement
Guest User

Untitled

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