| View previous topic :: View next topic |
| Author |
Message |
tessitd Senior


Joined: Sep 05, 2006 Posts: 286 Location: Colorado
|
Posted: Mon Nov 20, 2006 6:00 pm Post subject: SystemVerilog as a modeling language? |
|
|
To all,
Well someone asked me if I could model some DSP algorithms in SystemVerilog. I said sure we could do that - we are modeling some hardware we don't have that would have performed this function.
So I started looking the LRM and noticed that there is no real MATH library!!! Is this true that I cannot use sin(x) and such? Is my only recourse to use a DPI call to 'C' and link this in?
Thanks in advance,
TomT... |
|
| Back to top |
|
 |
RCIngham Senior


Joined: Feb 19, 2004 Posts: 194 Location: England (UK)
|
Posted: Tue Nov 21, 2006 4:31 am Post subject: |
|
|
As has been pointed out in other threads, SV is a super-set/extension of "vanilla" Verilog. If sine or any other desireable function exists in Verilog, you can use it in SV.
I've modelled DSP algorithms in VHDL, by using the IEEE 'math_real' package, but that may not help you. |
|
| Back to top |
|
 |
shalom Senior


Joined: Jan 06, 2004 Posts: 110 Location: Jerusalem, Israel
|
Posted: Wed Nov 22, 2006 10:55 am Post subject: |
|
|
Verilog-2005 defines the following real math functions as well as the intger ceiling log base2 function $clog2(x):
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 |
|
| Back to top |
|
 |
cabriggs Senior


Joined: Jan 12, 2004 Posts: 96 Location: Massachusetts
|
Posted: Wed Nov 22, 2006 12:02 pm Post subject: Re: SystemVerilog as a modeling language? |
|
|
| tessitd wrote: | Is this true that I cannot use sin(x) and such? Is my only recourse to use a DPI call to 'C' and link this in?
|
True, but at least calling standard C library functions is trivial through the DPI. All you have to do is write the import statement and, in this case, make sure the math library is compiled in (it probably already is).
-cb |
|
| Back to top |
|
 |
alexg Senior

![]()
Joined: Jan 07, 2004 Posts: 586 Location: Ottawa
|
Posted: Thu Nov 23, 2006 10:02 am Post subject: |
|
|
| Quote: | Well someone asked me if I could model some DSP algorithms in SystemVerilog. I said sure we could do that - we are modeling some hardware we don't have that would have performed this function.
So I started looking the LRM and noticed that there is no real MATH library!!! Is this true that I cannot use sin(x) and such? Is my only recourse to use a DPI call to 'C' and link this in? |
If company develops DSP chips, so it probably develops Matlab/Simulink DSP models to test DSP algorithms prior hardware development. Then, it is much easier to use already tested DSP models to verify the hardware. BTW, Matlab/Simulink already has dynamic bidirectional links to Modelsim and Ncverilog.
-Alex |
|
| Back to top |
|
 |
RCIngham Senior


