Clock domains
Stimulus API
Below is a list of ClockDomain
stimulation functions:
ClockDomain stimulus functions |
Description |
---|---|
|
Fork a simulation process to generate the clockdomain stimulus (clock, reset, softReset, clockEnable signals) |
|
Fork a simulation process which will periodically print the simulation speed in kilo-cycles per real time second. |
|
Toggle the clock signal |
|
Clear the clock signal |
|
Set the clock signal |
|
Set the reset signal to its active level |
|
Set the reset signal to its inactive level |
|
Set the clockEnable signal to its active level |
|
Set the clockEnable signal to its active level |
|
Set the softReset signal to its active level |
|
Set the softReset signal to its active level |
Wait API
Below is a list of ClockDomain
utilities that you can use to wait for a given event from the domain:
ClockDomain wait functions |
Description |
---|---|
|
Wait until the |
|
Wait cyclesCount rising edges on the clock; cycleCount defaults to 1 cycle if not otherwise specified. Note, cyclesCount = 0 is legal, and the function is not sensitive to reset/softReset/clockEnable |
|
Same as |
|
Same as |
|
Same as |
|
Same as |
|
Same as |
|
Wait until a clockdomain sampled and the given condition is true |
|
Same as waitSamplingWhere defined above, but will never block more than timeout cycles. Return true if the exit condition came from the timeout |
Warning
All the functionalities of the wait API can only be called from inside of a thread, and not from a callback.
Callback API
Below is a list of ClockDomain
utilities that you can use to wait for a given event from the domain:
ClockDomain callback functions |
Description |
---|---|
|
Execute the callback code only once on the next |
|
Execute the callback code each time the |
|
Execute the callback code each time the |
|
Execute the callback code each time the |
|
Execute the callback code each time the |
|
Execute the callback code each time the |
|
Same as onSampling, but you can stop it (forever) by letting the callback returning false |
Default ClockDomain
You can access the default ClockDomain
of your toplevel as shown below:
// Example of thread forking to generate a reset, and then toggling the clock each 5 time units.
// dut.clockDomain refers to the implicit clock domain created during component instantiation.
fork {
dut.clockDomain.assertReset()
dut.clockDomain.fallingEdge()
sleep(10)
while(true) {
dut.clockDomain.clockToggle()
sleep(5)
}
}
Note that you can also directly fork a standard reset/clock process:
dut.clockDomain.forkStimulus(period = 10)
An example of how to wait for a rising edge on the clock:
dut.clockDomain.waitRisingEdge()
New ClockDomain
If your toplevel defines some clock and reset inputs which aren’t directly integrated into their ClockDomain
, you can define their corresponding ClockDomain
directly in the testbench:
// In the testbench
ClockDomain(dut.io.coreClk, dut.io.coreReset).forkStimulus(10)