Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20688 Discussions

Special function calculation

Altera_Forum
Honored Contributor II
2,470 Views

sir, I'm using Verilog to program and Modelsim to simulate but i don't know how to use special function to calculate log, exponent, sin...Do i need add library ?

0 Kudos
7 Replies
Altera_Forum
Honored Contributor II
650 Views

nobody answer for me. Sad

0 Kudos
Altera_Forum
Honored Contributor II
650 Views

You didn't tell, if you need the mathematical functions only in the testbench or to be synthesizable?

0 Kudos
Altera_Forum
Honored Contributor II
650 Views

 

--- Quote Start ---  

You didn't tell, if you need the mathematical functions only in the testbench or to be synthesizable? 

--- Quote End ---  

 

 

I need the mathematical functions in testbench only. Thank
0 Kudos
Altera_Forum
Honored Contributor II
650 Views

You should review the real math functions provided by verilog 

 

 

--- Quote Start ---  

Table 17-18—Verilog to C real math function cross-listing 

Verilog function Equivalent C function Description 

$ln(x) log(x) Natural logarithm 

$log10(x) log10(x) Decimal logarithm 

$exp(x) exp(x) Exponential 

$sqrt(x) sqrt(x) Square root 

$pow(x,y) pow(x,y) x**y 

$floor(x) floor(x) Floor 

$ceil(x) ceil(x) Ceiling 

$sin(x) sin(x) Sine 

$cos(x) cos(x) Cosine 

$tan(x) tan(x) Tangent 

$asin(x) asin(x) Arc-sine 

$acos(x) acos(x) Arc-cosine 

$atan(x) atan(x) Arc-tangent 

$atan2(x,y) atan2(x,y) Arc-tangent of x/y 

$hypot(x,y) hypot(x,y) sqrt(x*x+y*y) 

$sinh(x) sinh(x) Hyperbolic sine 

$cosh(x) cosh(x) Hyperbolic cosine 

$tanh(x) tanh(x) Hyperbolic tangent 

$asinh(x) asinh(x) Arc-hyperbolic sine 

$acosh(x) acosh(x) Arc-hyperbolic cosine 

$atanh(x) atanh(x) Arc-hyperbolic tangent 

--- Quote End ---  

0 Kudos
Altera_Forum
Honored Contributor II
650 Views

thank FvM very much. That's i need

0 Kudos
Altera_Forum
Honored Contributor II
650 Views

Do I need to add any extra Verilog/VHDL codes (library or anything) in the simulation before I could call these special functions?

0 Kudos
Altera_Forum
Honored Contributor II
650 Views

They are available in HDL, but they cannot be used in an fpga.

0 Kudos
Reply