Add todo for floating_point test
@@ -316,35 +316,26 @@ class riscv_asm_program_gen:
pass
def init_gpr(self):
- reg_val = BitArray(uint = 0, length = pkg_ins.DATA_WIDTH)
- # TODO Map the function with PyVSC std::randomize()
+ reg_val_ = vsc.rand_bit_t(pkg_ins.DATA_WIDTH)
for i in range(rcs.NUM_GPR):
- if i in [cfg.sp.value, cfg.tp.value]:
+ if i == cfg.sp | i == cfg.tp:
continue
- if i == 0:
- reg_val = BitArray(hex='0x0')
- elif i == 1:
- reg_val = BitArray(hex='0x80000000')
- elif i == 2:
- temp = random.randrange(0x1, 0xf)
- reg_val = BitArray(hex(temp), length=32)
- elif i == 3:
- temp = random.randrange(0x10, 0xefffffff)
- reg_val = BitArray(hex(temp), length=32)
- else:
- temp = random.randrange(0xf0000000, 0xffffffff)
- reg_val = BitArray(hex(temp), length=32)
- init_string = "{}li x{}, {}".format(pkg_ins.indent, i, reg_val)
+ try:
+ with vsc.randomize_with(reg_val_) as it:
+ vsc.dist(reg_val_, [vsc.weight(0, 1), vsc.weight(0x80000000, 1),
+ vsc.weight(vsc.rng(0x10, 0xefffffff), 1),
+ vsc.weight(vsc.rng(0xf0000000, 0xffffffff), 1)])
+ except:
+ logging.critical("Cannot Randomize reg_val")
+ sys.exit(1)
+ init_string = "{}li x{}, {}".format(pkg_ins.indent, i, reg_val_)
self.instr_stream.append(init_string)
def init_floating_point_gpr(self):
for i in range(rcs.NUM_FLOAT_GPR):
- # TODO randselect
- '''
- vsc.randselect([(1, lambda:self.init_floating_point_gpr_with_spf(i)),
+ vsc.randselect([
+ (1, lambda: self.init_floating_point_gpr_with_spf(i)),
('RV64D' in rcs.supported_isa, lambda: self.init_floating_point_gpr_with_dpf(i))])
- '''
- self.init_floating_point_gpr_with_spf(i)
# Initialize rounding mode of FCSR
fsrmi_instr = "{}fsrmi {}".format(pkg_ins.indent, cfg.fcsr_rm)
self.instr_stream.append(fsrmi_instr)
