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.

How to multiply a fixed-point number by a signed integer number in Verilog

Status
Not open for further replies.

mohamis288

Full Member level 3
Joined
Mar 1, 2022
Messages
164
Helped
0
Reputation
0
Reaction score
1
Trophy points
18
Activity points
1,235
I want to multiply an 8-bit fixed-point number by an 8-bit signed integer number in Verilog and we want to have just 8 bits in output. So we want to round our output so that after multiplication, our output must be a signed integer. Unless it will overflow. How can I do that?

Wire [7:0] b0 = 8b'0_0100100;
Input [7:0] input = 8b'10100100;
Assign mul= b0*input;

Is it correct?
 

1) Unless you have some severe constraints, you’re going to have a lot of opportunity for overflow.
2) What’s your fixed point format, 4.4? 6.2?
3) You’ll probably need to do rounding, unless you can live with the truncation error.
4) Im not a verilog person, so I can’t speak to that, but I don’t think your simplistic “b0*input” will work. I think you need to convert both numbers to the same type.
 

Your variables are actually unsigned, signed has to be declared explicitly. Whe multiplying unsigned with signed, the unsigned variable is treated as signed, thus you need to extend 8 bit unsigned coefficient to 9 bit signed.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top