There are two simple ways of doing it:
1. Official way : use 'POS attribute
Please remember that the base unit of the TIME type is fs, so
TIME'POS(10 ns)
should return 10_000_000. If you need real type value, you can
use typecasting ( REAL(TIME'POS(10 ns)) ).
2. Very neat shortcut: divide time value by any time unit
Very convenient if you need the resulting integer to represent
number of nanoseconds or picoseconds;
10 ns / 1 ps
gives 10_000
From my experience, this is not the case:
time'pos(10 ns) returns 10 if you set the time unit to 'ns'
(please correct me if I'm wrong).
>
> 2. Very neat shortcut: divide time value by any time unit
> Very convenient if you need the resulting integer to represent
> number of nanoseconds or picoseconds;
> 10 ns / 1 ps
> gives 10_000
The easiest way to get a 'time as integer' in the given time unit is:
10 ns / time'val(1)
which would give 10 if you select 'ns' as time unit or 10_000_000
if you select 'fs' as time unit.
--
Andreas Gieriet
http://www.diagonal.ch/