def num_devices(self): """return the number of JTAG devices in the chain""" # put every device into bypass mode (IR = all 1's) self.driver.scan_ir(bits.ones(_flush_size)) # now each DR is a single bit # the DR chain length is the number of devices return self.dr_length()
def test_ir_capture(self): """test the IR capture result""" # write all-1s to the IR rd = self.rw_ir(bits.ones(self.irlen)) val = rd.split((self.irlen, ))[0] # the lowest 2 bits should be "01" return val & 3 == 1
def read_idcodes(self): """return a tuple of idcodes for the JTAG chain""" # a TAP reset leaves the idcodes in the DR chain self.driver.tap_reset() tdi = bits.ones(self.n * _idcode_length) tdo = bits.null() self.driver.scan_dr(tdi, tdo) return tdo.split((_idcode_length, ) * self.n)
def rw_dr(self, wr): """read/write DR for a device""" tdi = bits.ones(self.devs_before).tail(wr).tail1(self.devs_after) tdo = bits.null() self.chain.driver.scan_dr(tdi, tdo) # strip the dr bits from the bypassed devices tdo.drop_head(self.devs_before) tdo.drop_tail(self.devs_after) return tdo
def rw_ir(self, wr): """read/write IR for a device""" tdi = bits.ones(self.irlen_before).tail(wr).tail1(self.irlen_after) tdo = bits.null() self.chain.driver.scan_ir(tdi, tdo) # strip the ir bits from the other devices tdo.drop_head(self.irlen_before) tdo.drop_tail(self.irlen_after) return tdo
def test5(self): x = bits.ones(7).tail0(4) self.assertEqual(str(x), '(11) 00001111111')
def test2(self): x = bits.ones(3) self.assertEqual(str(x), '(3) 111')
def wr_dr(self, wr): """write to DR for a device""" # other devices are assumed to be in bypass mode (dr length = 1) tdi = bits.ones(self.devs_before).tail(wr).tail1(self.devs_after) self.chain.driver.scan_dr(tdi)
def wr_ir(self, wr): """write to IR for a device""" # place other devices into bypass mode (ir = all 1's) tdi = bits.ones(self.irlen_before).tail(wr).tail1(self.irlen_after) self.chain.driver.scan_ir(tdi)