Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

booth multiplier code

Status
Not open for further replies.
This is the code for 4bit multiplication..... now try 8bit from this... :)


`timescale 1ns / 1ps

module booth_multiplier(
input clk,
input [3:0] in_a,
input [3:0] in_b,
output [7:0] out);
reg [7:0] sig;
reg temp;
integer i;

always@(posedge clk)
begin
sig=0;
temp=0;

for(i=0;i<=3;i=i+1)
begin

case ({in_b,temp})
2'b00:sig = sig;
2'b01:sig[7:4] = sig[7:4] + in_a;
2'b10:sig[7:4] = sig[7:4] -in_a;
2'b11:sig = sig;
default:sig=10'b0;
endcase

temp = in_b;
sig = sig>>1; // right shift
sig[7]=sig[6]; // sign extend
end

end
assign out=sig;
endmodule
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top