Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Fixed_Point_Unit.v
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,23 @@ module Multiplier

output reg [15 : 0] product
);
reg [15:0] accumulator;
reg [8:0] Multiplier;
integer i;

always @(*)
accumulator = 16'b0;
Multiplier = {operand_2, 1'b0};
begin
product <= operand_1 * operand_2;
for (i = 0; i < 8 ; i++) begin
if (Multiplier[1:0] == 2'b01) begin
accumulator = accumulator + (operand_1 << i);
end
if (Multiplier[1:0] == 2'b10) begin
accumulator = accumulator - (operand_1 << i);
end
Multiplier = Multiplier >> 1;
end
product = accumulator;
end
endmodule