Skip to content

Conversation

htfab
Copy link

@htfab htfab commented Nov 25, 2024

Using Timer without setting up a Clock raises an IndexError:

from ttboard import cocotb
from ttboard.cocotb.triggers import Timer

@cocotb.test()
async def test_timer(dut):
    await Timer(10, units='ms')

if __name__ == '__main__':
    from ttboard.cocotb.dut import DUTWrapper   
    cocotb.get_runner().test(DUTWrapper())

Output:

MPY: soft reboot
db init: 128240
user conf loaded: 130240
ttboard.demoboard: Demoboard starting up in mode ASIC_RP_CONTROL
ttboard.pins.pins: Setting mode to ASIC_RP_CONTROL
ttboard.boot.rom: Got ROM data shuttle=tt04
repo=TinyTapeout/tinytapeout-04

ttboard.project_mux: Disable (selecting project 0)
ttboard.project_mux: Loading shuttle file /shuttles/tt04.json
ttboard.project_mux: Enable design tt_um_factory_test
ttboard.demoboard: Resetting system clock to default 1.25e+08Hz
ttboard.demoboard: Clocking at 10Hz
ttboard.demoboard: First time loading: Toggling project reset
ttboard.demoboard: Changing reset to output mode
DUT: *** Running Test 1/1: test_timer ***
DUT: T*** Test 'test_timer' FAIL: list index out of range ***
DUT: 1/1 tests failed
DUT: *** Summary ***
DUT: 	FAIL	test_timer	list index out of range

The exception happens at ttboard/cocotb/triggers/timer.py line 22:

This PR is a quick and dirty fix for this specific case when all_clocks is empty. There are some other edge cases where either self.time or some of the other clocks aren't a multiple of the fastest clock, but we can deal with them later.

@psychogenic psychogenic merged commit b0aa330 into TinyTapeout:v2.0-dev Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants