PlTbUtils
1.3
PlTbUtils is a collection of functions, procedures and components for easily creating stimuli and checking response in automatic self-checking testbenches.
|
If you are reading this markdown file on github, it has been formatted for doxygen, which might explain some strange symbols.
Displays a message at start of simulation message, and initializes PlTbUtils' status and control variable and -signal. Call startsim only once.
testcase_name
: Name of the test case, e.g. "tc1"
.
skiptests
: std_logic_vector
for marking tests that should be skipped. The leftmost bit has position 0, and position numbers increment to the right. A '1' indicates that the test with the same number as the position should be skipped. Note that there is usually no test which has number 0, so bit zero in the vector is usually ignored. This argument is normally fed by a generic. If no tests should be skipped, a zero-length vector is allowed, (""
).
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
The start-of-simulation message is not only intended to be informative for humans. It is also intended to be searched for by scripts, e.g. for collecting results from a large number of regression tests.
Displays a message at end of simulation message, presents the simulation results, and stops the simulation. Call endsim only once.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
show_success_fail
: If true, endsim
shows *** SUCCESS ***
, *** FAIL ***
, or *** NO CHECKS ***
. Optional, default is false
.
force
: If true
, forces the simulation to stop using an assert failure statement. Use this option only if the normal way of stopping the simulation doesn't work (see below). Optional, default is false
.
The testbench should be designed so that all clocks stop when endsim
sets the signal stop_sim
to '1'. This should stop the simulator.
In some cases, that doesn't work, then set the force argument to true, which causes a false assert failure, which should stop the simulator.
The end-of-simulation messages and success/fail messages are not only intended to be informative for humans. They are also intended to be searched for by scripts, e.g. for collecting results from a large number of regression tests.
starttest sets a number (optional) and a name for a test. The number and name will be printed to the screen, and displayed in the simulator's waveform window.
The test number and name is also included if there errors reported by the check procedure calls.
num
: Test number. Optional, default is to increment the current test number.
name
: Test name.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
If the test number is omitted, a new test number is automatically computed by incrementing the current test number. Manually setting the test number may make it easier to find the test code in the testbench code, though.
is_test_active returns true
if a test is active (not skipped), otherwise false
.
pltbv
: PlTbUtils' status- and control variable.
endtest prints an end-of-test message to the screen.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
Defined in txt_util.vhd:
Defined in pltbutils_func_pkg.vhd:
print without a signal as argument prints text messages to the transcript window.
print with a signal as argument prints text messages to that signal for viewing in the simulator's waveform window.
printv does the same thing, but to a variable instead.
print2 prints both to a signal and to the transcript window.
The type of the output can be string or pltbv
+ pltbs
.
s
: Signal or variable of type string to be printed to.
txt
: The text.
active
: The text is only printed if active is true. Useful for debug switches, etc.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal. The text will be printed to "info" in the waveform window.
If the string txt
is longer than the signal s
, the text will be truncated. If txt
is shorter, s
will be padded with spaces.
waitclks waits specified amount of clock cycles of the specified clock. Or, to be more precise, a specified number of specified clock edges of the specified clock.
n Number of rising or falling clock edges to wait.
clk
: The clock to wait for.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
falling
: If true, waits for falling edges, otherwise rising edges. Optional, default is false.
timeout
: Timeout time, in case the clock is not working. Optional, default is C_PLTBUTILS_TIMEOUT
.
waitsig waits until a signal has reached a specified value after specified clock edge.
s
: The signal to test. Supported types: integer, std_logic, std_logic_vector, unsigned, signed.
value
: Value to wait for. Same type as data or integer.
clk
: The clock.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
falling
: If true, waits for falling edges, otherwise rising edges. Optional, default is false.
timeout
: Timeout time, in case the clock is not working. Optional, default is C_PLTBUTILS_TIMEOUT.
check checks that the value of a signal or variable is equal to expected. If not equal, displays an error message and increments the error counter.
rpt
: Report message to be displayed in case of mismatch. It is recommended that the message is unique and that it contains the name of the signal or variable being checked. The message should NOT contain the expected value, because check() prints that automatically.
data
: The signal or variable to be checked. Supported types: integer, std_logic, std_logic_vector, unsigned, signed.
expected
: Expected value. Same type as data, or integer.
mask
: Bit mask and:ed to data and expected before comparison. Optional if data is std_logic_vector. Not allowed for other types.
tolerance
: Allowed tolerance. Checks that expected - tolerance ≤ actual ≤ expected + tolerance is true.
expr
: boolean expression for checking. This makes it possible to check any kind of expresion, not just equality.
pltbv, pltbs
: PlTbUtils' status- and control variable and -signal.
to_ascending converts a vector to ascending range ("to-range"). The argument s can have ascending or descending range. E.g. an argument defined as a std_logic_vector(3 downto 1)
will be returned as a std_logic_vector(1 to 3)
.
s
: Constant, signal or variable to convert
Return value: Converted value
to_descending converts a vector to descending range ("downto-range"). The argument s can have ascending or descending range. E.g. an argument defined as a std_logic_vector(1 to 3)
will be returned as a std_logic_vector(3 downto 1)
.
s
: Constant, signal or variable to convert
Return value: Converted value
hxstr converts a vector to a string in hexadecimal format. An optional prefix can be specified, e.g. "0x", as well as a suffix.
The input argument can have ascending range ( "to-range" ) or descending range ("downto-range"). There is no vector length limitation.
s
: Constant, signal or variable to convert
Return value: Converted value
Creates a clock signal for use in a testbench. The clock stops when input port stop_sim goes '1'. This makes the simulator stop (unless there are other infinite processes running in the simulation).
Generic | Width | Type | Description |
---|---|---|---|
G_PERIOD | 1 | time | Clock period. |
G_INITVALUE | 1 | std_logic | Initial value of the non-inverted clock output. |
Port | Width | Direction | Description |
---|---|---|---|
clk_o | 1 | Output | Non-inverted clock output. Use this output for single ended or differential clocks. |
clk_n_o | 1 | Output | Inverted clock output. Use if a differential clock is needed, leave open if single-ended clock is needed. |
stop_sim_i | 1 | Input | When '1', stops the clock. This will normally stop the simulation. |