what's bad in this declaratio of time constant?

J

Jim Lewis

In your example, sec is associated with
9600, so you actually wrote 1/time which
will not work.

Try this:
constant BIT_TIME: time := (1/9600) * 1 sec;

You may not need the parentheses, but it is more
readable with them.

Cheers,
jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
J

Jonathan Bromley

YES! SUCCESS! I caught Jim Lewis out!!!
Try this:
constant BIT_TIME: time := (1/9600) * 1 sec;

Bad plan. 1/9600 is evaluated as an integer, yielding
the value 0.

How about
constant BIT_TIME: time := 1 sec / 9600;

This will work because 1 sec == 10^15 fs, and arithmetic
on physical units is always scaled to the base unit,
which is fs in the case of time.

That comes close to paying you back for catching me
out with a cunning type conversion at your tutorial
in Lyon :)
--
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, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail: (e-mail address removed)
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.
 
J

Jim Lewis

How about
constant BIT_TIME: time := 1 sec / 9600;

Good point. :)
Serves me right for typing without thinking.

That comes close to paying you back for catching me
out with a cunning type conversion at your tutorial
in Lyon :)

You have a long memory. I will have to remember not
to what I did at FDL again - if only I could remember
what it was. :)

Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top