Skip to content

Commit

Permalink
Allow limiting cocotb tests clock frequency via a plusarg, add Makefi…
Browse files Browse the repository at this point in the history
…le targets for testing configs with input FFs enabled

Internal-tag: [#71812]
Signed-off-by: Maciej Kurc <[email protected]>
  • Loading branch information
mkurc-ant committed Jan 27, 2025
1 parent 6ad2067 commit e54b026
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,18 @@ tests-axi: ## Run all verification/cocotb/* RTL tests for AXI bus configuration
$(MAKE) config CFG_NAME=axi
cd $(COCOTB_VERIF_DIR) && $(PYTHON) -m nox -R -t "axi" --no-venv --forcecolor

tests-axi-ff: ## Run all verification/cocotb/* RTL tests for AXI bus configuration without coverage (input FF enabled)
$(MAKE) config CFG_NAME=axi_ff
cd $(COCOTB_VERIF_DIR) && $(PYTHON) -m nox -R -t "axi" --no-venv --forcecolor -- +MinSystemClockFrequency=200.0

tests-ahb: ## Run all verification/cocotb/* RTL tests for AHB bus configuration without coverage
$(MAKE) config CFG_NAME=ahb
cd $(COCOTB_VERIF_DIR) && $(PYTHON) -m nox -R -t "ahb" --no-venv --forcecolor

tests-ahb-ff: ## Run all verification/cocotb/* RTL tests for AHB bus configuration without coverage (input FF enabled)
$(MAKE) config CFG_NAME=ahb_ff
cd $(COCOTB_VERIF_DIR) && $(PYTHON) -m nox -R -t "ahb" --no-venv --forcecolor -- +MinSystemClockFrequency=200.0

tests: tests-axi tests-ahb ## Run all verification/cocotb/* RTL tests fro AHB and AXI bus configurations without coverage

# TODO: Enable full coverage flow
Expand Down
18 changes: 9 additions & 9 deletions verification/cocotb/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def _verify(session, test_group, test_type, test_name, coverage=None, simulator=
# session.install("-r", pip_requirements_path)
test = VerificationTest(test_group, test_type, test_name, coverage)

# Translate session options to plusargs
plusargs = list(session.posargs)

# Randomize seed for initialization of undefined signals in the simulation
random.seed(time.time_ns())
seed = random.randint(1, 10000)
Expand All @@ -40,21 +43,18 @@ def _verify(session, test_group, test_type, test_name, coverage=None, simulator=
"COCOTB_RESULTS_FILE=" + test.filenames["xml"],
]
if simulator == "verilator":
args.append(
"PLUSARGS="
+ " ".join(
[
"+verilator+rand+reset+2",
f"+verilator+seed+{seed}",
]
)
)
plusargs.extend([
"+verilator+rand+reset+2",
f"+verilator+seed+{seed}",
])
if coverage:
args.append("COVERAGE_TYPE=" + coverage)

if simulator:
args.append("SIM=" + simulator)

args.append("PLUSARGS=" + " ".join(plusargs))

session.run(
*args,
external=True,
Expand Down
10 changes: 10 additions & 0 deletions verification/cocotb/top/lib_i3c_top/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def __init__(self, dut: SimHandleBase) -> None:
self.write_csr_field = self.busIf.write_csr_field

async def setup(self, fclk=500.0):

# Limit the requested clock frequency if a limit is set via cocotb
# plusargs
fmin = cocotb.plusargs.get("MinSystemClockFrequency", None)
if fmin is not None:
fmin = float(fmin)
if fclk < fmin:
self.dut._log.warning(f"Enforcing min. system clock frequency of {fmin:.3f} MHz")
fclk = fmin

await self.busIf.register_test_interfaces(fclk)
await ClockCycles(self.clk, 20)
await reset_n(self.clk, self.rst_n, cycles=5)

0 comments on commit e54b026

Please sign in to comment.