Testbench
forastero.bench.BaseBench
Base class for a Forastero testbench
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dut
|
HierarchyObject
|
Handle to the DUT, provided by cocotb |
required |
clk
|
ModifiableObject | None
|
Handle to the primary clock signal |
None
|
rst
|
ModifiableObject | None
|
Handle to the primary reset signal |
None
|
clk_drive
|
bool
|
Whether the primary clock signal should be driven |
True
|
clk_period
|
float
|
Tick period for the primary clock |
1
|
clk_units
|
str
|
Units of the primary clock's period |
'ns'
|
__getattr__(key)
Pass through accesses to signals on the DUT.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key
|
str
|
Name of the attribute |
required |
Returns:
Type | Description |
---|---|
Any
|
Resolved object |
add_teardown(coro)
Register a coroutine to be executed after the shutdown loops have all completed, can be used to check final conditions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coro
|
Coroutine
|
Coroutine to register |
required |
close_down(loops=2, delay=100)
async
Wait for drivers, monitors, and the scoreboard to drain to ensure that the test has completed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loops
|
int
|
Number of repetitions of the shutdown sequence to run |
2
|
delay
|
int
|
Number of clock cycles to wait between shutdown loops |
100
|
fork_log(*scope)
Create a new descedent of the root simulation log with a given context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*scope
|
str
|
A particular scope as a list of strings |
()
|
get_parameter(name, default=None)
classmethod
Read back a parameter passed in from the outside world.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the parameter to read |
required |
default
|
Any
|
Default value to return if parameter not defined |
None
|
Returns:
Type | Description |
---|---|
Any
|
Value of the parameter or the default |
initialise()
async
Initialise the DUT's I/O
parameter(name, cast)
classmethod
Decorator for defining a parameter of a testcase that can be overridden
from a parameter file identified by the TEST_PARAMS
environment
variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the parameter |
required |
cast
|
Callable[[str], Any]
|
Function to cast a string param to the required type, usually just the type constructor e.g. |
required |
ready()
async
Blocks until reset has completed
register(name, comp_or_coro=None, scoreboard=True, scoreboard_queues=None, scoreboard_filter=None, scoreboard_timeout_ns=None, scoreboard_polling_ns=100, scoreboard_match_window=1)
Register a driver, monitor, or coroutine with the testbench. Drivers and monitors must be provided a name and their random seeding will be setup from the testbench's random instance. Monitors will be registered with the scoreboard unless explicitly requested. Coroutines must also be named and are required to complete before the test will shutdown.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the component or coroutine |
required |
comp_or_coro
|
Component | Coroutine
|
Component instance or coroutine |
None
|
scoreboard
|
bool
|
Only applies to monitors, controls whether it is registered with the scoreboard |
True
|
scoreboard_queues
|
list[str] | None
|
A list of named queues used when a funnel type scoreboard channel is required |
None
|
scoreboard_filter
|
Callable | None
|
A function that can filter or modify items recorded by the monitor before they are passed to the scoreboard |
None
|
scoreboard_timeout_ns
|
int | None
|
Optional timeout to allow for a object sat at the front of the monitor queue to remain unmatched (in nanoseconds, a value of None disables the timeout mechanism) |
None
|
scoreboard_polling_ns
|
int
|
How frequently to poll to check for unmatched items stuck in the monitor queue in nanoseconds (defaults to 100 ns) |
100
|
scoreboard_match_window
|
int
|
Where precise ordering of expected transactions is not known, a positive integer matching window can be used to match any of the next N transactions in the reference queue (where N is set by match_window) |
1
|
reset(init=True, wait_during=20, wait_after=1)
async
Reset the DUT.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
init
|
Initialise the DUT's I/O |
True
|
|
wait_during
|
Clock cycles to hold reset active for (defaults to 20) |
20
|
|
wait_after
|
Clock cycles to wait after lowering reset (defaults to 1) |
1
|
schedule(sequence, blocking=True)
Schedule a sequence to execute as part of a testcase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence
|
tuple[BaseSequence, Callable[[SimLog, Random, SeqArbiter, ModifiableObject, ModifiableObject], None]]
|
The sequence to schedule |
required |
blocking
|
bool
|
Whether the sequence must complete before the test is allowed to finish |
True
|
Returns:
Type | Description |
---|---|
Task
|
The scheduled task |
testcase(*args, reset=True, timeout=10000, shutdown_loops=2, shutdown_delay=100, reset_init=True, reset_wait_during=20, reset_wait_after=1, **kwargs)
classmethod
Custom testcase declaration, wraps test with bench class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reset
|
Whether to reset the design |
True
|
|
timeout
|
Maximum run time for a test (in clock cycles) |
10000
|
|
shutdown_loops
|
Number of loops of the shutdown sequence |
2
|
|
shutdown_delay
|
Delay between loops of the shutdown sequence |
100
|
|
reset_init
|
Initialise the DUT's I/O |
True
|
|
reset_wait_during
|
Clock cycles to hold reset active for (defaults to 20) |
20
|
|
reset_wait_after
|
Clock cycles to wait after lowering reset (defaults to 1) |
1
|