47cf306bb2842bd911a5de5091c0fb89827f44e5
[c4m-jtag.git] / sim / cocotb / dual_parallel / test.py
1 import cocotb
2 from cocotb.utils import get_sim_steps
3
4 from c4m_jtag import JTAG_Master
5
6 @cocotb.test()
7 def test01_dual(dut):
8 """
9 Test the IDCODE command
10 """
11
12 # TODO: Allow parallel operation of the JTAG chains
13
14 # Run @ 1MHz
15 clk_period = get_sim_steps(1, "us")
16 master1 = JTAG_Master(dut.i1_tck, dut.i1_tms, dut.i1_tdi, dut.i1_tdo, dut.i1_trst_n, clk_period)
17 master2 = JTAG_Master(dut.i2_tck, dut.i2_tms, dut.i2_tdi, dut.i2_tdo, dut.i2_trst_n, clk_period)
18
19 dut._log.info("Set command to SAMPLEPRELOAD")
20 yield master1.load_ir(master1.SAMPLEPRELOAD)
21 yield master2.load_ir(master2.SAMPLEPRELOAD)
22
23 dut._log.info("Load data, scan out first sample")
24 yield master1.shift_data([0, 0, 0])
25 dut._log.info(" master1 scan_out: {}".format(master1.result.binstr))
26 assert(master1.result.binstr == "011")
27 yield master2.shift_data([1, 1, 1])
28 dut._log.info(" master2 scan_out: {}".format(master2.result.binstr))
29 assert(master2.result.binstr == "101")
30
31 dut._log.info("Set command to EXTEST")
32 yield master1.load_ir(master1.EXTEST)
33 yield master2.load_ir(master2.EXTEST)
34
35 dut._log.info("Second scan")
36 yield master1.shift_data([0, 0, 0])
37 dut._log.info(" master1 scan_out: {}".format(master1.result.binstr))
38 assert(master1.result.binstr == "111")
39 yield master2.shift_data([1, 1, 1])
40 dut._log.info(" master2 scan_out: {}".format(master2.result.binstr))
41 assert(master2.result.binstr == "Z01")