0% found this document useful (0 votes)
76 views

Basic Multiplier Circuit: Week 9

This document discusses binary multiplication and multiplication circuits in Verilog. It explains that multiplication can be implemented using repeated addition by representing the AND operation as multiplication of two bits. A 2x2 and 4x4 binary multiplier circuit are shown using AND gates to generate partial products that are summed using adders. The document also provides an example Verilog code for a 4x4 multiplier module. It notes that multipliers are complex circuits that require adders to sum the partial products, with the number of adders depending on the bit sizes being multiplied. Shifting left is also described as a way to multiply by powers of two by shifting the digits.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Basic Multiplier Circuit: Week 9

This document discusses binary multiplication and multiplication circuits in Verilog. It explains that multiplication can be implemented using repeated addition by representing the AND operation as multiplication of two bits. A 2x2 and 4x4 binary multiplier circuit are shown using AND gates to generate partial products that are summed using adders. The document also provides an example Verilog code for a 4x4 multiplier module. It notes that multipliers are complex circuits that require adders to sum the partial products, with the number of adders depending on the bit sizes being multiplied. Shifting left is also described as a way to multiply by powers of two by shifting the digits.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Basic Multiplier Circuit

Week 9
Multiplication in Verilog

Multiplication

Multiplication cant be that hard!


Its just repeated addition.
If we have adders, we can do multiplication also.
Remember that the AND operation is equivalent to multiplication on two
bits:

ab

b ab

Multiplication in Verilog

Binary multiplication example

1
0

1
1

0
1

1
0

Multiplicand
Multiplier

0
1

Partial products

0
0
1

1
0

1
1
0

0
1
0
0

Product

Since we always multiply by either 0 or 1, the partial products are


always either 0000 or the multiplicand (1101 in this example).
There are four partial products which are added to form the result.
We can add them in pairs, using three adders.
Even though the product has up to 8 bits, we can use 4-bit adders if
we stagger them leftwards, like the partial products themselves.

Multiplication in Verilog

A 2x2 binary multiplier

The AND gates produce the


partial products.
For a 2-bit by 2-bit multiplier,
we can just use two half
adders to sum the partial
products. In general, though,
well need full adders.
Here C3-C0 are the product,
not carries!

+
C3

B1
A1

B0
A0

A1B1

A0B1
A1B0

A0B0

C2

C1

C0

Multiplication in Verilog

A 4x4 multiplier circuit

Multiplication in Verilog

Verilog Code for 4*4 Multiplier

module booth_encoder(mr,md,x,z);
input[3:0] mr,md;
output [3:0] x,z;
//reg [3:0]
mr,md;
reg [3:0]
x,z;
reg [1:0]
i;
always@(mr or md)
begin
x[0]=md[0];
z[0]=md[0];
x[1]=md[1]&~md[0];
z[1]=md[1]^md[0];
x[2]=md[2]&~md[1];
z[2]=md[2]^md[1];
x[3]=md[3]&~md[2];
z[3]=md[3]^md[2];
end
endmodule // booth_encoder
Multiplication in Verilog

More on multipliers

Notice that this 4-bit multiplier produces an 8-bit result.


We could just keep all 8 bits.
Or, if we needed a 4-bit result, we could ignore C4-C7, and consider
it an overflow condition if the result is longer than 4 bits.
Multipliers are very complex circuits.
In general, when multiplying an m-bit number by an n-bit number:
There are n partial products, one for each bit of the multiplier.
This requires n-1 adders, each of which can add m bits (the size
of the multiplicand).
The circuit for 32-bit or 64-bit multiplication would be huge!

Multiplication in Verilog

Multiplication: a special case

In decimal, an easy way to multiply by 10 is to shift all the digits to the


left, and tack a 0 to the right end.
128 x 10 = 1280

We can do the same thing in binary. Shifting left is equivalent to


multiplying by 2:
11 x 10 = 110

Shifting left twice is equivalent to multiplying by 4:


11 x 100 = 1100

(in decimal, 3 x 2 = 6)

(in decimal, 3 x 4 = 12)

As an aside, shifting to the right is equivalent to dividing by 2.


110 10 = 11

(in decimal, 6 2 = 3)

Multiplication in Verilog

Addition and multiplication summary

Adder and multiplier circuits mimic human algorithms for addition and
multiplication.
Adders and multipliers are built hierarchically.
We start with half adders or full adders and work our way up.
Building these functions from scratch with truth tables and K-maps
would be pretty difficult.
The arithmetic circuits impose a limit on the number of bits that can be
added. Exceeding this limit results in overflow.
There is a tradeoff between simple but slow circuits (ripple carry
adders) and complex but fast circuits (carry lookahead adders).
Multiplication and division by powers of 2 can be handled with simple
shifting.

Multiplication in Verilog

You might also like