def do_reg_write(self, line): fmat = r"(.*)\[(\d*)\]\s*(\d*)" searchObj = re.search(fmat, line) if searchObj is not None: reg_name = searchObj.group(1) index = int(searchObj.group(2)) val = int(searchObj.group(3)) else: print >> sys.stderr, "ERROR: usage ..." self.help_reg_write() return result = p4_regs_api.reg_write(reg_name, index, val) print result
def _clear_dist(self): for i in range(NUM_BINS): p4_regs_api.reg_write('dist', i, 0)