Advertisement
some_kid

le Code

Feb 9th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 4.21 KB | None | 0 0
  1. --------------------------------------------------------------------------------
  2. -- Entity: Lec11
  3. -- Date: Feb 8, 2012
  4. -- Author:  
  5. --
  6. -- Description
  7. --------------------------------------------------------------------------------
  8. library ieee;
  9. use ieee.std_logic_1164.all;
  10.  
  11. entity controller is
  12.     port(
  13.         clock        : in  std_logic;
  14.         reset        : in  std_logic;
  15.         loada, loadb : out std_logic;
  16.         muxs         : out std_logic_vector(1 downto 0);
  17.         alus         : out std_logic_vector(2 downto 0)
  18.     );
  19. end entity controller;
  20.  
  21. architecture RTL of controller is
  22.     type states is (s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16);
  23.     signal q, d : states;
  24. begin
  25.     FF : process(clock, reset) is
  26.     begin
  27.         if reset = '0' then
  28.             q <= s1;
  29.         elsif rising_edge(clock) then
  30.             q <= d;
  31.         end if;
  32.     end process FF;
  33.  
  34.     with q select d <=
  35.         s2 when s1,
  36.         s3 when s2,
  37.         s4 when s3,
  38.         s5 when s4,
  39.         s6 when s5,
  40.         s7 when s6,
  41.         s8 when s7,
  42.         s9 when s8,
  43.         s10 when s9,
  44.         s11 when s10,
  45.         s12 when s11,
  46.         s13 when s12,
  47.         s14 when s13,
  48.         s15 when s14,
  49.         s16 when others;
  50.  
  51.     with q select loada <=
  52.         '1' when s1,                    -- load 0
  53.         '0' when s2,                    -- hold
  54.         '0' when s3,                    -- hold
  55.         '0' when s4,                    -- load 2y
  56.         '0' when s5,                    -- hold
  57.         '0' when s6,                    -- hold
  58.         '1' when s7,                    -- load x
  59.         '0' when s8,                    -- hold
  60.         '0' when s9,                    -- hold
  61.         '0' when s10,                   -- hold
  62.         '0' when s11,                   -- hold
  63.         '0' when s12,                   -- hold
  64.         '0' when s13,                   -- hold
  65.         '0' when s14,                   -- hold
  66.         '0' when s15,                   -- hold
  67.         '0' when s16;                   -- hold
  68.  
  69.  
  70.     with q select loadb <=
  71.         '0' when s1,                    -- hold
  72.         '1' when s2,                    -- load y
  73.         '1' when s3,                    -- load 2y
  74.         '0' when s4,                    -- hold
  75.         '1' when s5,                    -- load !2y
  76.         '1' when s6,                    -- load -2y
  77.         '0' when s7,                    -- hold
  78.         '1' when s8,                    -- load x - 2y
  79.         '1' when s9,                    -- load 2x - 2y
  80.         '1' when s10,                   -- load 3x - 2y
  81.         '1' when s11,                   -- load 4x - 2y
  82.         '1' when s12,                   -- load 5x - 2y
  83.         '1' when s13,                   -- load 6x - 2y
  84.         '1' when s14,                   -- load 7x - 2y
  85.         '1' when s15,                   -- load 8x - 2y
  86.         '0' when s16;                   -- hold
  87.  
  88.  
  89.     with q select alus <=
  90.         x"0" when s1,                   -- 0 - > a        = 0
  91.         x"0" when s2,                   -- y -> b
  92.         x"0" when s3,                   -- b + b -> b     = 2y
  93.         x"0" when s4,                   -- a or b -> a    = 2y
  94.         x"0" when s5,                   -- a nand b -> b  = !2y
  95.         x"0" when s6,                   -- b + 1 -> b     = -2y
  96.         x"0" when s7,                   -- x -> a
  97.         x"0" when s8,                   -- x + b -> b     = x -2y
  98.         x"0" when s9,                   -- x + b -> b     = 2x -2y
  99.         x"0" when s10,                  -- x + b -> b     = 3x -2y
  100.         x"0" when s11,                  -- x + b -> b     = 4x -2y
  101.         x"0" when s12,                  -- x + b -> b     = 5x -2y
  102.         x"0" when s13,                  -- x + b -> b     = 6x -2y
  103.         x"0" when s14,                  -- x + b -> b     = 7x -2y
  104.         x"0" when s15,                  -- x + b -> b     = 8x -2y
  105.         x"0" when s16;                  -- hold
  106.  
  107.  
  108.     with q select muxs <=
  109.         x"3" when s1,                   -- alu
  110.         x"1" when s2,                   -- y
  111.         x"3" when s3,                   -- alu
  112.         x"3" when s4,                   -- alu
  113.         x"3" when s5,                   -- alu
  114.         x"3" when s6,                   -- alu
  115.         x"0" when s7,                   -- x
  116.         x"3" when s8,                   -- alu
  117.         x"3" when s9,                   -- alu
  118.         x"3" when s10,                  -- alu
  119.         x"3" when s11,                  -- alu
  120.         x"3" when s12,                  -- alu
  121.         x"3" when s13,                  -- alu
  122.         x"3" when s14,                  -- alu
  123.         x"3" when s15,                  -- alu
  124.         x"2" when s16;                  -- hold
  125.  
  126.  
  127. end architecture RTL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement