blob: bfd0464c7a1651623a877bdf6e7ebef7457d8636 [file] [log] [blame]
Created on Nov 22, 2020
@author: mballance
import cocotb
import pybfms
from wishbone_bfms.wb_initiator_bfm import WbInitiatorBfm
from logic_analyzer_bfms.la_initiator_bfm import LaInitiatorBfm
from random import Random
from fwpayload_tests.la_utils import LaUtils
async def test(top):
Hold the payload DUT in reset via the logic analyzer
Meanwhile, test that the management interface can access memory
print("--> pybfms.init()")
await pybfms.init()
print("<-- pybfms.init()")
u_wb : WbInitiatorBfm = pybfms.find_bfm(".*u_wb")
u_la : LaInitiatorBfm = pybfms.find_bfm(".*u_la")
print("u_wb=" + str(u_wb))
print("u_la=" + str(u_la))
# Bring the system out of reset
la_utils = LaUtils(u_la)
print("--> reset_cycle_dut")
await la_utils.reset_cycle_dut(100)
print("<-- reset_cycle_dut")
for i in range(10):
await la_utils.clock_dut()
await la_utils.set_dut_clock_control(False)
# Load a short program that toggles the GPIO lines
gpio_toggle_program = [
for i,data in enumerate(gpio_toggle_program):
print("Write: " + hex(0x30000000+4*i) + " " + hex(data))
await la_utils.write(0x30000000+4*i, data, 0xF)
# Take back clock control
await la_utils.set_dut_clock_control(True)
await la_utils.set_sys_reset(False)
# Release the processor from reset
await la_utils.set_core_reset(True)
for i in range(10):
await la_utils.reset_cycle_dut(10)
await la_utils.set_core_reset(False)
# Clock the system, while observing GPIO via the logic analyzer
gpio_out_last = None
for i in range(1000):
await la_utils.clock_dut()
gpio_out_new = la_utils.get_gpio_out()
if gpio_out_last is None or gpio_out_new != gpio_out_last:
print("New: " + hex(gpio_out_new))
gpio_out_last = gpio_out_new
if gpio_out_last == 0xF:
if gpio_out_last is None:
raise cocotb.result.TestError("No gpio activity")
if gpio_out_last != 0xF:
raise cocotb.result.TestError("GPIO did something, but we didn't reach 0xF")