# error in modelsim simulation

Discussion in 'VHDL' started by viswanath, Apr 22, 2004.

1. ### viswanathGuest

Hi,
I was trying to implement digital sine modulation in vhdl and for the
same I was multiplying a sine value( which I assumed to be a real
number). For reasons unknown to me though it appears to be an ok
waveform I get error messages stating the following:
Error: XLOCAL <= 0.0 after reduction in SIN(X)
# Time: 479952500 ps Iteration: 0 Instance: /sigtst/s1
At this instant of time the value of sine is of the order 1e -14,
1e-15, 1e-13.
The code at which I think is the problem is :
sin_theta := sin(math_2_pi*real(now/1 ps)/real(period/ 1 ps));
What could that problem be? and how can one fix that?
I need this because for a further multiplication with another real
number I am getting a FATAL error message and the simulation stops. It
says the real number range has exceeded though I am multiplying two
real numbers which are within that range one the above number and
another number which is also a sine value. Though this cannot exceed
the range I get that message.
I would greatly appreciate any help and suggestions.
Thanking You in Anticipation,
Yours Truly,
Viswanath Daita

viswanath, Apr 22, 2004

2. ### Jonathan BromleyGuest

On 21 Apr 2004 21:25:40 -0700, (viswanath) wrote:

>Hi,
>I was trying to implement digital sine modulation in vhdl and for the
>same I was multiplying a sine value( which I assumed to be a real
>number). For reasons unknown to me though it appears to be an ok
>waveform I get error messages stating the following:
>Error: XLOCAL <= 0.0 after reduction in SIN(X)
># Time: 479952500 ps Iteration: 0 Instance: /sigtst/s1
>At this instant of time the value of sine is of the order 1e -14,
>1e-15, 1e-13.
>The code at which I think is the problem is :
>sin_theta := sin(math_2_pi*real(now/1 ps)/real(period/ 1 ps));
>What could that problem be? and how can one fix that?

I think the problem is internal to the SIN() function. You are
asking it to calculate the sine of a very large angle, far larger
than one rotation. To perform this calculation, the SIN()
function needs to reduce the angle so that it is within some
range (probably 0 to pi/2, though I'm not sure exactly how
the SIN() function works internally). My guess is that
there is some limitation to the way this has been implemented,
and you have discovered a corner-case bug.

If my guess is right, the obvious solution is to do the
reduction yourself:

sin_theta := sin(math_2_pi * real( (now/1 ps) mod (period/1 ps) ));

The IEEE standard specifies that accuracy may be degraded for
very large input angles, but doesn't permit failure like this.
Consequently it would be a good idea to capture the input value
(479952500/period) and report it to .
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

Jonathan Bromley, Apr 22, 2004

3. ### viswanathGuest

Hi Jonathan,
Thanks for the reply.Though it sounds exciting that I have discovered
a bug in modelsim I need a way to get around this problem.
I didnot explain to you what I did previously. I am trying to model a
continuous sine wave and the expression I have in the previous mail is
what I am using to calculate the modulation.((const)* sin(wt) )
How could one implement the same instead of using the kind of
expression that I used. where the omega frequency is in the order of
Mhz.
Can you please let me know?
Thanking You,
Viswanath(aka Vishy)

Jonathan Bromley <> wrote in message news:<>...
> On 21 Apr 2004 21:25:40 -0700, (viswanath) wrote:
>
> >Hi,
> >I was trying to implement digital sine modulation in vhdl and for the
> >same I was multiplying a sine value( which I assumed to be a real
> >number). For reasons unknown to me though it appears to be an ok
> >waveform I get error messages stating the following:
> >Error: XLOCAL <= 0.0 after reduction in SIN(X)
> ># Time: 479952500 ps Iteration: 0 Instance: /sigtst/s1
> >At this instant of time the value of sine is of the order 1e -14,
> >1e-15, 1e-13.
> >The code at which I think is the problem is :
> >sin_theta := sin(math_2_pi*real(now/1 ps)/real(period/ 1 ps));
> >What could that problem be? and how can one fix that?

>
> I think the problem is internal to the SIN() function. You are
> asking it to calculate the sine of a very large angle, far larger
> than one rotation. To perform this calculation, the SIN()
> function needs to reduce the angle so that it is within some
> range (probably 0 to pi/2, though I'm not sure exactly how
> the SIN() function works internally). My guess is that
> there is some limitation to the way this has been implemented,
> and you have discovered a corner-case bug.
>
> If my guess is right, the obvious solution is to do the
> reduction yourself:
>
> sin_theta := sin(math_2_pi * real( (now/1 ps) mod (period/1 ps) ));
>
> The IEEE standard specifies that accuracy may be degraded for
> very large input angles, but doesn't permit failure like this.
> Consequently it would be a good idea to capture the input value
> (479952500/period) and report it to .
> --
> Jonathan Bromley, Consultant
>
> DOULOS - Developing Design Know-how
> VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
>
> Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
> Tel: +44 (0)1425 471223 mail:
> Fax: +44 (0)1425 471573 Web: http://www.doulos.com
>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.

viswanath, Apr 22, 2004
4. ### Jonathan BromleyGuest

On 22 Apr 2004 11:24:35 -0700, (viswanath) wrote:

>Hi Jonathan,
>Thanks for the reply.Though it sounds exciting that I have discovered
>a bug in modelsim I need a way to get around this problem.

Read my post again. I gave you a solution.

>I didnot explain to you what I did previously. I am trying to model a
>continuous sine wave and the expression I have in the previous mail is
>what I am using to calculate the modulation.((const)* sin(wt) )

Yup. Your problem, of course, is that (omega.t) grows without
(theoretical) limit as the simulation runs. I suggested one of
many possible ways to work around that.

>How could one implement the same instead of using the kind of
>expression that I used.

Just in case you missed it last time:

sin_theta := sin(math_2_pi * real( (now/1 ps) mod (period/1 ps) ));
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.

Jonathan Bromley, Apr 23, 2004
5. ### viswanathGuest

Hi Jonathan,
Viswanath

Jonathan Bromley <> wrote in message news:<>...
> On 22 Apr 2004 11:24:35 -0700, (viswanath) wrote:
>
> >Hi Jonathan,
> >Thanks for the reply.Though it sounds exciting that I have discovered
> >a bug in modelsim I need a way to get around this problem.

>
> Read my post again. I gave you a solution.
>
> >I didnot explain to you what I did previously. I am trying to model a
> >continuous sine wave and the expression I have in the previous mail is
> >what I am using to calculate the modulation.((const)* sin(wt) )

>
> Yup. Your problem, of course, is that (omega.t) grows without
> (theoretical) limit as the simulation runs. I suggested one of
> many possible ways to work around that.
>
> >How could one implement the same instead of using the kind of
> >expression that I used.

>
> Just in case you missed it last time:
>
> sin_theta := sin(math_2_pi * real( (now/1 ps) mod (period/1 ps) ));
> --
> Jonathan Bromley, Consultant
>
> DOULOS - Developing Design Know-how
> VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services
>
> Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
> Tel: +44 (0)1425 471223 mail:
> Fax: +44 (0)1425 471573 Web: http://www.doulos.com
>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.

viswanath, Apr 25, 2004