|
| 1 | +from caravel_cocotb.caravel_interfaces import report_test |
| 2 | +import cocotb |
| 3 | +from common import test_configure_ml |
| 4 | +import random |
| 5 | +from frigate_test.gpio import GPIOsPortB, GPIOsPortA, GPIOsPortH |
| 6 | + |
| 7 | +@cocotb.test() |
| 8 | +@report_test |
| 9 | +async def counter(dut): |
| 10 | + caravelEnv = await test_configure_ml(dut, timeout_cycles=78129) |
| 11 | + cocotb.log.info("[TEST] Start counter test") |
| 12 | + counter_gpio = GPIOsPortA(caravelEnv) # RTL connects user counter value to GPIOA |
| 13 | + gpio_port_b = GPIOsPortB(caravelEnv) # for monitoring value read from software |
| 14 | + gpio_port_h = GPIOsPortH(caravelEnv) # new value indicator |
| 15 | + shift = 0 |
| 16 | + old_counter_val = 0 |
| 17 | + old_software_val = 0 |
| 18 | + for i in range(10): |
| 19 | + await gpio_port_h.wait_gpio_pin(7, 1) |
| 20 | + counter_val = counter_gpio.monitor_gpio(7, 0).integer |
| 21 | + software_val = gpio_port_b.monitor_gpio(7, 0).integer |
| 22 | + cocotb.log.info(f"[TEST] counter_val: {counter_val}, software_val: {software_val} shift {counter_val - software_val}") |
| 23 | + if i == 0: |
| 24 | + shift = counter_val - software_val |
| 25 | + old_counter_val = counter_val |
| 26 | + old_software_val = software_val |
| 27 | + else: |
| 28 | + if counter_val - software_val != shift: |
| 29 | + cocotb.log.error(f"[TEST] shift error shift = {counter_val - software_val} expected shift = {shift}") |
| 30 | + if counter_val <= old_counter_val: |
| 31 | + cocotb.log.error(f"[TEST] counting direction error counter_val: {counter_val} <= old_counter_val: {old_counter_val}") |
| 32 | + if software_val <= old_software_val: |
| 33 | + cocotb.log.error(f"[TEST] counting direction error software_val: {software_val} <= old_software_val: {old_software_val}") |
| 34 | + await gpio_port_h.wait_gpio_pin(7, 0) |
0 commit comments