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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [common/] [opencores.org/] [cde/] [ip/] [mult/] [rtl/] [verilog/] [ord_r4.v] - Blame information for rev 131

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
////////////////////////////////////////////////////////////////////////////////
2
/// Booth Recoding for Higher-Radix and Signed Multiplication
3
 
4
// :PH: 4.6  Only describes Radix-2 Booth Recoding
5
 
6
 /// Basic Idea
7
//
8
// Rather than repeatedly adding either 0 or 1 times multiplicand,
9
// repeatedly add 0, 1, -1, 2, -2, etc. times the multiplicand.
10
//
11
 /// Benefits
12
//
13
// Performs signed multiplication without having to first compute the
14
// absolute value of the multiplier and multiplicand.
15
//
16
// Improved performance (when radix higher than 2).
17
 
18
 /// Multipliers Described Here
19
//
20
// Ordinary Radix-4 Unsigned Multiplier
21
//   Presented for pedagogical reasons, Booth multipliers better.
22
//   Twice as fast as earlier multipliers.
23
//   Uses more hardware than Booth multipliers below.
24
//
25
// Booth Recoding Radix-4 Multiplier
26
//   Multiplies signed numbers.
27
//   Twice as fast as earlier multipliers.
28
//
29
// Booth Recoding Radix-2 Multiplier
30
//   Multiplies signed numbers.
31
//   Uses about the same amount of hardware than earlier signed multiplier.
32
 
33
 
34
 /// Ordinary Radix-4 Multiplier Idea
35
//
36
// Review of Radix-2 Multiplication
37
//
38
//  Multiply 5 times 12.  Radix-2 multiplication (the usual way).
39
//
40
//     0101  Multiplicand
41
//     1100  Multiplier
42
//     """"
43
//     0000  0 x 0101
44
//    0000   0 x 0101
45
//   0101    1 x 0101
46
//  0101     1 x 0101
47
//  """""""
48
//  0111100  Product
49
//
50
// Radix-4 Multiplication
51
//   Let "a" denote the multiplicand and b denote the multiplier.
52
//   Pre-compute 2a and 3a.
53
//   Examine multiplier two bits at a time (rather than one bit at a time).
54
//   Based on the value of those bits add 0, a, 2a, or 3a (shifted by
55
//     the appropriate amount).
56
//
57
//   Uses n/2 additions to multiply two n-bit numbers.
58
//
59
// Two Radix-4 Multiplication Examples
60
//
61
//  Multiply 5 times 12.  Radix-4 multiplication (the faster way).
62
//
63
//     Precompute: 2a: 01010,  3a: 01111
64
//
65
//     0101  Multiplicand
66
//     1100  Multiplier
67
//     """"
68
//    00000  00 x 0101  
69
//  01111    11 x 0101
70
//  """""""
71
//  0111100  Product
72
//
73
//  Multiply 5 times 9.  Radix-4 multiplication (the faster way).
74
//
75
//     0101  Multiplicand
76
//     1001  Multiplier
77
//     """"
78
//    00101  01 x 0101
79
//  01010    10 x 0101
80
//  """""""
81
//  0101101  Product
82
 
83
 // Ordinary Radix-2^d Multiplier
84
//
85
// This is a generalization of the Radix-4 multiplier.
86
//
87
//   Let "a" denote the multiplicand and b denote the multiplier.
88
//   Pre-compute 2a, 3a, 4a, 5a, ..., (2^d-1)a
89
//   Examine multiplier d bits at a time.
90
//   Let the value of those bits be v.
91
//   Add v shifted by the appropriate amount.
92
//
93
//   Uses n/d additions to multiply two n-bit numbers.
94
 
95
 
96
// :Example:
97
//
98
// A Radix-4 multiplier.  Takes unsigned numbers.
99
 
100
module imult_ord_radix_4 #(parameter width=16)
101
(
102
   input   wire               clk,
103
   input   wire               reset,
104
   input   wire               start,
105
   input   wire [width-1:0]   multiplicand,
106
   input   wire [width-1:0]   multiplier,
107
   output  wire [2*width-1:0] prod,
108
   output  wire               ready
109
);
110
 
111
   reg   [width+1:0]          pp;
112
   reg   [width-1:0]          bit_cnt;
113
   reg   [2*width:0]          product;
114
   wire  [width+1:0]          multiplicand_X_1 = {2'b00,multiplicand};
115
   wire  [width+1:0]          multiplicand_X_2 = {1'b0,multiplicand,1'b0};
116
   wire  [width+1:0]          multiplicand_X_3 =  multiplicand_X_2 + multiplicand_X_1;
117
 
118
 
119
 
120
   assign   prod  =  product[2*width-1:0];
121
   assign   ready = ~ ( | bit_cnt);
122
 
123
 
124
 
125
   always @(*)
126
     begin
127
        case ( {product[1:0]} )
128
          2'd0: pp = {2'b0, product[2*width-1:width] };
129
          2'd1: pp = {2'b0, product[2*width-1:width] } + multiplicand_X_1;
130
          2'd2: pp = {2'b0, product[2*width-1:width] } + multiplicand_X_2;
131
          2'd3: pp = {2'b0, product[2*width-1:width] } + multiplicand_X_3;
132
        endcase
133
     end
134
 
135
 
136
   always @( posedge clk )
137
    if(reset)
138
        begin
139
        bit_cnt <= 'b0;
140
        product <= 'b0;
141
        end
142
    else
143
    begin
144
     if( ready && start )
145
        begin
146
        bit_cnt     <= width/2;
147
        product     <= {1'b0, {width{1'b0}}, multiplier };
148
        end
149
     else if( !ready )
150
        begin
151
        product     <= { 1'b0,pp, product[width-1:2] };
152
        bit_cnt     <= bit_cnt - 1;
153
        end
154
    end
155
endmodule

powered by: WebSVN 2.1.0

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