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 chain_length(self, scan): """return the length of the JTAG chain""" tdo = bits.null() # build a 000...001000...000 flush buffer for tdi tdi = bits.zeroes(_flush_size).tail1(1).tail0(_flush_size) scan(tdi, tdo) # the first bits are junk tdo.drop_head(_flush_size) # work out how many bits tdo is behind tdi s = tdo.bit_str() s = s.lstrip('0') if len(s.replace('0', '')) != 1: raise Error, 'unexpected result from jtag chain, there should be a single 1' return len(s) - 1
def test1(self): x = bits.null() self.assertEqual(str(x), '(0) ')