def write(self, val): """write to the data buffer""" val = util.mask_val(val, self.width) if self.wr_idx == len(self.buf): # append to the buffer self.buf.append(val) self.wr_idx += 1 elif self.wr_idx < len(self.buf): # replace existing content self.buf[self.wr_idx] = val else: assert False, 'buffer write error: more than 1 off the end'
def cmd_wr(self, ui, args, n): """memory write command for n bits""" if util.wrong_argc(ui, args, (1, 2)): return adr = util.sex_arg(ui, args[0], self.cpu.width) if adr == None: return adr = util.align(adr, n) val = 0 if len(args) == 2: val = util.int_arg(ui, args[1], util.limit_32, 16) if val == None: return val = util.mask_val(val, n) self.cpu.wr(adr, val, n) ui.put('[0x%08x] = ' % adr) ui.put('0x%%0%dx\n' % (n / 4) % val)
def cmd_wr(self, ui, args, n): """memory write command for n bits""" if util.wrong_argc(ui, args, (1,2)): return adr = util.sex_arg(ui, args[0], self.cpu.width) if adr == None: return adr = util.align(adr, n) val = 0 if len(args) == 2: val = util.int_arg(ui, args[1], util.limit_32, 16) if val == None: return val = util.mask_val(val, n) self.cpu.wr(adr, val, n) ui.put('[0x%08x] = ' % adr) ui.put('0x%%0%dx\n' % (n/4) % val)