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 convert binary fraction to integer value in VHDL?

Status
Not open for further replies.

seffin

Newbie level 4
Joined
Oct 19, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Indonesia
Activity points
1,318
Dear friends..

I have problem with fixed point in VHDL, How to display binary fraction into LCD in decimal value?
example:
1001.10002 = 9.5 decimal

10012 = 9 and .10002 = .5 but 10002 in decimal value is = 8.

if I make an encoder for this fraction value it must require very many resource in my FPGA.
I use Spartan 3E board.

please help me..

Regards

Seffin
 

Can you subtract a value of 3 (8-3) from the fractional values and display
 

But if the value is 1001.11002 the decimal value is 9.7510
the value that result from subtraction is not true..
any body have an idea? :-(
 

with only 4 fractional bits, there are only 16 possible states, so it is only a 16-1 decoder, which is pretty straight forward.
 
  • Like
Reactions: seffin

    seffin

    Points: 2
    Helpful Answer Positive Rating
The weight of the lowest fractional bit is 1/16 or 0.0625, so you would need four display digits to represent it exactly. If this is what you want, you can multiply with 625 and convert to decimal. Or just use a look-up table of intended representations with your selected width, as TrickyDicky suggested.
 
  • Like
Reactions: seffin

    seffin

    Points: 2
    Helpful Answer Positive Rating
Thank you very much FvM and TrickyDicky for your reply... :) It's very helpful!
If I use 8 bit fraction bit, the lowest fraction bit is 1/256 or 0.00390625, but it have too many digit (8 decimal digit fraction), so how to make it only 2 digit or 4 digit without reduce fraction bit?
 

you now have a problem of displaying it, not with your actual data.
you will have to decide how many decimal bits are acceptable and a Look up table should suit this problem.
 
  • Like
Reactions: seffin

    seffin

    Points: 2
    Helpful Answer Positive Rating
TrickyDicky, What you mean with acceptable decimal bits?
I just want to diplay like this:
99.99
if I add with 1 it will display 100.00 decimal.. but I use 8 binary fraction bits..
please help me..
 

use a look up table for the fractional part. You dont need to do any adding at all.
 
  • Like
Reactions: seffin

    seffin

    Points: 2
    Helpful Answer Positive Rating
Ok, Thank you for all :) I'll try it.. if I have succeeded I'll let you know.. :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top