lm32_mc_arithmetic.v

changeset 27
d6c693415d59
parent 26
73de224304c1
     1.1 --- a/lm32_mc_arithmetic.v	Sat Aug 06 00:02:46 2011 +0100
     1.2 +++ b/lm32_mc_arithmetic.v	Sat Aug 06 01:26:56 2011 +0100
     1.3 @@ -170,59 +170,59 @@
     1.4  begin
     1.5      if (rst_i == `TRUE)
     1.6      begin
     1.7 -        cycles <= #1 {6{1'b0}};
     1.8 -        p <= #1 {`LM32_WORD_WIDTH{1'b0}};
     1.9 -        a <= #1 {`LM32_WORD_WIDTH{1'b0}};
    1.10 -        b <= #1 {`LM32_WORD_WIDTH{1'b0}};
    1.11 +        cycles <= {6{1'b0}};
    1.12 +        p <= {`LM32_WORD_WIDTH{1'b0}};
    1.13 +        a <= {`LM32_WORD_WIDTH{1'b0}};
    1.14 +        b <= {`LM32_WORD_WIDTH{1'b0}};
    1.15  `ifdef CFG_MC_BARREL_SHIFT_ENABLED
    1.16 -        sign_extend_x <= #1 1'b0;
    1.17 +        sign_extend_x <= 1'b0;
    1.18  `endif
    1.19  `ifdef CFG_MC_DIVIDE_ENABLED
    1.20 -        divide_by_zero_x <= #1 `FALSE;
    1.21 +        divide_by_zero_x <= `FALSE;
    1.22  `endif
    1.23 -        result_x <= #1 {`LM32_WORD_WIDTH{1'b0}};
    1.24 -        state <= #1 `LM32_MC_STATE_IDLE;
    1.25 +        result_x <= {`LM32_WORD_WIDTH{1'b0}};
    1.26 +        state <= `LM32_MC_STATE_IDLE;
    1.27      end
    1.28      else
    1.29      begin
    1.30  `ifdef CFG_MC_DIVIDE_ENABLED
    1.31 -        divide_by_zero_x <= #1 `FALSE;
    1.32 +        divide_by_zero_x <= `FALSE;
    1.33  `endif
    1.34          case (state)
    1.35          `LM32_MC_STATE_IDLE:
    1.36          begin
    1.37              if (stall_d == `FALSE)                 
    1.38              begin          
    1.39 -                cycles <= #1 `LM32_WORD_WIDTH;
    1.40 -                p <= #1 32'b0;
    1.41 -                a <= #1 operand_0_d;
    1.42 -                b <= #1 operand_1_d;                    
    1.43 +                cycles <= `LM32_WORD_WIDTH;
    1.44 +                p <= 32'b0;
    1.45 +                a <= operand_0_d;
    1.46 +                b <= operand_1_d;                    
    1.47  `ifdef CFG_MC_DIVIDE_ENABLED
    1.48                  if (divide_d == `TRUE)
    1.49 -                    state <= #1 `LM32_MC_STATE_DIVIDE;
    1.50 +                    state <= `LM32_MC_STATE_DIVIDE;
    1.51                  if (modulus_d == `TRUE)
    1.52 -                    state <= #1 `LM32_MC_STATE_MODULUS;
    1.53 +                    state <= `LM32_MC_STATE_MODULUS;
    1.54  `endif                    
    1.55  `ifdef CFG_MC_MULTIPLY_ENABLED
    1.56                  if (multiply_d == `TRUE)
    1.57 -                    state <= #1 `LM32_MC_STATE_MULTIPLY;
    1.58 +                    state <= `LM32_MC_STATE_MULTIPLY;
    1.59  `endif
    1.60  `ifdef CFG_MC_BARREL_SHIFT_ENABLED
    1.61                  if (shift_left_d == `TRUE)
    1.62                  begin
    1.63 -                    state <= #1 `LM32_MC_STATE_SHIFT_LEFT;
    1.64 -                    sign_extend_x <= #1 sign_extend_d;
    1.65 -                    cycles <= #1 operand_1_d[4:0];
    1.66 -                    a <= #1 operand_0_d;
    1.67 -                    b <= #1 operand_0_d;
    1.68 +                    state <= `LM32_MC_STATE_SHIFT_LEFT;
    1.69 +                    sign_extend_x <= sign_extend_d;
    1.70 +                    cycles <= operand_1_d[4:0];
    1.71 +                    a <= operand_0_d;
    1.72 +                    b <= operand_0_d;
    1.73                  end
    1.74                  if (shift_right_d == `TRUE)
    1.75                  begin
    1.76 -                    state <= #1 `LM32_MC_STATE_SHIFT_RIGHT;
    1.77 -                    sign_extend_x <= #1 sign_extend_d;
    1.78 -                    cycles <= #1 operand_1_d[4:0];
    1.79 -                    a <= #1 operand_0_d;
    1.80 -                    b <= #1 operand_0_d;
    1.81 +                    state <= `LM32_MC_STATE_SHIFT_RIGHT;
    1.82 +                    sign_extend_x <= sign_extend_d;
    1.83 +                    cycles <= operand_1_d[4:0];
    1.84 +                    a <= operand_0_d;
    1.85 +                    b <= operand_0_d;
    1.86                  end
    1.87  `endif
    1.88              end            
    1.89 @@ -232,74 +232,74 @@
    1.90          begin
    1.91              if (t[32] == 1'b0)
    1.92              begin
    1.93 -                p <= #1 t[31:0];
    1.94 -                a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b1};
    1.95 +                p <= t[31:0];
    1.96 +                a <= {a[`LM32_WORD_WIDTH-2:0], 1'b1};
    1.97              end
    1.98              else 
    1.99              begin
   1.100 -                p <= #1 {p[`LM32_WORD_WIDTH-2:0], a[`LM32_WORD_WIDTH-1]};
   1.101 -                a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.102 +                p <= {p[`LM32_WORD_WIDTH-2:0], a[`LM32_WORD_WIDTH-1]};
   1.103 +                a <= {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.104              end
   1.105 -            result_x <= #1 a;
   1.106 +            result_x <= a;
   1.107              if ((cycles == `LM32_WORD_WIDTH'd0) || (kill_x == `TRUE))
   1.108              begin
   1.109                  // Check for divide by zero
   1.110 -                divide_by_zero_x <= #1 b == {`LM32_WORD_WIDTH{1'b0}};
   1.111 -                state <= #1 `LM32_MC_STATE_IDLE;
   1.112 +                divide_by_zero_x <= b == {`LM32_WORD_WIDTH{1'b0}};
   1.113 +                state <= `LM32_MC_STATE_IDLE;
   1.114              end
   1.115 -            cycles <= #1 cycles - 1'b1;
   1.116 +            cycles <= cycles - 1'b1;
   1.117          end
   1.118          `LM32_MC_STATE_MODULUS:
   1.119          begin
   1.120              if (t[32] == 1'b0)
   1.121              begin
   1.122 -                p <= #1 t[31:0];
   1.123 -                a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b1};
   1.124 +                p <= t[31:0];
   1.125 +                a <= {a[`LM32_WORD_WIDTH-2:0], 1'b1};
   1.126              end
   1.127              else 
   1.128              begin
   1.129 -                p <= #1 {p[`LM32_WORD_WIDTH-2:0], a[`LM32_WORD_WIDTH-1]};
   1.130 -                a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.131 +                p <= {p[`LM32_WORD_WIDTH-2:0], a[`LM32_WORD_WIDTH-1]};
   1.132 +                a <= {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.133              end
   1.134 -            result_x <= #1 p;
   1.135 +            result_x <= p;
   1.136              if ((cycles == `LM32_WORD_WIDTH'd0) || (kill_x == `TRUE))
   1.137              begin
   1.138                  // Check for divide by zero
   1.139 -                divide_by_zero_x <= #1 b == {`LM32_WORD_WIDTH{1'b0}};
   1.140 -                state <= #1 `LM32_MC_STATE_IDLE;
   1.141 +                divide_by_zero_x <= b == {`LM32_WORD_WIDTH{1'b0}};
   1.142 +                state <= `LM32_MC_STATE_IDLE;
   1.143              end
   1.144 -            cycles <= #1 cycles - 1'b1;
   1.145 +            cycles <= cycles - 1'b1;
   1.146          end
   1.147  `endif        
   1.148  `ifdef CFG_MC_MULTIPLY_ENABLED
   1.149          `LM32_MC_STATE_MULTIPLY:
   1.150          begin
   1.151              if (b[0] == 1'b1)
   1.152 -                p <= #1 p + a;
   1.153 -            b <= #1 {1'b0, b[`LM32_WORD_WIDTH-1:1]};
   1.154 -            a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.155 -            result_x <= #1 p;
   1.156 +                p <= p + a;
   1.157 +            b <= {1'b0, b[`LM32_WORD_WIDTH-1:1]};
   1.158 +            a <= {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.159 +            result_x <= p;
   1.160              if ((cycles == `LM32_WORD_WIDTH'd0) || (kill_x == `TRUE))
   1.161 -                state <= #1 `LM32_MC_STATE_IDLE;
   1.162 -            cycles <= #1 cycles - 1'b1;
   1.163 +                state <= `LM32_MC_STATE_IDLE;
   1.164 +            cycles <= cycles - 1'b1;
   1.165          end
   1.166  `endif     
   1.167  `ifdef CFG_MC_BARREL_SHIFT_ENABLED
   1.168          `LM32_MC_STATE_SHIFT_LEFT:
   1.169          begin       
   1.170 -            a <= #1 {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.171 -            result_x <= #1 a;
   1.172 +            a <= {a[`LM32_WORD_WIDTH-2:0], 1'b0};
   1.173 +            result_x <= a;
   1.174              if ((cycles == `LM32_WORD_WIDTH'd0) || (kill_x == `TRUE))
   1.175 -                state <= #1 `LM32_MC_STATE_IDLE;
   1.176 -            cycles <= #1 cycles - 1'b1;
   1.177 +                state <= `LM32_MC_STATE_IDLE;
   1.178 +            cycles <= cycles - 1'b1;
   1.179          end
   1.180          `LM32_MC_STATE_SHIFT_RIGHT:
   1.181          begin       
   1.182 -            b <= #1 {fill_value, b[`LM32_WORD_WIDTH-1:1]};
   1.183 -            result_x <= #1 b;
   1.184 +            b <= {fill_value, b[`LM32_WORD_WIDTH-1:1]};
   1.185 +            result_x <= b;
   1.186              if ((cycles == `LM32_WORD_WIDTH'd0) || (kill_x == `TRUE))
   1.187 -                state <= #1 `LM32_MC_STATE_IDLE;
   1.188 -            cycles <= #1 cycles - 1'b1;
   1.189 +                state <= `LM32_MC_STATE_IDLE;
   1.190 +            cycles <= cycles - 1'b1;
   1.191          end
   1.192  `endif   
   1.193          endcase