def decode(idcode): """decode the JTAG idcode, return a string""" version = util.bits(idcode, (31, 28)) part = util.bits(idcode, (27, 12)) mfg = util.bits(idcode, (11, 1)) s = [] s.append('idcode 0x%08x' % idcode) s.append('mfg 0x%03x (%s)' % (mfg, mfg_name(mfg))) s.append('part 0x%04x' % part) s.append('ver 0x%x' % version) if util.bits(idcode, (0,)) != 1: s.append('leading bit != 1') return ' '.join(s)
def idr_decode(idr): """return a string for the IDR decode""" rev = util.bits(idr, (31, 28)) jedec_cont = util.bits(idr, (27, 24)) jedec_id = util.bits(idr, (23, 17)) ap_class = util.bits(idr, (16, 13)) ap_variant = util.bits(idr, (7, 4)) ap_type = util.bits(idr, (3, 0)) s = [] if jedec_cont == 0x4 and jedec_id == 0x3b: jedec_name = 'ARM' else: jedec_name = '?' ap_name = { AP_TYPE_JTAG: 'JTAG', AP_TYPE_AHB: 'AHB', AP_TYPE_APB: 'APB', AP_TYPE_AXI: 'AXI', } class_name = { AP_CLASS_NONE: 'NONE', AP_CLASS_MEM_AP: 'MEM-AP', } s.append('idr 0x%08x' % idr) s.append('rev %x' % rev) s.append('jedec %x:%x (%s)' % (jedec_cont, jedec_id, jedec_name)) s.append('class %x (%s)' % (ap_class, class_name.get(ap_class, '?'))) s.append('ap %x:%x (%s)' % (ap_variant, ap_type, ap_name.get(ap_type, '?'))) return ' '.join(s)
def is_jtag_ap(idr): """return True if this IDR is for a JTAG-AP""" ap_class = util.bits(idr, (16, 13)) ap_type = util.bits(idr, (3, 0)) return ap_class == AP_CLASS_NONE and ap_type == AP_TYPE_JTAG
def is_mem_ap(idr): """return True if this IDR is for a MEM-AP""" ap_class = util.bits(idr, (16, 13)) return ap_class == AP_CLASS_MEM_AP