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.

[SOLVED] fractional representation in verilog

Status
Not open for further replies.

dipin

Full Member level 4
Joined
Jul 16, 2014
Messages
223
Helped
14
Reputation
28
Reaction score
14
Trophy points
18
Activity points
1,731
hi all,
how can i represent a fractional number in verilog code.i need to store it into a memoryand do some(like addition,sub) operation.
if i do so can i apply it in to a fpga .is it synthesizable ?????
plzz help im confused.

with regards
dipin
 

Use a fractional number representation, like floating point format, to store your number. It will be like a normal binary number but with some bits representing the exponent and some representing the fractional part. Just search online for different ways of fractional number representation.

To process these numbers, you will just have to interpret each bit appropriately.

Hope this helps!
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
Use a fractional number representation, like floating point format, to store your number. It will be like a normal binary number but with some bits representing the exponent and some representing the fractional part. Just search online for different ways of fractional number representation.

To process these numbers, you will just have to interpret each bit appropriately.

Hope this helps!

What? Doesnt make sense.

Fractional numbers are just normal numbers offset by 2^n, so they can be treated as integers.
 

Fixed point arithmetic is synthesizable. As Tricky mention scale everytyhing by some 2^N value, then code your arithmetic as if you were using integers or 2's comp values, depending on if you need unsigned or signed.

Regards
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
Moderately pedantic point: strictly speaking fractional representation is precisely that, fractional. So you have two integer numbers P (numerator) and Q (denominator) and they represent your fractional number P/Q. Rational number and all that. When Q is a power of two that's just a special case. And to make it even more boring and predictable (== useful from an engineering point of view) this power of two is usually fixed. And it's this Q = 2^N that is the scaling factor as mentioned by the previous posters.

And as you may note, all the above doesn't have anything to do with floating point.
 
Last edited:
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
thanks guys ,,,its solved
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top