我已经开始熟悉 cocotb,但遇到了麻烦。
我写了一个像这样的简单测试:
@cocotb.test()
async def add_test(dut):
dut._log.info("Running add test!")
c = Clock(dut.clk, 10, 'ns')
await cocotb.start(c.start())
a = 1
b = 2
for cycle in range(10):
a += 1
b += 1
await RisingEdge(dut.clk)
dut.exu2ialu_main_op1_i <= a
dut.exu2ialu_main_op2_i <= b
dut.exu2ialu_cmd_i <= 4
await RisingEdge(dut.clk)
assert dut.ialu2exu_main_res_o == (a+b)
并拼凑了一个简单的 makefile:
VERILOG_INCLUDE_DIRS = $(PWD)/include
VERILOG_SOURCES = $(PWD)/myalu.sv
TOPLEVEL=scr1_pipe_ialu # the module name in your Verilog or VHDL file
MODULE=test # the name of the Python test file
include $(shell cocotb-config --makefiles)/Makefile.sim
first问题是
make SIM=verilator
第一次运行崩溃,通过日志判断是由于大量警告所致(11)。在后续运行中,一切都很好,我将此归因于 sim_build 正在构建,但我想了解是否可以避免崩溃。
第二个问题是,建议我使用 verilator_coverage 实用程序分析测试覆盖率,该实用程序应该接受 .dat 文件,但未生成该文件。我尝试使用命令 make SIM=verilator COVERAGE=1
修复此问题,但这不起作用。
# Extra args for verilator
EXTRA_ARGS += --coverage --coverage-line --coverage-toggle
一般来说,可以在那里添加 verilator 命令行参数。