0

I come from VHDL back ground. And in VHDL, there is IEEE packages for doing fixed and floating point operations. They are not synthesisable sometimes, but are pretty helpful when comes to testing.

My question is, whether Verilog has a library for doing fixed and floating point operations? It doesnt matter if its not synthesisable.

vipin
  • 1,438
  • 3
  • 14
  • 23
  • You can always try to google it and find e.g. [this](http://www.eda.org/fphdl/old_index.html). But aren't real numbers good enough? – Qiu Oct 26 '15 at 19:15
  • Not that I am aware of, See [Previous answer on handling fixed-point](http://stackoverflow.com/a/28383767/97073). [also this](http://stackoverflow.com/a/27765266/97073) and [this](http://stackoverflow.com/a/28170918/97073). – Morgan Oct 26 '15 at 20:28
  • I can use real numbers. But in vhdl, I normally use the fixed_pkg in testbench. to convert real values to and from fixed poiht values. But i guess in Verilog I have to write real to fixed functions on my own. – vipin Oct 27 '15 at 10:00

1 Answers1

1

Real operations are built into Verilog. See section 20.8.2 Real math functions in the IEEE 1800-2012 LRM. You can also use the DPI to import many other math function from a standard C library. See https://www.doulos.com/knowhow/sysverilog/tutorial/dpi/

For fixed point, you will need to shift you values manually.

AndresM
  • 1,189
  • 8
  • 16
dave_59
  • 30,490
  • 3
  • 22
  • 48