Verilog Code
module BoothMulti(X, Y, Z);
input signed [3:0] X, Y;
output signed [7:0] Z;
reg signed [7:0] Z;
reg [1:0] temp;
integer i;
reg E1;
reg [3:0] Y1;
always @ (X, Y)
begin
Z = 8'd0;
E1 = 1'd0;
for (i = 0; i < 4; i = i + 1)
begin
temp = {X[i], E1};
Y1 = - Y;
case (temp)
2'd2 : Z [7 : 4] = Z [7 : 4] + Y1;
2'd1 : Z [7 : 4] = Z [7 : 4] + Y;
default : begin end
endcase
Z = Z >> 1;
Z[7] = Z[6];
E1 = X[i];
end
if (Y == 4'd8)
begin
Z = - Z;
end
end
endmodule
Test Bench
module BoothTB;
// Inputs
reg [3:0] X;
reg [3:0] Y;
// Outputs
wire [7:0] Z;
// Instantiate the Unit Under Test (UUT)
BoothMulti uut (
.X(X),
.Y(Y),
.Z(Z)
);
initial begin
// Initialize Inputs
X = 0;
Y = 0;
// Wait 100 ns for global reset to finish
#100;
X=-5;
Y=7;
// Add stimulus here
end
endmodule
Output
Coming Soon
Hey post 8 bit Booth Multiplier also & Sequential Multiplier
By Tomorrow evening, you will get both codes with verified output.✌
https://codesexplorer.blogspot.in/2017/02/8-bit-booth-multiplier-Verilog-Code.html
this doesn’t seem to be able to multiply numbers above 8.
8 is represented by 4 bits da ivane.
This is Booth thing for 3 bits and 1 sign bit.
any binary value more than 1000’b is considered negative