7027fcfc48eaa30b1feaf706b0a9350f3e3a7e24
Stefan Schuermans separated shifter from ALU

Stefan Schuermans authored 12 years ago

1) LIBRARY ieee;
2) USE ieee.std_logic_1164.all;
3) USE ieee.numeric_std.all;
4) USE work.mips_types.all;
5) 
6) ENTITY e_mips_shifter IS
7)     PORT (
8)         i_arith: IN  std_logic;
9)         i_left:  IN  std_logic;
10)         i_val:   IN  std_logic_vector(31 DOWNTO 0);
11)         i_num:   IN  std_logic_vector(31 DOWNTO 0);
12)         o_val:   OUT std_logic_vector(31 DOWNTO 0)
13)     );
14) END ENTITY e_mips_shifter;
15) 
16) ARCHITECTURE a_mips_shifter OF e_mips_shifter IS
17) 
18)     SIGNAL s_in:   std_logic_vector(31 DOWNTO 0);
19)     SIGNAL s_fill: std_logic;
20)     SIGNAL s_out:  std_logic_vector(31 DOWNTO 0);
21) 
22)     FUNCTION l_shift(b:    std_logic;
23)                      val:  std_logic_vector(31 DOWNTO 0);
24)                      n:    natural) RETURN std_logic_vector IS
25)         VARIABLE v_fill: std_logic_vector(31 DOWNTO 0);
26)     BEGIN
27)         v_fill := (OTHERS => '0');
28)         IF b = '1' THEN
29)             RETURN val(31 - n DOWNTO 0) & v_fill(n - 1 DOWNTO 0);
30)         ELSE
31)             RETURN val;
32)         END IF;
33)     END FUNCTION l_shift;
34) 
35)     FUNCTION r_shift(b:    std_logic;
36)                      val:  std_logic_vector(31 DOWNTO 0);
37)                      fill: std_logic;
38)                      n:    natural) RETURN std_logic_vector IS
39)         VARIABLE v_fill: std_logic_vector(31 DOWNTO 0);
40)     BEGIN
41)         v_fill := (OTHERS => fill);
42)         IF b = '1' THEN
43)             RETURN v_fill(n - 1 DOWNTO 0) & val(31 DOWNTO n);
44)         ELSE
45)             RETURN val;
46)         END IF;
47)     END FUNCTION r_shift;
48) 
49) BEGIN
50) 
51)     s_fill <= i_arith AND s_in(31);
52) 
Stefan Schuermans fix sensitivity list

Stefan Schuermans authored 12 years ago

53)     p_shift: PROCESS(i_left, i_val, i_num, s_fill)