Joined: Feb 19, 2004 Posts: 194 Location: England (UK)
|
Posted: Thu Nov 23, 2006 11:14 am Post subject: |
|
|
| alexg wrote: |
If company develops DSP chips, so it probably develops Matlab/Simulink DSP models to test DSP algorithms prior hardware development. Then, it is much easier to use already tested DSP models to verify the hardware. BTW, Matlab/Simulink already has dynamic bidirectional links to Modelsim and Ncverilog.
-Alex |
But a cycle-accurate model in Matlab/Simulink? If that's what they need? Or perhaps they don't have (can't afford) all the incremental licences. |
|
| Back to top |
|
 |
alexg Senior

![]()
Joined: Jan 07, 2004 Posts: 586 Location: Ottawa
|
Posted: Thu Nov 23, 2006 11:48 am Post subject: |
|
|
| Quote: | | But a cycle-accurate model in Matlab/Simulink? |
I am against writing cycle-accurate models for verification. In many cases, it is more painful and error-prone than writing actual designs.
In my opinion, models (if used) must have untimed transaction interface only. Reusable transactors & monitors which transfer untimed transactions to/from timed ones have to be developed to support untimed models /checkers/scoreboards.
Regards,
-Alex |
|
| Back to top |
|
 |
tessitd Senior


Joined: Sep 05, 2006 Posts: 286 Location: Colorado
|
Posted: Tue Nov 28, 2006 12:40 pm Post subject: |
|
|
Thanks for all that replied. I will look into the Verilog 2005 library, does VCS 2006.06 have support?
Regarding modelling - what I was really after was injecting noise into an algorithm. One class of noise is of course random. But this design also has anti-aliasing which is sensitive to a slow moving sin wave. So we wanted to create this as one of our noise sources.
But I didn't find a math package in SV or in Verilog 2001. I will review what is in Verilog 2005 if VCS supports it. Also using the C math package is very doable. I just found this lack of math package to be an issue.
For RCIngham I am a big fan of the VHDL IEEE math_real package I wish that SV would adopt some of these better features of VHDL!
TomT... |
|
| Back to top |
|
 |
shalom Senior


Joined: Jan 06, 2004 Posts: 110 Location: Jerusalem, Israel
|
Posted: Wed Nov 29, 2006 6:58 am Post subject: |
|
|
The IEEE SV standard 1800-2005 includes Verilog-2005. 1800 is a set of extensions to Verilog-2005.
However, in practice, at the current time, many tools implement older versions of SV.
Even the tools which are implementing the IEEE version of SV have not yet implemented many of the extensions to Verilog-2001 which are defined in the Verilog-2005 standard.
So in principle, SV includes Verilog-2005. In practice, actual implementations do not yet do this. |
|
| Back to top |
|
 |
tessitd Senior


Joined: Sep 05, 2006 Posts: 286 Location: Colorado
|
Posted: Wed Oct 08, 2008 2:38 pm Post subject: |
|
|
| shalom wrote: | Verilog-2005 defines the following real math functions as well as the intger ceiling log base2 function $clog2(x):
|
Really when I look in the Verilog 2001 LRM these don't show up? What am I missing?
TomT... |
|
| Back to top |
|
 |
DavidCastle Senior


Joined: Jul 14, 2008 Posts: 54 Location: S. California
|
Posted: Wed Oct 08, 2008 3:19 pm Post subject: |
|
|
| 4 years |
|
| Back to top |
|
 |
DavidCastle Senior


Joined: Jul 14, 2008 Posts: 54 Location: S. California
|
Posted: Wed Oct 08, 2008 3:36 pm Post subject: |
|
|
Seriously section 17 defines a lot more system tasks and functions in 2005 than 2001.
But, where in the SystemVerilog LRM does it specifically say that Verilog system tasks and functions are supported? |
|
| Back to top |
|
 |
dave_59 Senior


Joined: Jun 22, 2004 Posts: 978 Location: Fremont, CA
|
Posted: Wed Oct 08, 2008 4:54 pm Post subject: |
|
|
| DavidCastle wrote: |
But, where in the SystemVerilog LRM does it specifically say that Verilog system tasks and functions are supported? |
On page 1:
| IEEE Std 1800™-2005 wrote: | Abstract: This standard provides a set of extensions to the IEEE 1364™ Verilog® hardware
description language (HDL) to aid in the creation and verification of abstract architectural level
models. |
The 1800-2009 LRM will incorporate the 1364 LRM.
Dave Rich |
|
| Back to top |
|
 |
DavidCastle Senior


Joined: Jul 14, 2008 Posts: 54 Location: S. California
|
Posted: Wed Oct 08, 2008 5:04 pm Post subject: |
|
|
Greetings Dave,
I saw that statement, but it sounds so nebulous that I didn't think it was really saying what it sounded like. And, it leaves a lot unsaid like, "Which version is an extension of which version?"
Regards,
David |
|
| Back to top |
|
 |
tessitd Senior


Joined: Sep 05, 2006 Posts: 286 Location: Colorado
|
Posted: Wed Oct 08, 2008 5:15 pm Post subject: |
|
|
Ok,
So I am using VCS and I put in my code:
mylog = $sin(.5);
The compiler throws a message like it doesn't understand $sin? What am I missing?
TomT... |
|
| Back to top |
|
 |
|