You are required to implement and test a multiplier unit that can perform signed
ID: 3908797 • Letter: Y
Question
You are required to implement and test a multiplier unit that can perform signed multiplication on two 4-bit binary numbers. The unit has two 4-bit inputs, multiplicand and multiplier, input clock, 1-bit output called valid and one 8-bit output called the product. The valid bit is set to indicate that the result on the product output is valid. In the implementation of the multiplier, you should choose the following Optimized multiplier circuit after making any necessary changes Multiplicand 4 bits 4-bit ALU Shift right Control Product Writetest 8 bits Figure 1. The optimized multiplierExplanation / Answer
module multiply(ready,plsb,prsb,product,multiplier,multiplicand,sign,clk);
input clk;
input sign;
input [3:0] multiplier, multiplicand;
output [7:0] product;
output [3:0] plsb,prsb;
output ready;
reg [7:0] product, product_temp;
reg [3:0] multiplier_copy;
reg [7:0] multiplicand_copy;
reg negative_output;
reg [2:0] bit;
wire ready = !bit;
reg [3:0] plsb,prsb;
initial bit = 0;
initial negative_output = 0;
always @( posedge clk )
if( ready )
begin
bit = 3'b100;
product = 0;
product_temp = 0;
multiplicand_copy = (!sign || !multiplicand[3]) ? { 4'd0, multiplicand } : { 4'd0, ~multiplicand + 1'b1};
multiplier_copy = (!sign || !multiplier[3]) ? multiplier : ~multiplier + 1'b1;
negative_output = sign && ((multiplier[3] && !multiplicand[3]) ||(!multiplier[3] && multiplicand[3]));
end
else if ( bit > 0 )
begin
if( multiplier_copy[0] == 1'b1 )
product_temp = product_temp + multiplicand_copy;
product = (!negative_output)?product_temp:(~product_temp + 1'b1);
multiplier_copy = multiplier_copy >> 1;
multiplicand_copy = multiplicand_copy << 1;
bit = bit - 1'b1;
plsb = product[3:0];
prsb = product[7:4];
end
endmodule
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.