From a9936e15ed38ab0bc6da89e1c33af1d5ee0d018c Mon Sep 17 00:00:00 2001 From: Andrey Miroshnikov Date: Sun, 30 Jan 2022 17:01:06 +0000 Subject: [PATCH] Trying to debug the TDO issue with JTAG test --- src/spec/testing_stage1.py | 48 +++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/spec/testing_stage1.py b/src/spec/testing_stage1.py index e6f1353..cf47143 100644 --- a/src/spec/testing_stage1.py +++ b/src/spec/testing_stage1.py @@ -206,9 +206,12 @@ class Blinker(Elaboratable): # get the UART resource, mess with the output tx uart = self.jtag.request('uart') print("uart fields", uart, uart.fields) - self.intermediary = Signal() - m.d.comb += uart.tx.eq(self.intermediary) - m.d.comb += self.intermediary.eq(uart.rx) + self.uart_tx_test = Signal() + #self.intermediary = Signal() + #m.d.comb += uart.tx.eq(self.intermediary) + #m.d.comb += self.intermediary.eq(uart.rx) + # Allow tx to be controlled externally + m.d.comb += uart.tx.eq(self.uart_tx_test ^ uart.rx) # I2C num_i2c = 1 @@ -228,6 +231,7 @@ class Blinker(Elaboratable): # Public attributes are equivalent to input/output ports in hdl's self.gpio = gpio self.uart = uart + self.uart_tx_test self.i2c = i2c self.i2c_sda_oe_test = i2c_sda_oe_test self.i2c_scl_oe_test = i2c_scl_oe_test @@ -630,8 +634,8 @@ BS_PRELOAD = 2 def test_jtag_bs_chain(dut): - # print(dir(dut.jtag)) - # print(dir(dut)) + print(dir(dut.jtag)) + print(dir(dut)) print("JTAG BS Reset") yield from jtag_set_reset(dut.jtag) @@ -651,25 +655,34 @@ def test_jtag_bs_chain(dut): mask_high = bsdata # TODO: make format based on bslen, not a magic number 20-bits wide - print("Input Mask: {0:20b}".format(mask_inputs)) - print("Output Mask: {0:20b}".format(mask_outputs)) + print("Input Mask: {0:020b}".format(mask_inputs)) + print("Output Mask: {0:020b}".format(mask_outputs)) + print(dut.jtag._ir_width) + #bsdata = 0xA3659 + #bsdata = 0x20000 + bsdata = 0x00000 + uart_rx_pad = dut.jtag.boundary_scan_pads['uart_0__rx']['i'] + yield uart_rx_pad.eq(1) yield from jtag_unit_test(dut, BS_EXTEST, False, bsdata, mask_outputs) yield from jtag_unit_test(dut, BS_SAMPLE, False, bsdata, mask_low) + #yield from jtag_unit_test(dut, BS_SAMPLE, False, bsdata, mask_low) + # Run through GPIO, UART, and I2C tests so that all signals are asserted - yield from test_gpios(dut) - yield from test_uart(dut) - yield from test_i2c(dut) + #yield from test_gpios(dut) + #yield from test_uart(dut) + #yield from test_i2c(dut) - yield from jtag_unit_test(dut, BS_EXTEST, True, emptydata, mask_inputs) - yield from jtag_unit_test(dut, BS_SAMPLE, True, emptydata, mask_high) + #yield from jtag_unit_test(dut, BS_EXTEST, True, emptydata, mask_inputs) + #yield from jtag_unit_test(dut, BS_SAMPLE, True, emptydata, mask_high) print("JTAG Boundary Scan Chain Test PASSED!") def jtag_unit_test(dut, bs_type, is_io_set, bsdata, expected): - bslen = len(dut.jtag.ios) + bslen = len(dut.jtag.ios) #* 2 + print("Chain len based on jtag.ios: {}".format(bslen)) if bs_type == BS_EXTEST: print("Sending TDI data with core/pads disconnected") elif bs_type == BS_SAMPLE: @@ -687,10 +700,13 @@ def jtag_unit_test(dut, bs_type, is_io_set, bsdata, expected): result = yield from jtag_read_write_reg(dut.jtag, bs_type, bslen, bsdata) # TODO: TDO data does not always match the signal states, maybe JTAG reset? - print("TDI BS Data: {0:b}, Data Length (bits): {1}".format(bsdata, bslen)) - print("TDO BS Data: {0:b}".format(result)) + # TODO: make format based on bslen, not a magic number 20-bits wide + print("TDI BS Data: {0:020b}, Data Length (bits): {1}" + .format(bsdata, bslen)) + print("TDO BS Data: {0:020b}".format(result)) yield from check_ios_keys(dut, expected) + yield # testing extra clock # Reset shift register between tests yield from jtag_set_reset(dut.jtag) @@ -713,7 +729,7 @@ def check_ios_keys(dut, test_vector): else: raise Exception("Signal in JTAG ios dict: " + signal + " cannot be determined as input or output!") - assert temp_result == test_value + #assert temp_result == test_value # TODO: may need to expand to support further signals contained in the # JTAG module ios dictionary! -- 2.30.2