# Helper functions
#
+class JTAGPin:
+ def __init__(self, pin):
+ self.type_ = pin[2]
+ self.name = pin[3]
+
+ def log(self, dut):
+ if self.type_ == IOType.In:
+ core_i = getattr(dut.test_issuer, f"{self.name}__core__i").value
+ pad_i = getattr(dut.test_issuer, f"{self.name}__pad__i").value
+ dut._log.info(f"{self.name}: core.i={core_i}, pad.i={pad_i}")
+ elif self.type_ == IOType.Out:
+ core_o = getattr(dut.test_issuer, f"{self.name}__core__o").value
+ pad_o = getattr(dut.test_issuer, f"{self.name}__pad__o").value
+ dut._log.info(f"{self.name}: core.o={core_o}, pad.o={pad_o}")
+ elif self.type_ == IOType.TriOut:
+ core_o = getattr(dut.test_issuer, f"{self.name}__core__o").value
+ core_oe = getattr(dut.test_issuer, f"{self.name}__core__oe").value
+ pad_o = getattr(dut.test_issuer, f"{self.name}__pad__o").value
+ pad_oe = getattr(dut.test_issuer, f"{self.name}__pad__oe").value
+ dut._log.info(f"{self.name}: core.(o={core_o}, oe={core_oe}), pad.(o={pad_o}, oe={pad_oe})")
+ elif self.type_ == IOType.InTriOut:
+ core_i = getattr(dut.test_issuer, f"{self.name}__core__i").value
+ core_o = getattr(dut.test_issuer, f"{self.name}__core__o").value
+ core_oe = getattr(dut.test_issuer, f"{self.name}__core__oe").value
+ pad_i = getattr(dut.test_issuer, f"{self.name}__pad__i").value
+ pad_o = getattr(dut.test_issuer, f"{self.name}__pad__o").value
+ pad_oe = getattr(dut.test_issuer, f"{self.name}__pad__oe").value
+ dut._log.info(f"{self.name}: core.(i={core_i}, o={core_o}, oe={core_oe}), pad.(t={core_i}, o={pad_o}, oe={pad_oe})")
+ else:
+ raise ValueError(f"Unsupported pin type {self.type_}")
+
+ def check(self, dut, val):
+ if self.type_ == IOType.In:
+ assert getattr(dut.test_issuer, f"{self.name}__core__i").value == val
+ elif self.type_ == IOType.Out:
+ assert getattr(dut.test_issuer, f"{self.name}__pad__o").value == val
+ elif self.type_ == IOType.TriOut:
+ assert getattr(dut.test_issuer, f"{self.name}__core__o").value == val
+ assert getattr(dut.test_issuer, f"{self.name}__core__oe").value == 1
+ elif self.type_ == IOType.InTriOut:
+ assert getattr(dut.test_issuer, f"{self.name}__core__i").value == val
+ assert getattr(dut.test_issuer, f"{self.name}__pad__o").value == val
+ assert getattr(dut.test_issuer, f"{self.name}__pad__oe").value == val
+ else:
+ raise ValueError(f"Unsupported pin type {self.type_}")
+
+def log_pins(dut, pins):
+ for pin in pins:
+ pin.log(dut)
+
+
def get_jtag_boundary():
"""gets the list of information for jtag boundary scan
"""
# 'mspi1', - disabled for now
# 'pwm', 'sd0', - disabled for now
'sdr']
- pins = Pins(get_pinspecs(subset=subset))
+ pins = tuple(JTAGPin(pin) for pin in Pins(get_pinspecs(subset=subset)))
return pins
-def log_pin(dut, pin):
- _, _, type_, name, _ = pin
- if type_ == IOType.In:
- core_i = getattr(dut.test_issuer, f"{name}__core__i").value
- pad_i = getattr(dut.test_issuer, f"{name}__pad__i").value
- dut._log.info(f"{name}: core.i={core_i}, pad.i={pad_i}")
- elif type_ == IOType.Out:
- core_o = getattr(dut.test_issuer, f"{name}__core__o").value
- pad_o = getattr(dut.test_issuer, f"{name}__pad__o").value
- dut._log.info(f"{name}: core.o={core_o}, pad.o={pad_o}")
- elif type_ == IOType.TriOut:
- core_o = getattr(dut.test_issuer, f"{name}__core__o").value
- core_oe = getattr(dut.test_issuer, f"{name}__core__oe").value
- pad_o = getattr(dut.test_issuer, f"{name}__pad__o").value
- pad_oe = getattr(dut.test_issuer, f"{name}__pad__oe").value
- dut._log.info(f"{name}: core.(o={core_o}, oe={core_oe}), pad.(o={pad_o}, oe={pad_oe})")
- elif type_ == IOType.InTriOut:
- core_i = getattr(dut.test_issuer, f"{name}__core__i").value
- core_o = getattr(dut.test_issuer, f"{name}__core__o").value
- core_oe = getattr(dut.test_issuer, f"{name}__core__oe").value
- pad_i = getattr(dut.test_issuer, f"{name}__pad__i").value
- pad_o = getattr(dut.test_issuer, f"{name}__pad__o").value
- pad_oe = getattr(dut.test_issuer, f"{name}__pad__oe").value
- dut._log.info(f"{name}: core.(i={core_i}, o={core_o}, oe={core_oe}), pad.(t={core_i}, o={pad_o}, oe={pad_oe})")
- else:
- raise ValueError(f"Unsupported pin type {type_}")
-
-def log_pins(dut, pins):
- for pin in get_jtag_boundary():
- log_pin(dut, pin)
-
-def check_pin(dut, pin, val):
- _, _, type_, name, _ = pin
- if type_ == IOType.In:
- assert getattr(dut.test_issuer, f"{name}__core__i").value == val
- elif type_ == IOType.Out:
- assert getattr(dut.test_issuer, f"{name}__pad__o").value == val
- elif type_ == IOType.TriOut:
- assert getattr(dut.test_issuer, f"{name}__core__o").value == val
- assert getattr(dut.test_issuer, f"{name}__core__oe").value == 1
- elif type_ == IOType.InTriOut:
- assert getattr(dut.test_issuer, f"{name}__core__i").value == val
- assert getattr(dut.test_issuer, f"{name}__pad__o").value == val
- assert getattr(dut.test_issuer, f"{name}__pad__oe").value == val
- else:
- raise ValueError(f"Unsupported pin type {type_}")
-
def setup_sim(dut, *, clk_period, run):
"""Initialize CPU and setup clock"""
#
def boundary_scan(dut, *, jtag):
- pins = tuple(get_jtag_boundary())
+ pins = get_jtag_boundary()
yield jtag.reset()
dut._log.info("After scan")
log_pins(dut, pins)
- check_pin(dut, pins[0], 1)
+ pins[0].check(dut, 1)
yield jtag.reset()
dut._log.info("After reset")
log_pins(dut, pins)
- check_pin(dut, pins[0], 0)
+ pins[0].check(dut, 0)
@cocotb.test()