# Can anybody tell me about 2's complement multipliers ?

Status
Not open for further replies.

#### narasimha_80

##### Newbie level 5 Hello,

I want to implement 8 bit 2's complement multipliers ( for fractional number multiplication ) in VHDL. Can anybody suggest me some algorithms or send me the VHDL/verilog code ?

Narasimha Naik

#### echo47 I would do this in Verilog. Verilog doesn't have any fractional data types, so I would simply remember where I put the decimal point.

Code:
module top (a, b, y);
input signed  [7:0] a, b;
output signed [7:0] y;

assign y = a * b;
endmodule

#### drwho78

##### Full Member level 3 • sepehra_6191

### sepehra_6191

points: 2

#### anjali

##### Full Member level 3 its better to use booths algorithm for signed multiplication.

• sepehra_6191

### sepehra_6191

points: 2

#### narasimha_80

##### Newbie level 5 Hello Anjali,

Actually I want to implement fractional value (in 2's complement) multipliers in VHDL.ie represeneting fractional value in binary and multiplying. Does Booths algorithms support this fractional value multiplication ? If not, Can you suggest any algorithms for this ? I really need some help.

Best Regards,
Narasimha Naik

#### echo47 I'm not sure I understand your question. Multiplication of fractions is exactly the same as integer multiplication, except for the position of the decimal point.

For example, let's assume you already have hardware that multiplies two 8-bit integers to get a 16-bit product:
aaaaaaaa * bbbbbbbb = yyyyyyyyyyyyyyyy

You can use the same hardware to multiply two 8-bit fraction values:
aaa.aaaaa * bbbbbb.bb = yyyyyyyyy.yyyyyyy

However, if you don't yet have an integer multiplier, and for some reason your don't want to use the HDL * operator, than that's a different problem.

#### narasimha_80

##### Newbie level 5 Hello echo47,

you have written that same hardware can be used for integer and fractional multiplication. ie

aaaaaaaa * bbbbbbbb = yyyyyyyyyyyyyyyy

aaa.aaaaa * bbbbbb.bb = yyyyyyyyy.yyyyyyy

I think we can not use the same hardware for integer and fractional multiplication.

See for example
0.5 * 0.5 = 0.25

0.5 = 01 in binary;

Then, 01 * 01 =0001 = 1 in decimal and 0001 is not equal to 0.25 in binary.

But, 0.25 = 0100

So I think we cannot use same hardware for integer and fractional value multiplication. Isn't it ?

Write to me further.

Regards,
Narasimha Naik

#### tarkyss

##### Full Member level 6 narasimha_80
0.5 = 01 in binary;
Then, 01 * 01 =0001
0001 is not 1
0001=00.01=0.25
you should notify the position of the decimal point.
as for algorithm
there are a lot of algorithms for multiplier implemention
you can seach them in google,
it is easy to find a lot of useful links
as anjali said, booth encode is a good method for area and speed, especially 4-based booth encode.

### narasimha_80

points: 2

#### echo47 Or you can use my 8-bit example:

aaa.aaaaa * bbbbbb.bb = yyyyyyyyy.yyyyyyy
0.5 = aaa.aaaaa = 000.10000
0.5 = bbbbbb.bb = 000000.10
000.10000 * 000000.10 = 000000000.0100000 = 0.25

To determine the location of the output decimal point, you add the number of input fraction bits. Five fraction bits times two fraction bits gives you seven fraction bits.

points: 2