srcmask = dstmask = 0xffff_ffff_ffff_ffff
if self.is_svp64_mode:
pmode = yield self.dec2.rm_dec.predmode
+ reverse_gear = yield self.dec2.rm_dec.reverse_gear
sv_ptype = yield self.dec2.dec.op.SV_Ptype
srcpred = yield self.dec2.rm_dec.srcpred
dstpred = yield self.dec2.rm_dec.dstpred
if sv_ptype == SVPtype.P2.value:
srcmask = get_predcr(self.crl, srcpred, vl)
log (" pmode", pmode)
+ log (" reverse", reverse_gear)
log (" ptype", sv_ptype)
log (" srcpred", bin(srcpred))
log (" dstpred", bin(dstpred))
srcstep = self.svstate.srcstep.asint(msb0=True)
dststep = self.svstate.dststep.asint(msb0=True)
rm_mode = yield self.dec2.rm_dec.mode
+ reverse_gear = yield self.dec2.rm_dec.reverse_gear
sv_ptype = yield self.dec2.dec.op.SV_Ptype
out_vec = not (yield self.dec2.no_out_vec)
in_vec = not (yield self.dec2.no_in_vec)
log (" svstate.srcstep", srcstep)
log (" svstate.dststep", dststep)
log (" mode", rm_mode)
+ log (" reverse", reverse_gear)
log (" out_vec", out_vec)
log (" in_vec", in_vec)
log (" sv_ptype", sv_ptype, sv_ptype == SVPtype.P2.value)
svstate=svstate)
self._check_regs(sim, expected_regs)
+ def test_sv_add_prefix_sum(self):
+ """>>> lst = ['sv.add/mr 2.v, 2.v, 1.v'
+ ]
+ adds performed - not in reverse
+ * 2 = 2 + 1 => 1 + 2 => 3
+ * 3 = 3 + 2 => 3 + 3 => 6
+ * 4 = 4 + 3 => 4 + 6 => 10
+
+ pascal's triangle!
+ """
+ isa = SVP64Asm(['sv.add/mr 2.v, 2.v, 1.v'
+ ])
+ lst = list(isa)
+ print ("listing", lst)
+
+ # initial values in GPR regfile
+ initial_regs = [0] * 32
+ initial_regs[1] = 0x1
+ initial_regs[2] = 0x2
+ initial_regs[3] = 0x3
+ initial_regs[4] = 0x4
+ # SVSTATE (in this case, VL=2)
+ svstate = SVP64State()
+ svstate.vl[0:7] = 3 # VL
+ svstate.maxvl[0:7] = 3 # MAXVL
+ print ("SVSTATE", bin(svstate.spr.asint()))
+ # copy before running, then compute answers
+ expected_regs = deepcopy(initial_regs)
+ for i in range(3):
+ print ("%d += %d" % (2+i, 1+i))
+ expected_regs[2+i] += expected_regs[1+i]
+ for i in range(5):
+ print ("expected", i, expected_regs[i])
+
+ with Program(lst, bigendian=False) as program:
+ sim = self.run_tst_program(program, initial_regs,
+ svstate=svstate)
+ self._check_regs(sim, expected_regs)
+
+ def test_sv_add_prefix_sum_reverse(self):
+ """>>> lst = ['sv.add/mrr 2.v, 2.v, 1.v'
+ ]
+ adds performed - *in reverse order*
+ * 4 = 4 + 3 => 1 + 2 => 3
+ * 3 = 3 + 2 => 3 + 2 => 5
+ * 2 = 2 + 1 => 3 + 4 => 7
+ """
+ isa = SVP64Asm(['sv.add/mrr 2.v, 2.v, 1.v'
+ ])
+ lst = list(isa)
+ print ("listing", lst)
+
+ # initial values in GPR regfile
+ initial_regs = [0] * 32
+ initial_regs[1] = 0x4
+ initial_regs[2] = 0x3
+ initial_regs[3] = 0x2
+ initial_regs[4] = 0x1
+ # SVSTATE (in this case, VL=2)
+ svstate = SVP64State()
+ svstate.vl[0:7] = 3 # VL
+ svstate.maxvl[0:7] = 3 # MAXVL
+ print ("SVSTATE", bin(svstate.spr.asint()))
+ # copy before running, then compute answers
+ expected_regs = deepcopy(initial_regs)
+ for i in range(3):
+ j = 2-i
+ print ("%d += %d" % (2+j, 1+j))
+ expected_regs[2+j] += expected_regs[1+j]
+ for i in range(5):
+ print ("expected", i, expected_regs[i])
+
+ with Program(lst, bigendian=False) as program:
+ sim = self.run_tst_program(program, initial_regs,
+ svstate=svstate)
+ self._check_regs(sim, expected_regs)
+
def test_fp_muls_reduce(self):
""">>> lst = ["sv.fmuls/mr 1, 2.v, 1",
]
sv_mode = None
mapreduce = False
+ reverse_gear = False
mapreduce_crm = False
mapreduce_svm = False
assert sv_mode is None
sv_mode = 0b11
predresult = decode_ffirst(encmode[3:])
+ # map-reduce mode, reverse-gear
+ elif encmode == 'mrr':
+ assert sv_mode is None
+ sv_mode = 0b00
+ mapreduce = True
+ reverse_gear = True
# map-reduce mode
elif encmode == 'mr':
assert sv_mode is None
elif sv_mode == 0b00:
mode |= (0b1<<SVP64MODE.REDUCE) # sets mapreduce
assert dst_zero == 0, "dest-zero not allowed in mapreduce mode"
+ if reverse_gear:
+ mode |= (0b1<<SVP64MODE.RG) # sets Reverse-gear mode
if mapreduce_crm:
mode |= (0b1<<SVP64MODE.CRM) # sets CRM mode
assert rc_mode, "CRM only allowed when Rc=1"
macros = {'win2': '50', 'win': '60'}
lst = [
'sv.addi win2.v, win.v, -1',
+ 'sv.add./mrr 5.v, 2.v, 1.v',
]
isa = SVP64Asm(lst, macros=macros)
print ("list", list(isa))