OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [or1200/] [or1200_fpu_mul.v] - Blame information for rev 360

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 350 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  or1200_fpu_mul                                              ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://opencores.org/project,or1k                           ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Serial multiplication entity for the multiplication unit    ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////                                                              ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Original design (FPU100) -                            ////
16
////        Jidan Al-eryani, jidan@gmx.net                        ////
17
////      - Conv. to Verilog and inclusion in OR1200 -            ////
18
////        Julius Baxter, julius@opencores.org                   ////
19
////                                                              ////
20
//////////////////////////////////////////////////////////////////////
21
//
22
//  Copyright (C) 2006, 2010
23
//
24
//      This source file may be used and distributed without        
25
//      restriction provided that this copyright statement is not   
26
//      removed from the file and that any derivative work contains 
27
//      the original copyright notice and the associated disclaimer.
28
//                                                           
29
//              THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY     
30
//      EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED   
31
//      TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS   
32
//      FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR      
33
//      OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,         
34
//      INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    
35
//      (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE   
36
//      GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR        
37
//      BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF  
38
//      LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT  
39
//      (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT  
40
//      OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE         
41
//      POSSIBILITY OF SUCH DAMAGE. 
42
//
43
 
44
module or1200_fpu_mul
45
(
46
   clk_i,
47
   fracta_i,
48
   fractb_i,
49
   signa_i,
50
   signb_i,
51
   start_i,
52
   fract_o,
53
   sign_o,
54
   ready_o
55
   );
56
 
57
   parameter FP_WIDTH = 32;
58
   parameter MUL_SERIAL = 0; // 0 for parallel multiplier, 1 for serial
59
   parameter MUL_COUNT = 11; //11 for parallel multiplier, 34 for serial
60
   parameter FRAC_WIDTH = 23;
61
   parameter EXP_WIDTH = 8;
62
   parameter ZERO_VECTOR = 31'd0;
63
   parameter INF = 31'b1111111100000000000000000000000;
64
   parameter QNAN = 31'b1111111110000000000000000000000;
65
   parameter SNAN = 31'b1111111100000000000000000000001;
66
 
67
   input clk_i;
68
   input [FRAC_WIDTH:0] fracta_i;
69
   input [FRAC_WIDTH:0] fractb_i;
70
   input                signa_i;
71
   input                signb_i;
72
   input                start_i;
73
   output reg [2*FRAC_WIDTH+1:0] fract_o;
74
   output reg                sign_o;
75
   output reg                ready_o;
76
 
77
   parameter t_state_waiting = 1'b0,
78
               t_state_busy = 1'b1;
79
 
80
   reg [47:0]                 s_fract_o;
81
   reg [23:0]                 s_fracta_i;
82
   reg [23:0]                 s_fractb_i;
83
   reg                       s_signa_i, s_signb_i;
84
   wire                      s_sign_o;
85
   reg                       s_start_i;
86
   reg                       s_ready_o;
87
   reg                       s_state;
88
   reg [4:0]                  s_count;
89
   wire [23:0]                s_tem_prod;
90
 
91
   // Input Register
92
   always @(posedge clk_i)
93
     begin
94
        s_fracta_i <= fracta_i;
95
        s_fractb_i <= fractb_i;
96
        s_signa_i<= signa_i;
97
        s_signb_i<= signb_i;
98
        s_start_i <= start_i;
99
     end
100
 
101
   // Output Register
102
   always @(posedge clk_i)
103
     begin
104
        fract_o <= s_fract_o;
105
        sign_o <= s_sign_o;
106
        ready_o <= s_ready_o;
107
     end
108
 
109
   assign s_sign_o = signa_i ^ signb_i;
110
 
111
   // FSM
112
   always @(posedge clk_i)
113
     if (s_start_i)
114
       begin
115
          s_state <= t_state_busy;
116
          s_count <= 0;
117
       end
118
     else if (s_count==23)
119
       begin
120
          s_state <= t_state_waiting;
121
          s_ready_o <= 1;
122
          s_count <=0;
123
       end
124
     else if (s_state==t_state_busy)
125
       s_count <= s_count + 1;
126
     else
127
       begin
128
          s_state <= t_state_waiting;
129
          s_ready_o <= 0;
130
       end
131
 
132
   assign s_tem_prod[0] = s_fracta_i[0] & s_fractb_i[s_count];
133
   assign s_tem_prod[1] = s_fracta_i[1] & s_fractb_i[s_count];
134
   assign s_tem_prod[2] = s_fracta_i[2] & s_fractb_i[s_count];
135
   assign s_tem_prod[3] = s_fracta_i[3] & s_fractb_i[s_count];
136
   assign s_tem_prod[4] = s_fracta_i[4] & s_fractb_i[s_count];
137
   assign s_tem_prod[5] = s_fracta_i[5] & s_fractb_i[s_count];
138
   assign s_tem_prod[6] = s_fracta_i[6] & s_fractb_i[s_count];
139
   assign s_tem_prod[7] = s_fracta_i[7] & s_fractb_i[s_count];
140
   assign s_tem_prod[8] = s_fracta_i[8] & s_fractb_i[s_count];
141
   assign s_tem_prod[9] = s_fracta_i[9] & s_fractb_i[s_count];
142
   assign s_tem_prod[10] = s_fracta_i[10] & s_fractb_i[s_count];
143
   assign s_tem_prod[11] = s_fracta_i[11] & s_fractb_i[s_count];
144
   assign s_tem_prod[12] = s_fracta_i[12] & s_fractb_i[s_count];
145
   assign s_tem_prod[13] = s_fracta_i[13] & s_fractb_i[s_count];
146
   assign s_tem_prod[14] = s_fracta_i[14] & s_fractb_i[s_count];
147
   assign s_tem_prod[15] = s_fracta_i[15] & s_fractb_i[s_count];
148
   assign s_tem_prod[16] = s_fracta_i[16] & s_fractb_i[s_count];
149
   assign s_tem_prod[17] = s_fracta_i[17] & s_fractb_i[s_count];
150
   assign s_tem_prod[18] = s_fracta_i[18] & s_fractb_i[s_count];
151
   assign s_tem_prod[19] = s_fracta_i[19] & s_fractb_i[s_count];
152
   assign s_tem_prod[20] = s_fracta_i[20] & s_fractb_i[s_count];
153
   assign s_tem_prod[21] = s_fracta_i[21] & s_fractb_i[s_count];
154
   assign s_tem_prod[22] = s_fracta_i[22] & s_fractb_i[s_count];
155
   assign s_tem_prod[23] = s_fracta_i[23] & s_fractb_i[s_count];
156
 
157
   wire [47:0] v_prod_shl;
158
   assign v_prod_shl = {24'd0,s_tem_prod} << s_count[4:0];
159
 
160
   always @(posedge clk_i)
161
     if (s_state==t_state_busy)
162
       begin
163
          if (|s_count)
164
            s_fract_o <= v_prod_shl + s_fract_o;
165
          else
166
            s_fract_o <= v_prod_shl;
167
       end
168
 
169
endmodule // or1200_fpu_mul
170
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.