Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
21615 Discussions

Floating point conversion [Verilog]

Altera_Forum
Honored Contributor II
2,077 Views

Hello, 

I am trying to find a way to convert numbers into floating point.  

 

For example: 

 

Let Y=-A/B; 

And A and B are integers, but B>> A. Therefore the range of Y is [0 1]. 

 

I already tried using $itor and $realtobits. But my output is still 0. 

 

I am using modelsim 10.0 btw. 

 

 

Thanks in advance.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
1,384 Views

If it's a pure simulation problem, it's very easy. As in most programming languages, you have to convert the type of at least A or B before the division. 

 

If the code is intended for synthesis, you hav eto decide about a suitable number format first, e.g. single precision float and use respective Megafunctions.
0 Kudos
Reply