0% found this document useful (0 votes)
6 views4 pages

Booth Multiplier Verilog Module

The document describes the Booth algorithm implemented in Verilog for signed multiplication of two 8-bit numbers, producing a 16-bit product. It includes a module for the Booth multiplier, an ALU for addition and subtraction, and a test bench to validate the functionality with various test cases. The test bench initializes inputs and displays the product after each multiplication operation is completed.

Uploaded by

prafullaenc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Booth Multiplier Verilog Module

The document describes the Booth algorithm implemented in Verilog for signed multiplication of two 8-bit numbers, producing a 16-bit product. It includes a module for the Booth multiplier, an ALU for addition and subtraction, and a test bench to validate the functionality with various test cases. The test bench initializes inputs and displays the product after each multiplication operation is completed.

Uploaded by

prafullaenc
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Booth algorithm

module booth(prod, busy, mc, mp, clk, start);

output signed [15:0] prod;

output busy;

input signed [7:0] mc, mp;

input clk, start;

reg signed[7:0] A, Q, M;

reg Q_1;

reg [3:0] count;

wire signed [7:0] sum, difference;

always @(posedge clk)

begin

if (start) begin

A <= 8'b0;

M <= mc;

Q <= mp;

Q_1 <= 1'b0;

count <= 4'b0;

end

else begin

case ({Q[0], Q_1})

2'b0_1 : {A, Q, Q_1} <= {sum[7], sum, Q};

2'b1_0 : {A, Q, Q_1} <= {difference[7], difference, Q};

default: {A, Q, Q_1} <= {A[7], A, Q};

endcase
count <= count + 1'b1;

end

end

alu adder (sum, A, M, 1'b0);

alu subtracter (difference, A, ~M, 1'b1);

assign prod = {A, Q};

assign busy = (count < 8);

endmodule

//The following is an alu.

//It is an adder, but capable of subtraction:

//Recall that subtraction means adding the two's complement--

//a - b = a + (-b) = a + (inverted b + 1)

//The 1 will be coming in as cin (carry-in)

module alu(out, a, b, cin);

output signed[7:0] out;

input signed[7:0] a;

input signed[7:0] b;

input cin;

assign out = a + b + cin;

endmodule

Test Bench
module tbw_v;

reg signed [7:0] mc, mp;

reg clk, start;

wire signed [15:0] prod;


wire busy;

// Instantiate the booth multiplier module

booth uut (.prod(prod), .busy(busy), .mc(mc), .mp(mp), .clk(clk), .start(start));

// Clock generation

always #5 clk = ~clk;

initial begin

// Initialize signals

clk = 0;

start = 0;

mc = 0;

mp = 0;

// Apply test cases

#10 mc = 8'd7; mp = 8'd3; start = 1; // 7 * 3 = 21

#10 start = 0;

wait (!busy); // Wait for operation to complete

$display("Product: %d", prod);

#10 mc = -8'd4; mp = 8'd2; start = 1; // -4 * 2 = -8

#10 start = 0;
wait (!busy);

$display("Product: %d", prod);

#10 mc = -8'd6; mp = -8'd3; start = 1; // -6 * -3 = 18

#10 start = 0;

wait (!busy);

$display("Product: %d", prod);

#10 mc = 8'd15; mp = -8'd2; start = 1; // 15 * -2 = -30

#10 start = 0;

wait (!busy);

$display("Product: %d", prod);

#50 $finish;

end

endmodule

Common questions

Powered by AI

The implementation strategy in the Booth module efficiently handles simultaneous operations by using an always block sensitive to the positive edge of a clock signal. During initialization, if the start signal is high, the module resets key registers and prepares operands. As the state machine progresses, it updates the registers based on the specific value combinations of Q[0] and Q_1, ensuring synchronization and coordination across operations without interference .

Waiting for the 'busy' signal in digital circuits reflects implicit synchronization needs by ensuring that different components or states do not proceed out of sequence. In the Booth multiplier test bench, it prevents the initiation of new operations until the current task completes, ensuring accuracy and coordination across iterations. This reliance on 'busy' as a synchronization mechanism confirms that all state transitions and updates are coherently aligned .

The Booth algorithm's state update logic employs conditional statements to precisely adjust the registers A, Q, and Q_1 based on the evaluation of Q[0] and Q_1 bits. These conditions dictate whether to add, subtract, or shift, facilitating the correct accommodation for both positive and negative multipliers. This logic ensures the setup correctly loops over required iterations to compute outputs that reflect signed arithmetic accurately .

The test bench reveals that positive and negative multipliers influence the sign and value of the output product significantly. When both multipliers are positive or both are negative, the product is positive (e.g., 7 * 3 = 21, -6 * -3 = 18). Conversely, if one multiplier is negative and the other is positive, the product is negative (e.g., -4 * 2 = -8, 15 * -2 = -30).

Encapsulating the Booth multiplier in a test bench environment is crucial for validating and verifying its operation under various scenarios. This environment provides controlled conditions to apply test inputs safely and check outputs against expected results. Encapsulation benefits include isolating errors, conducting repeatable tests, and efficiently debugging to ensure accurate functionality before deployment .

The Booth multiplier offers advantages in handling signed number multiplications by effectively reducing the number of required additions or subtractions. Its ability to incorporate both addition and two's complement subtraction within a conditional, state-based framework minimizes intermediate steps. This efficiency contrasts with other methods, which may require more uniform handling of each digit, increasing complexity for similar outcomes .

The ALU module is integral to the Booth's algorithm as it performs the essential arithmetic operations required for multiplication: addition and subtraction. It is designed to handle subtraction by adding the two's complement of a number, effectively transforming subtraction into addition. This capability allows the Booth's algorithm to conditionally adjust the register values based on the state machine's instructions, supporting both positive and negative arithmetic .

The conditional case statement in Booth's algorithm optimizes multiplication by allowing dynamic control over arithmetic operations. It evaluates the current states of Q[0] and Q_1, dictating whether to perform a sum, a difference, or simply shift operations. By efficiently choosing the optimal path each cycle based on these bit conditions, the algorithm avoids unnecessary calculations, streamlining the multiplication process .

The test bench ensures the Booth module's multiplication operations proceed correctly by sequentially applying test cases and waiting for the 'busy' signal to indicate completion of each operation. The busy signal is part of a condition monitored for completing multipliers' processing stages. It enables the test bench to synchronize the progression of scenarios, ensuring no new operations begin until the current one is finished .

The Booth's algorithm state machine plays a crucial role in controlling the step-by-step multiplication process. At each clock cycle, it checks the current values of Q[0] and Q_1 to determine the next operation: adding, subtracting, or shifting. The sums are generated through an ALU module capable of both addition and subtraction by incorporating a two's complement approach. The algorithm interprets these sums to update the registers A, Q, and Q_1 accordingly, moving towards the final product .

You might also like