opcode,unit,internal op,in1,in2,in3,out,CR in,CR out,inv A,inv out,cry in,cry out,ldst len,BR,sgn ext,upd,rsrv,32b,sgn,rc,lk,sgl pipe,comment,form,CONDITIONS,unofficial,comment2
+# ternlog (integer, CR and CR field)
--------00-,SHIFT_ROT,OP_TERNLOG,RA,RB,RT,RT,NONE,CR0,0,0,ZERO,0,NONE,0,0,0,0,0,0,RC_ONLY,0,0,ternlogi,TLI,,1,unofficial until submitted and approved/renumbered by the opf isa wg
---------010,CR,OP_CRFTERNLOG,NONE,NONE,NONE,NONE,BFA_BFB_BF,BF,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,crfternlogi,CRB,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-------00100,ALU,OP_MADDSUBRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddsubrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-------01100,ALU,OP_MADDRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
-------10100,ALU,OP_MSUBRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,msubrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+-----00001-,CR,OP_CRFTERNLOG,NONE,NONE,NONE,NONE,BFA_BFB_BF,BF,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,crfternlogi,CRB,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+-----00101-,CR,OP_CRTERNLOG,NONE,NONE,NONE,NONE,BA_BB,BT,0,0,ZERO,0,NONE,0,0,0,0,0,0,NONE,0,0,crternlogi,TLI,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+
+# integer butterfly
+-----100100,ALU,OP_MADDSUBRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddsubrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+-----101100,ALU,OP_MADDRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,maddrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
+-----110100,ALU,OP_MSUBRS,RA,CONST_SH,RB,RT,NONE,NONE,0,0,ZERO,0,NONE,0,0,0,0,1,0,NONE,0,0,msubrs,A,,1,unofficial until submitted and approved/renumbered by the opf isa wg
return expected
+def crfternlogi(bf, bfa, bfb, imm, mask):
+ expected = bf&~mask # start at BF, mask overwrites masked bits only
+ checks = (bfb, bfa, bf) # LUT positions 1<<0=bfb 1<<1=bfa 1<<2=bf
+ for i in range(4):
+ lut_index = 0
+ for j, check in enumerate(checks):
+ if check & (1<<i):
+ lut_index |= 1<<j
+ maskbit = (mask >> i) & 0b1
+ if (imm & (1<<lut_index)) and maskbit:
+ expected |= 1<<i
+ return expected
+
+
class BitManipTestCase(TestAccumulatorBase):
def case_gbbd(self):
lst = ["gbbd 0, 1"]
lst = list(SVP64Asm(lst, bigendian))
e = ExpectedState(pc=4)
- expected = bf&~mask # start at BF, mask overwrites masked bits only
- checks = (bfb, bfa, bf) # LUT positions 1<<0=bfb 1<<1=bfa 1<<2=bf
- for i in range(4):
- lut_index = 0
- for j, check in enumerate(checks):
- if check & (1<<i):
- lut_index |= 1<<j
- maskbit = (mask >> i) & 0b1
- if (imm & (1<<lut_index)) and maskbit:
- expected |= 1<<i
- e.crregs[3] = expected
+ e.crregs[3] = crfternlogi(bf, bfa, bfb, imm, mask)
e.crregs[4] = bfa
e.crregs[5] = bfb
self.add_case(Program(lst, bigendian), initial_regs=None, expected=e,
def case_crfternlogi_random(self):
for i in range(100):
- rc = bool(hash_256(f"crfternlogi rc {i}") & 1)
imm = hash_256(f"crfternlogi imm {i}") & 0xFF
bf = hash_256(f"crfternlogi bf {i}") % 2 ** 4
bfa = hash_256(f"crfternlogi bfa {i}") % 2 ** 4