use instruction issue queue to get instructions into engine
[soc.git] / src / scoreboard / test_iq.py
index 6bbb26db4c33921fbf589242a69a8ed97481f2c4..06e1511ea4719b5c005593b75fb4d57d86db3558 100644 (file)
@@ -22,23 +22,26 @@ class IQSim:
         i = 0
         while i < len(self.iq):
             sendlen = randint(1, self.n_in)
-            print (sendlen)
+            sendlen = 1
             sendlen = min(len(self.iq) - i, sendlen)
-            print (len(self.iq)-i, sendlen)
+            print ("sendlen", len(self.iq)-i, sendlen)
             for idx in range(sendlen):
                 instr = self.iq[i+idx]
                 yield from eq(self.dut.data_i[idx], instr)
+                di = yield self.dut.data_i[idx]#.src1_i
+                print ("senddata %d %x" % ((i+idx), di))
+                self.oq.append(di)
             yield self.dut.p_add_i.eq(sendlen)
+            yield
             o_p_ready = yield self.dut.p_ready_o
             while not o_p_ready:
                 yield
                 o_p_ready = yield self.dut.p_ready_o
 
-            yield
+            yield self.dut.p_add_i.eq(0)
 
             print ("send", len(self.iq), i, sendlen)
 
-            yield self.dut.p_add_i.eq(0)
             # wait random period of time before queueing another value
             for j in range(randint(0, 3)):
                 yield
@@ -62,16 +65,24 @@ class IQSim:
 
     def rcv(self):
         i = 0
+        yield
+        yield
+        yield
         while i < len(self.iq):
             rcvlen = randint(1, self.n_out)
             #print ("outreq", rcvlen)
             yield self.dut.n_sub_i.eq(rcvlen)
             n_sub_o = yield self.dut.n_sub_o
+            print ("recv", n_sub_o)
+            for j in range(n_sub_o):
+                r = yield self.dut.data_o[j]#.src1_i
+                print ("recvdata %x %s" % (r, repr(self.iq[i+j])))
+                assert r == self.oq[i+j]
             yield
             if n_sub_o == 0:
                 continue
+            yield self.dut.n_sub_i.eq(0)
 
-            print ("recv", n_sub_o)
             i += n_sub_o
 
         print ("recv ended")
@@ -91,11 +102,11 @@ def mk_insns(n_insns, wid, opwid):
 def test_iq():
     wid = 8
     opwid = 4
-    qlen = 5
-    n_in = 2
-    n_out = 3
+    qlen = 2
+    n_in = 1
+    n_out = 1
     dut = InstructionQ(wid, opwid, qlen, n_in, n_out)
-    insns = mk_insns(10, wid, opwid)
+    insns = mk_insns(1000, wid, opwid)
 
     vl = rtlil.convert(dut, ports=dut.ports())
     with open("test_iq.il", "w") as f: