Advertisement
Guest User

VHDL BMSTU HW

a guest
May 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.29 KB | None | 0 0
  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.all;
  3. USE ieee.std_logic_arith.all;
  4.  
  5. ENTITY control_unit IS
  6.    PORT( U : IN std_logic_vector ( 5 DOWNTO 0 );
  7.    clk : IN std_logic;
  8.    rst : IN std_logic;
  9.    V : OUT std_logic_vector ( 7 DOWNTO 0 ) );
  10. END control_unit;
  11.  
  12. ARCHITECTURE moore OF control_unit IS
  13. TYPE STATE_TYPE IS (s1,s2,s3,s4,s5,s6);
  14. SIGNAL current_state : STATE_TYPE;
  15. BEGIN
  16.    clocked_proc : PROCESS (clk, rst)
  17.    BEGIN
  18.       IF (rst = '0') THEN
  19.          current_state <= s1;
  20.       ELSIF (clk'EVENT AND clk = '1') THEN
  21.          CASE current_state IS
  22.             WHEN s1 =>
  23.                V <= (others => '0');
  24.                IF (U(0) = '1' AND U(3) = '1' AND U(4) = '0') THEN
  25.                   current_state <= s2;
  26.                ELSIF (U(0) = '1' AND U(2) = '0') THEN
  27.                   current_state <= s4;
  28.                ELSE
  29.                   current_state <= s1;
  30.                END IF;
  31.             WHEN s2 =>
  32.                V <= "00000101";
  33.                IF (U(2) = '1' OR U(4) = '1' THEN
  34.                   current_state <= s3;
  35.                ELSE
  36.                   current_state <= s2;
  37.                END IF;
  38.             WHEN s3 =>
  39.                V <= "10000000";
  40.                IF (U(0) = '1' AND U(1) = '1' THEN
  41.                   current_state <= s1;
  42.                ELSE
  43.                   current_state <= s3;
  44.                END IF;
  45.             WHEN s4 =>
  46.                V <= "00001010";
  47.                IF (U(0) = '1' AND U(5) = '0') THEN
  48.                   current_state <= s3;
  49.                ELSIF (U(1) = '1') THEN
  50.                   current_state <= s5;
  51.                ELSE
  52.                   current_state <= s4;
  53.                END IF;
  54.             WHEN s5 =>
  55.                V <= "00110000";
  56.                IF (U(0) = '0' OR U(2) = '1') THEN
  57.                   current_state <= s6;
  58.                ELSE
  59.                   current_state <= s5;
  60.                END IF;
  61.             WHEN s6 =>
  62.                V <= (6 => '1', others => '0');
  63.                IF (U(0) = '1' OR U(5) = '1') THEN
  64.                   current_state <= s1;
  65.                ELSE
  66.                   current_state <= s6;
  67.                END IF;
  68.             WHEN OTHERS =>
  69.                current_state <= s0;
  70.          END CASE;
  71.       END IF;
  72.    END PROCESS clocked_proc;
  73. END moore;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement