From: Luke Kenneth Casson Leighton Date: Sat, 26 Sep 2020 14:42:24 +0000 (+0100) Subject: create client-server version of jtag debug unit test X-Git-Tag: 24jan2021_ls180~315 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2f218479f33282ef472863fa05d112c9ad397d5;p=soc.git create client-server version of jtag debug unit test --- diff --git a/src/soc/debug/test/test_jtag_tap_srv.py b/src/soc/debug/test/test_jtag_tap_srv.py new file mode 100644 index 00000000..ae74f5ee --- /dev/null +++ b/src/soc/debug/test/test_jtag_tap_srv.py @@ -0,0 +1,229 @@ +"""DMI 2 JTAG test + +based on Staf Verhaegen (Chips4Makers) wishbone TAP +""" + +from nmigen import (Module, Signal, Elaboratable, Const) +from c4m.nmigen.jtag.tap import TAP, IOType +from c4m.nmigen.jtag.bus import Interface as JTAGInterface +from soc.debug.dmi import DMIInterface, DBGCore +from soc.debug.test.dmi_sim import dmi_sim +from soc.debug.dmi2jtag import DMITAP +from soc.debug.test.jtagremote import JTAGServer, JTAGClient + +from nmigen_soc.wishbone.sram import SRAM +from nmigen import Memory, Signal, Module + +from nmigen.back.pysim import Simulator, Delay, Settle, Tick +from nmutil.util import wrap + +def client_sync(dut): + tck = yield dut.cbus.tck + tms = yield dut.cbus.tms + tdi = yield dut.cbus.tdi + dut.c.jtagremote_client_send((tck, tms, tdi)) + #print ("about to client recv") + while True: + tdo = dut.c.jtagremote_client_recv(timeout=0) + if tdo is not None: + break + yield + yield dut.cbus.tdo.eq(tdo) + + +def tms_state_set(dut, bits): + for bit in bits: + yield dut.cbus.tck.eq(1) + yield dut.cbus.tms.eq(bit) + yield from client_sync(dut) + yield + yield dut.cbus.tck.eq(0) + yield from client_sync(dut) + yield + yield from client_sync(dut) + yield dut.cbus.tms.eq(0) + yield from client_sync(dut) + + +def tms_data_getset(dut, tms, d_len, d_in=0): + res = 0 + yield dut.cbus.tms.eq(tms) + for i in range(d_len): + tdi = 1 if (d_in & (1<