Functions
Timing Functions

Overview

Timing Functions are used in order to calculate the number of clock cycles that would occur in a giving time interval. SpeakHDL offers the timing functions us(), ms(), and s() that calculate microseconds, milliseconds, and seconds time lapsed and return an integer value. Inputs to timing functions can either be integer or real values. For example, us(45.2) would return the number of clock cycles that would occur in 45.2 microseconds. When there is only one clock domain present, timing functions only require one parameter. Thus, the number of clock cycles is calculated based the sys_clk_freq which is set in the configuration file.

When there are multiple clock domains, the number of clock cycles is based on the rs_clk (resource clock) frequency which is given as the first parameter of the RESOURCE_SELECT procedure call. In is case, the timing function must be called with (2) parameters. The second parameter is the rs_clk frequency in Hz. For example if the second clock domain had resource clock of 120MHz, the timing function above would use the signature of us(45.2, 120e6). Typically timing functions are used as the divide_count parameter in either the TIME_COUNTER procedure call or the TRANSITION procedure call when creating transitions for state machines.

Default Time Units for Floating Point Commands

When creating timing patterns, often times a waveform is assumed to have some default time units of either us, ms, or s. SpeakHDL allows the developer to define the default_time_units that each real valued command will reference. Meaning, if a user were to type any numerical value with a decimal point within a command expecting an integer value, then SpeakHDL will automatically use the timing function defined as default time unit. For example, typing the value 3.5 within an expecting command would result in the timing function ms(3.5) if the default_time_units was set to ms.

See also
RESOURCE_SELECT
TRANSITION
TIME_COUNTER

Notes and Warnings

Note
1) Timing Functions are overloaded for inputs of integer data type and real data types and return constant integer values which are resolvable at compile time which makes the functions synthesizable.
2) If the timing function input results in time duration that does not result in an exact number of clock cycles, the timing function return value is rounded to the nearest clock cycle.

Functions

integer   us ( value: in integer , DOMAIN_FREQ: in positive SYS_CLK )
integer   ms ( value: in integer , DOMAIN_FREQ: in positive SYS_CLK )
integer   s ( value: in integer , DOMAIN_FREQ: in positive SYS_CLK )
integer   sec ( value: in integer , DOMAIN_FREQ: in positive SYS_CLK )
integer   us ( value: in real , DOMAIN_FREQ: in positive SYS_CLK )
integer   ms ( value: in real , DOMAIN_FREQ: in positive SYS_CLK )
integer   s ( value: in real , DOMAIN_FREQ: in positive SYS_CLK )
integer   sec ( value: in real , DOMAIN_FREQ: in positive SYS_CLK )