RE: math functions in 1364

From: Steven Sharp <sharp@cadence.com>
Date: Wed Dec 01 2004 - 17:36:01 PST

>Using $<math func> seems like a bad idea to me, regular Verilog usually
>treats those kind of things as user-supplied or user-replaceable.

These particular functions are built-in, not user-supplied. The user
can indeed replace them with user-supplied versions, but that doesn't
mean that a tool doesn't know this has been done. It need not allow a
user-supplied replacement in all of the situations where the built-in
ones are allowed. For example, these particular built-in functions are
allowed to be used in constant expressions (i.e. expressions that must be
elaboration-time constants), while a user-supplied replacement is not.
In a similar way, these built-in functions could be allowed in analog
contexts without allowing a user-supplied replacement there, if that
causes problems.

> You'd
>be as well off using the SV DPI interface and just calling the C math
>functions directly - you can skip the '$' then.

This is a good point, but there are some flaws in it. As noted above,
a tool can know whether a built-in system function has been replaced with
a user-supplied function, and disallow it if necessary. Since all SV DPI
functions are effectively user-supplied, this may not be possible there.
It may be that if the C math library is statically linked into the tool,
and it can be sure that the imported DPI function is using those math
functions, then this is possible.

As noted above, these particular built-in Verilog system functions can be
used in constant expressions. As far as I know, SV DPI functions cannot.
It was my understanding that it was necessary to be able to use these math
functions in constant expressions.

And DPI is only available in SystemVerilog at present, not in Verilog.
However, it must be admitted that certain other SystemVerilog features
would make the system task approach work better too. Being able to
put the Verilog functions without the '$' into a package or $unit would
make them much more convenient to use.

Steven Sharp
sharp@cadence.com
Received on Wed Dec 1 17:36:18 2004

This archive was generated by hypermail 2.1.8 : Wed Dec 01 2004 - 17:36:24 PST