Skip to content

Commit c65bf40

Browse files
committed
uniformized and simplified testbench scoping
1 parent 424cf3b commit c65bf40

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

src/examples/basic/tb.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
from microcotb.triggers import RisingEdge, FallingEdge, ClockCycles, Timer
2828
from microcotb.utils import get_sim_time
2929

30-
# get the @cocotb tests into a namespace
31-
cocotb.RunnerModuleName = 'basic'
30+
# get the detected @cocotb tests into a namespace
31+
# so we can load multiple such modules
32+
cocotb.set_runner_scope(__name__)
3233

3334
from ttboard.demoboard import DemoBoard, RPMode
3435
from ttboard.cocotb.dut import DUT
@@ -146,7 +147,7 @@ def run():
146147
tt.uio_oe_pico.value = 0 # all inputs
147148

148149
# get a runner
149-
runner = cocotb.get_runner('basic')
150+
runner = cocotb.get_runner(__name__)
150151

151152
# here's our DUT... you could subclass this and
152153
# do cool things, like rename signals or access

src/examples/tt_um_factory_test/tt_um_factory_test.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
gc.collect()
1717

1818

19-
# get the @cocotb tests into a namespace
20-
cocotb.RunnerModuleName = 'tt_um_factory_test'
19+
# get the detected @cocotb tests into a namespace
20+
# so we can load multiple such modules
21+
cocotb.set_runner_scope(__name__)
2122

2223
@cocotb.test()
2324
async def test_loopback(dut):
@@ -145,7 +146,7 @@ def __init__(self):
145146
TimeValue.ReBaseStringUnits = True # I like pretty strings
146147

147148

148-
runner = cocotb.get_runner('tt_um_factory_test')
149+
runner = cocotb.get_runner(__name__)
149150

150151
dut = DUT()
151152
dut._log.info(f"enabled factory test project. Will test with {runner}")

src/examples/tt_um_psychogenic_neptuneproportional/tt_um_psychogenic_neptuneproportional.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
from microcotb.triggers import Timer, ClockCycles # RisingEdge, FallingEdge, Timer, ClockCycles
1010

1111

12-
# get the @cocotb tests into a namespace
13-
cocotb.RunnerModuleName = 'tt_um_psychogenic_neptune'
12+
# get the detected @cocotb tests into a namespace
13+
# so we can load multiple such modules
14+
cocotb.set_runner_scope(__name__)
1415

1516
from ttboard.demoboard import DemoBoard, RPMode
1617

@@ -202,7 +203,7 @@ def main():
202203
TimeValue.ReBaseStringUnits = True
203204

204205
# create runner and DUT, and get tests going
205-
runner = cocotb.get_runner('tt_um_psychogenic_neptune')
206+
runner = cocotb.get_runner(__name__)
206207
dut = DUT()
207208
dut._log.info(f"enabled neptune project, will test with {runner}")
208209
runner.test(dut)

src/examples/tt_um_psychogenic_shaman/tb.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
import hashlib
1919
import random
2020

21+
22+
23+
# get the detected @cocotb tests into a namespace
24+
# so we can load multiple such modules
25+
cocotb.set_runner_scope(__name__)
26+
27+
2128
GateLevelTest = False
2229
DoLongLongTest = False
2330
DoEverySizeBlockTest = False
@@ -619,7 +626,7 @@ def main():
619626
dut = DUT()
620627
tt.uio_oe_pico.value = dut.oe_pico_setting
621628

622-
runner = cocotb.get_runner('tt_um_psychogenic_shaman')
629+
runner = cocotb.get_runner(__name__)
623630
dut._log.info(f"enabled shaman project. Will test with\n{runner}")
624631
runner.test(dut)
625632

src/examples/tt_um_rejunity_sn76489/tt_um_rejunity_sn76489.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
from microcotb.triggers import RisingEdge, FallingEdge, Timer, ClockCycles
3232

3333

34-
# get the @cocotb tests into a namespace
35-
cocotb.RunnerModuleName = 'tt_um_rejunity_snXXX'
34+
# get the detected @cocotb tests into a namespace
35+
# so we can load multiple such modules
36+
cocotb.set_runner_scope(__name__)
3637

3738
# MASTER_CLOCK = 3_579_545 # NTSC frequency of SN as used in Sega Master System, 0xFE = 440 Hz
3839
# MASTER_CLOCK = 3_546_895 # PAL ---- // ----
@@ -611,5 +612,5 @@ def main(selection=None, master_clock=None, internal_clock_div = None):
611612

612613
dut = DUT()
613614
dut._log.info("enabled factory test project, running")
614-
runner = cocotb.get_runner('tt_um_rejunity_snXXX')
615+
runner = cocotb.get_runner(__name__)
615616
runner.test(dut)

src/examples/tt_um_rgbled_decoder/tt_um_rgbled_decoder.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
from microcotb.triggers import RisingEdge, FallingEdge, Timer, ClockCycles
2727
from microcotb.utils import get_sim_time
2828

29-
30-
# get the @cocotb tests into a namespace
31-
cocotb.RunnerModuleName = 'tt_um_rgbled_decoder'
29+
# get the detected @cocotb tests into a namespace
30+
# so we can load multiple such modules
31+
cocotb.set_runner_scope(__name__)
3232

3333

3434
def time_delta_not(cond:str):
@@ -230,7 +230,7 @@ def main():
230230

231231
dut = DUT()
232232
dut._log.info("enabled rgbled project, running")
233-
runner = cocotb.get_runner('tt_um_rgbled_decoder')
233+
runner = cocotb.get_runner(__name__)
234234
runner.test(dut)
235235

236236

src/main.py

-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ def stopClocking():
118118

119119
def run_testbench_basic():
120120
import microcotb
121-
# a uPython means to avoid having all
122-
# decorators ever seen in the same test run:
123121
import examples.basic as test
124122
test.run()
125123
return test

0 commit comments

Comments
 (0)