902aa402b3830b9c9aa26758390b6eb93b42a0f5
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd   1) -- MIPS I system
Stefan Schuermans replace email address in he...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd   2) -- Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd   3) -- Copyleft GNU public license V2 or later
mips/mul_slow.vhd   4) --          http://www.gnu.org/copyleft/gpl.html
mips/mul_slow.vhd   5) 
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd        6) LIBRARY ieee;
mips/mul.vhd        7) USE ieee.std_logic_1164.all;
mips/mul.vhd        8) USE ieee.numeric_std.all;
mips/mul.vhd        9) USE work.mips_types.all;
mips/mul.vhd       10) 
mips/mul.vhd       11) ENTITY e_mips_mul IS
mips/mul.vhd       12)     PORT (
mips/mul.vhd       13)         rst:      IN  std_logic;
mips/mul.vhd       14)         clk:      IN  std_logic;
mips/mul.vhd       15)         i_a:      IN  std_logic_vector(31 DOWNTO 0);
mips/mul.vhd       16)         i_b:      IN  std_logic_vector(31 DOWNTO 0);
mips/mul.vhd       17)         i_signed: IN  std_logic;
mips/mul.vhd       18)         i_start:  IN  std_logic;
mips/mul.vhd       19)         o_busy:   OUT std_logic;
mips/mul.vhd       20)         o_res:    OUT std_logic_vector(63 DOWNTO 0)
mips/mul.vhd       21)     );
mips/mul.vhd       22) END ENTITY e_mips_mul;
mips/mul.vhd       23) 
mips/mul.vhd       24) ARCHITECTURE a_mips_mul OF e_mips_mul IS
mips/mul.vhd       25) 
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  26)     TYPE t_state IS (idle, mul1, add1, mul2, add2, mul3, add3, mul4, add4,
mips/mul_slow.vhd  27)                      post);
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       28)     SIGNAL n_state: t_state;
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  29)     SIGNAL r_state: t_state := idle;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       30) 
mips/mul.vhd       31)     SIGNAL n_a:   unsigned(31 DOWNTO 0);
mips/mul.vhd       32)     SIGNAL n_b:   unsigned(31 DOWNTO 0);
mips/mul.vhd       33)     SIGNAL n_neg: boolean;
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  34)     SIGNAL n_r:   unsigned(31 DOWNTO 0);
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       35)     SIGNAL n_res: unsigned(63 DOWNTO 0);
Stefan Schuermans add initial values for regi...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  36)     SIGNAL r_a:   unsigned(31 DOWNTO 0) := (OTHERS => '0');
mips/mul_slow.vhd  37)     SIGNAL r_b:   unsigned(31 DOWNTO 0) := (OTHERS => '0');
mips/mul_slow.vhd  38)     SIGNAL r_neg: boolean               := false;
mips/mul_slow.vhd  39)     SIGNAL r_r:   unsigned(31 DOWNTO 0) := (OTHERS => '0');
mips/mul_slow.vhd  40)     SIGNAL r_res: unsigned(63 DOWNTO 0) := (OTHERS => '0');
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       41) 
mips/mul.vhd       42) BEGIN
mips/mul.vhd       43) 
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  44)     p_mul: PROCESS(r_state, r_a, r_b, r_neg, r_r, r_res,
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       45)                    i_a, i_b, i_signed, i_start)
mips/mul.vhd       46)         VARIABLE v_a:   unsigned(15 DOWNTO 0);
mips/mul.vhd       47)         VARIABLE v_b:   unsigned(15 DOWNTO 0);
mips/mul.vhd       48)         VARIABLE v_res: unsigned(31 DOWNTO 0);
mips/mul.vhd       49)         VARIABLE v_add: unsigned(63 DOWNTO 0);
mips/mul.vhd       50)         VARIABLE v_sum: unsigned(63 DOWNTO 0);
mips/mul.vhd       51)     BEGIN
mips/mul.vhd       52)         o_busy  <= '0';
mips/mul.vhd       53)         n_state <= idle;
mips/mul.vhd       54)         n_a     <= r_a;
mips/mul.vhd       55)         n_b     <= r_b;
mips/mul.vhd       56)         n_neg   <= r_neg;
mips/mul.vhd       57)         n_res   <= r_res;
mips/mul.vhd       58)         v_a     := (OTHERS => '0');
mips/mul.vhd       59)         v_b     := (OTHERS => '0');
mips/mul.vhd       60)         v_add   := (OTHERS => '0');
mips/mul.vhd       61)         CASE r_state IS
mips/mul.vhd       62)             WHEN idle =>
mips/mul.vhd       63)                 IF i_start = '1' THEN
mips/mul.vhd       64)                     o_busy  <= '1';
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  65)                     n_state <= mul1;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       66)                     IF i_signed = '1' THEN
mips/mul.vhd       67)                         IF i_a(31) = '1' THEN
mips/mul.vhd       68)                             n_a <= unsigned(-signed(i_a));
mips/mul.vhd       69)                         ELSE
mips/mul.vhd       70)                             n_a <= unsigned(i_a);
mips/mul.vhd       71)                         END IF;
mips/mul.vhd       72)                         IF i_b(31) = '1' THEN
mips/mul.vhd       73)                             n_b <= unsigned(-signed(i_b));
mips/mul.vhd       74)                         ELSE
mips/mul.vhd       75)                             n_b <= unsigned(i_b);
mips/mul.vhd       76)                         END IF;
mips/mul.vhd       77)                         n_neg <= i_a(31) = '1' XOR i_b(31) = '1';
mips/mul.vhd       78)                     ELSE
mips/mul.vhd       79)                         n_a   <= unsigned(i_a);
mips/mul.vhd       80)                         n_b   <= unsigned(i_b);
mips/mul.vhd       81)                         n_neg <= false;
mips/mul.vhd       82)                     END IF;
mips/mul.vhd       83)                 END IF;
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  84)             WHEN mul1 =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       85)                 o_busy  <= '1';
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  86)                 n_state <= add1;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       87)                 v_a     := r_a(15 DOWNTO  0);
mips/mul.vhd       88)                 v_b     := r_b(15 DOWNTO  0);
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  89)             WHEN add1 =>
mips/mul_slow.vhd  90)                 o_busy  <= '1';
mips/mul_slow.vhd  91)                 n_state <= mul2;
mips/mul_slow.vhd  92)                 v_add := X"00000000" & r_r;
mips/mul_slow.vhd  93)             WHEN mul2 =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       94)                 o_busy  <= '1';
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  95)                 n_state <= add2;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       96)                 v_a     := r_a(31 DOWNTO 16);
mips/mul.vhd       97)                 v_b     := r_b(15 DOWNTO  0);
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd  98)             WHEN add2 =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd       99)                 o_busy  <= '1';
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 100)                 n_state <= mul3;
mips/mul_slow.vhd 101)                 v_add := X"0000" & r_r & X"0000";
mips/mul_slow.vhd 102)             WHEN mul3 =>
mips/mul_slow.vhd 103)                 o_busy  <= '1';
mips/mul_slow.vhd 104)                 n_state <= add3;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      105)                 v_a     := r_a(15 DOWNTO  0);
mips/mul.vhd      106)                 v_b     := r_b(31 DOWNTO 16);
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 107)             WHEN add3 =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      108)                 o_busy  <= '1';
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 109)                 n_state <= mul4;
mips/mul_slow.vhd 110)                 v_add := X"0000" & r_r & X"0000";
mips/mul_slow.vhd 111)             WHEN mul4 =>
mips/mul_slow.vhd 112)                 o_busy  <= '1';
mips/mul_slow.vhd 113)                 n_state <= add4;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      114)                 v_a     := r_a(31 DOWNTO 16);
mips/mul.vhd      115)                 v_b     := r_b(31 DOWNTO 16);
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 116)             WHEN add4 =>
mips/mul_slow.vhd 117)                 o_busy  <= '1';
mips/mul_slow.vhd 118)                 n_state <= post;
mips/mul_slow.vhd 119)                 v_add := r_r & X"00000000";
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      120)             WHEN OTHERS => NULL;
mips/mul.vhd      121)         END CASE;
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 122)         n_r <= v_a * v_b;
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      123)         v_sum := r_res + v_add;
mips/mul.vhd      124)         CASE r_state IS
mips/mul.vhd      125)             WHEN idle =>
mips/mul.vhd      126)                 n_res <= (OTHERS => '0');
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 127)             WHEN add1 | add2 | add3 | add4 =>
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      128)                 n_res <= v_sum;
mips/mul.vhd      129)             WHEN post =>
mips/mul.vhd      130)                 IF r_neg THEN
mips/mul.vhd      131)                     n_res <= unsigned(-signed(r_res));
mips/mul.vhd      132)                 ELSE
mips/mul.vhd      133)                     n_res <= r_res;
mips/mul.vhd      134)                 END IF;
mips/mul.vhd      135)             WHEN OTHERS => NULL;
mips/mul.vhd      136)         END CASE;
mips/mul.vhd      137)     END PROCESS p_mul;
mips/mul.vhd      138) 
mips/mul.vhd      139)     p_sync: PROCESS(rst, clk)
mips/mul.vhd      140)     BEGIN
mips/mul.vhd      141)         IF rst = '1' THEN
mips/mul.vhd      142)             r_state <= idle;
mips/mul.vhd      143)             r_a     <= (OTHERS => '0');
mips/mul.vhd      144)             r_b     <= (OTHERS => '0');
mips/mul.vhd      145)             r_neg   <= false;
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 146)             r_r     <= (OTHERS => '0');
Stefan Schuermans moved multiplier to own module

Stefan Schuermans authored 12 years ago

mips/mul.vhd      147)             r_res   <= (OTHERS => '0');
mips/mul.vhd      148)         ELSIF rising_edge(clk) THEN
mips/mul.vhd      149)             r_state <= n_state;
mips/mul.vhd      150)             r_a     <= n_a;
mips/mul.vhd      151)             r_b     <= n_b;
mips/mul.vhd      152)             r_neg   <= n_neg;
Stefan Schuermans second version of multiplie...

Stefan Schuermans authored 12 years ago

mips/mul_slow.vhd 153)             r_r     <= n_r;