Advertisement
hbinderup94

mee_moo

May 26th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.61 KB | None | 0 0
  1. ------ mee_moo ------
  2. library ieee;
  3. use ieee.std_logic_1164.all;
  4.  
  5. entity mee_moo is
  6. port(
  7.     clk     : in std_logic;
  8.     reset   : in std_logic;
  9.     inp     : in std_logic_vector(1 downto 0);
  10.     moo_out : out std_logic;
  11.     mee_out : out std_logic);
  12. end mee_moo;
  13.  
  14. architecture state_machine of mee_moo is
  15.     type    state is(idle, init, aktiv);
  16.     signal  present_state, next_state : state;
  17. begin
  18.  
  19.     state_reg: process(clk, reset)  -- state register instantieres
  20.     begin
  21.         if reset = '0' then             -- reset af state machine
  22.             present_state <= idle;
  23.         elsif rising_edge(clk) then     -- næste state ved rising_edge af clk
  24.             present_state <= next_state;
  25.         end if;
  26.     end process;
  27.    
  28.     next_st: process(inp, present_state)
  29.     begin
  30.     next_state <= present_state;        -- states defineres ud fra ibd
  31.         case present_state is
  32.             when idle =>
  33.                 if (inp = "10" or inp = "11") then
  34.                     next_state <= init;
  35.                 end if;
  36.             when init =>
  37.                 if (inp = "00") then
  38.                     next_state <= idle;
  39.                 elsif (inp = "01") then
  40.                     next_state <= aktiv;
  41.                 end if;
  42.             when aktiv =>
  43.                 next_state <= idle;
  44.         end case;
  45.     end process;
  46.    
  47.     moo_output: process(present_state)  -- output for moo defineres ift. ibd
  48.     begin
  49.         case present_state is
  50.             when idle =>
  51.                 moo_out <= '0';
  52.             when others =>
  53.                 moo_out <= '1';
  54.         end case;
  55.     end process;
  56.    
  57.     mee_output: process(present_state, inp) -- output for mee defineres ift. ibd
  58.     begin
  59.         case present_state is
  60.             when init =>
  61.                 if (inp = "11") then
  62.                     mee_out <= '1';
  63.                 else
  64.                     mee_out <= '0';
  65.                 end if;
  66.             when others =>
  67.                 mee_out <= '0';
  68.         end case;
  69.     end process;
  70.    
  71. end state_machine;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement