hack to set predicate mask (if it exists)
[ieee754fpu.git] / src / ieee754 / fpcommon / test / fpmux.py
index 631f2fc2af5cde1e95de7d5a1890f9a113e4f3fd..77d70a45fa1911b66498a14a262c385e02822048 100644 (file)
@@ -38,7 +38,10 @@ class MuxInOut:
                     #print ("test", hex(op1), hex(op2))
                     res = self.fpop(self.fpkls(op1), self.fpkls(op2))
                     self.di[muxid][i] = (op1, op2)
-                self.do[muxid].append(res.bits)
+                if hasattr(res, "bits"):
+                    self.do[muxid].append(res.bits)
+                else:
+                    self.do[muxid].append(res) # for FP to INT
 
     def send(self, muxid):
         for i in range(self.tlen):
@@ -54,6 +57,8 @@ class MuxInOut:
             if not self.single_op:
                 yield rs.data_i.b.eq(op2)
             yield rs.data_i.muxid.eq(muxid)
+            if hasattr(rs, "mask_i"):
+                yield rs.mask_i.eq(1) # TEMPORARY HACK
             yield
             o_p_ready = yield rs.ready_o
             while not o_p_ready:
@@ -63,14 +68,18 @@ class MuxInOut:
             if self.single_op:
                 fop1 = self.fpkls(op1)
                 res = self.fpop(fop1)
-                print ("send", muxid, i, hex(op1), hex(res.bits),
-                               fop1, res)
+                if hasattr(res, "bits"):
+                    r = res.bits
+                else:
+                    r = res
+                print("send", muxid, i, hex(op1), hex(r),
+                              fop1, res)
             else:
                 fop1 = self.fpkls(op1)
                 fop2 = self.fpkls(op2)
                 res = self.fpop(fop1, fop2)
-                print ("send", muxid, i, hex(op1), hex(op2), hex(res.bits),
-                               fop1, fop2, res)
+                print("send", muxid, i, hex(op1), hex(op2), hex(res.bits),
+                              fop1, fop2, res)
 
             yield rs.valid_i.eq(0)
             # wait random period of time before queueing another value
@@ -80,7 +89,7 @@ class MuxInOut:
         yield rs.valid_i.eq(0)
         yield
 
-        print ("send ended", muxid)
+        print("send ended", muxid)
 
         ## wait random period of time before queueing another value
         #for i in range(randint(0, 3)):
@@ -112,8 +121,8 @@ class MuxInOut:
 
             out_i = 0
 
-            print ("recv", out_muxid, hex(out_z), "expected",
-                        hex(self.do[muxid][out_i] ))
+            print("recv", out_muxid, hex(out_z), "expected",
+                  hex(self.do[muxid][out_i]))
 
             # see if this output has occurred already, delete it if it has
             assert muxid == out_muxid, "out_muxid %d not correct %d" % \
@@ -124,7 +133,7 @@ class MuxInOut:
             # check if there's any more outputs
             if len(self.do[muxid]) == 0:
                 break
-        print ("recv ended", muxid)
+        print("recv ended", muxid)
 
 
 def create_random(num_rows, width, single_op=False, n_vals=10):
@@ -132,7 +141,7 @@ def create_random(num_rows, width, single_op=False, n_vals=10):
     for muxid in range(num_rows):
         for i in range(n_vals):
             if single_op:
-                op1 = randint(0, (1<<width)-1)
+                op1 = randint(0, (1 << width)-1)
                 #op1 = 0x40900000
                 #op1 = 0x94607b66
                 #op1 = 0x889cd8c
@@ -161,15 +170,71 @@ def create_random(num_rows, width, single_op=False, n_vals=10):
 
                 #op1 = 0x1841
 
+                # FSQRT
                 #op1 = 0x3449f9a9
+                #op1 = 0x1ba94baa
+
+                #if i % 2:
+                #    op1 = 0x0001
+                #else:
+                #    op1 = 0x3C00
+
+                # FRSQRT
+                #op1 = 0x3686
+                #op1 = 0x4400
+                #op1 = 0x4800
+                #op1 = 0x48f0
+                #op1 = 0x429
+                #op1 = 0x2631
+                #op1 = 0x3001
+                #op1 = 0x3f2ad8eb
+
+                # f2int
+                #op1 = 0x4dc0
+                #op1 = 0x3b81
+                #op1 = 0xfcb6
+                #op1 = 0x4f8d77b3
+
+                # f2int signed
+                #op1 = 0xc913
+                #op1 = 0x7b97
+                #op1 = 0xaae2
+                #op1 = 0x7fca
+
+                # FCLASS
+                #op1 = 0x87d1
+                #op1 = 0x75e
+                #op1 = 0x7f8c
+                #op1 = 0x7c57
+                #op1 = 0xfea8
+                #op1 = 0xfd57
+
+                # f2int unsigned (fp64 to ui16)
+                #op1 = 0x40e6f5bc4d88b0cc
+
+                # f2int signed (fp64 to i16)
+                #op1 = 0xff292cf09f159ddb
+                #op1 = 0x5880e09f7cb716a1
+
+                # f2int signed (fp64 to i32)
+                #op1 = 0x5beb66ffc69a9a64
+                #op1 = 0xd4cdd178a1f2cdec
 
                 vals.append((op1,))
             else:
-                op1 = randint(0, (1<<width)-1)
-                op2 = randint(0, (1<<width)-1)
+                op1 = randint(0, (1 << width)-1)
+                op2 = randint(0, (1 << width)-1)
+                # op1 = 0x3F800000  # 1.0f32
+                # op2 = 0x40000000  # 2.0f32
+
+                #op2 = 0x4000
+                #op1 = 0x3c50
+                #op2 = 0x3e00
+                #op2 = 0xb371
+                #op1 = 0x4400
+                #op1 = 0x656c
+                #op1 = 0x738c
 
-                op1 = 0x4000
-                op2 = 0x4000
                 vals.append((op1, op2,))
     return vals
 
@@ -186,14 +251,14 @@ def repeat(num_rows, vals):
 
 
 def pipe_cornercases_repeat(dut, name, mod, fmod, width, fn, cc, fpfn, count,
-                            single_op=False):
+                            single_op=False, opcode=None):
     for i, fixed_num in enumerate(cc(mod)):
         vals = fn(mod, fixed_num, count, width, single_op)
         vals = repeat(dut.num_rows, vals)
         #print ("repeat", i, fn, single_op, list(vals))
         fmt = "test_pipe_fp%d_%s_cornercases_%d"
         runfp(dut, width, fmt % (width, name, i),
-                   fmod, fpfn, vals=vals, single_op=single_op)
+              fmod, fpfn, vals=vals, single_op=single_op, opcode=opcode)
 
 
 def runfp(dut, width, name, fpkls, fpop, single_op=False, n_vals=10,