I am new to cocotb and I want to test my DUT.
I have one clock that input to the dut which i generate correctly, however, I want a clock to use it only in the test not connected to the DUT, I want this clock to be long and with each rising edge a do a test but O am suffering since yesterday to do such a clock
I have the following code
import cocotb
from cocotb.runner import get_runner
from cocotb.triggers import Timer, FallingEdge, RisingEdge
from cocotb.clock import Clock
async def generate_clock(sim_clk, period):
"""Generate clock test."""
while True:
sim_clk <= 0
await Timer(period // 2, units="ms")
sim_clk <= 1
await Timer(period // 2, units="ms")
@cocotb.test()
async def top(dut):
sim_clk = Clock('sim_clk', period=22)
cocotb.start_soon(generate_clock(sim_clk, 22))
.
.
.
.
.
.
.
## this line is alwys error I tried everything but it gives error
await RisingEdge(dut.sim_clk)
How can make such clock I can use its rising edge but not eonnected to the dut
The main problem was cocotb prefer working with dut.clk and in case we want to make a clk only for the tesbench this will raise an issue for cocotb, I overcome this issue by adding a clock to the dut which only for the test and it passed. I searched a lot and using a delay for clock in cocotb is not a practical use.
I belive this is the best use of the clock in cocotb
enter image description here