move dependency cells to row class
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 18 May 2019 08:43:27 +0000 (09:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 18 May 2019 08:43:27 +0000 (09:43 +0100)
src/scoreboard/dependence_cell.py
src/scoreboard/fu_reg_matrix.py

index ae552077841baf7e8189b8f7c64892c173bc60e1..a4cb8a2d27d9d7ee0ec1a8d28bde1f8ac4103031 100644 (file)
@@ -1,6 +1,6 @@
 from nmigen.compat.sim import run_simulation
 from nmigen.cli import verilog, rtlil
-from nmigen import Module, Signal, Elaboratable
+from nmigen import Module, Signal, Elaboratable, Array
 from nmutil.latch import SRLatch
 
 
@@ -75,6 +75,18 @@ class DependenceCell(Elaboratable):
         return list(self)
 
 
+class DependencyRow(Elaboratable):
+    def __init__(self, n_reg_col):
+        self.n_reg_col = n_reg_col
+        self.rcell = Array(DependenceCell() for f in range(self.n_reg_col))
+
+    def elaborate(self, platform):
+        m = Module()
+        for rn in range(self.n_reg_col):
+            setattr(m.submodules, "dm_r%d" % rn, self.rcell[rn])
+        return m
+
+
 def dcell_sim(dut):
     yield dut.dest_i.eq(1)
     yield dut.issue_i.eq(1)
index 94d30600a8f74d1d732134d30909ca47d8eccb3f..747c43710f5ac97a4216850cfe8546bfdcda3a7b 100644 (file)
@@ -3,7 +3,7 @@ from nmigen.cli import verilog, rtlil
 from nmigen import Module, Signal, Elaboratable, Array, Cat
 
 #from nmutil.latch import SRLatch
-from scoreboard.dependence_cell import DependenceCell
+from scoreboard.dependence_cell import DependencyRow
 from scoreboard.fu_wr_pending import FU_RW_Pend
 from scoreboard.reg_select import Reg_Rsv
 
@@ -56,11 +56,9 @@ class FURegDepMatrix(Elaboratable):
         # ---
         # matrix of dependency cells
         # ---
-        dm = Array(Array(DependenceCell() for r in range(self.n_fu_row)) \
-                                          for f in range(self.n_reg_col))
-        for rn in range(self.n_reg_col):
-            for fu in range(self.n_fu_row):
-                setattr(m.submodules, "dm_r%d_fu%d" % (rn, fu), dm[rn][fu])
+        dm = Array(DependencyRow(self.n_reg_col) for r in range(self.n_fu_row))
+        for fu in range(self.n_fu_row):
+            setattr(m.submodules, "dr_fu%d" % fu, dm[fu])
 
         # ---
         # array of Function Unit Pending vectors
@@ -89,7 +87,7 @@ class FURegDepMatrix(Elaboratable):
             src1_fwd_o = []
             src2_fwd_o = []
             for rn in range(self.n_reg_col):
-                dc = dm[rn][fu]
+                dc = dm[fu].rcell[rn]
                 # accumulate cell fwd outputs for dest/src1/src2 
                 dest_fwd_o.append(dc.dest_fwd_o)
                 src1_fwd_o.append(dc.src1_fwd_o)
@@ -125,7 +123,7 @@ class FURegDepMatrix(Elaboratable):
             src1_rsel_o = []
             src2_rsel_o = []
             for fu in range(self.n_fu_row):
-                dc = dm[rn][fu]
+                dc = dm[fu].rcell[rn]
                 # accumulate cell reg-select outputs dest/src1/src2
                 dest_rsel_o.append(dc.dest_rsel_o)
                 src1_rsel_o.append(dc.src1_rsel_o)
@@ -155,7 +153,7 @@ class FURegDepMatrix(Elaboratable):
             src1_i = []
             src2_i = []
             for rn in range(self.n_reg_col):
-                dc = dm[rn][fu]
+                dc = dm[fu].rcell[rn]
                 # accumulate cell inputs dest/src1/src2
                 dest_i.append(dc.dest_i)
                 src1_i.append(dc.src1_i)
@@ -174,7 +172,7 @@ class FURegDepMatrix(Elaboratable):
             go_wr_i = []
             issue_i = []
             for fu in range(self.n_fu_row):
-                dc = dm[rn][fu]
+                dc = dm[fu].rcell[rn]
                 # accumulate cell fwd outputs for dest/src1/src2 
                 go_rd_i.append(dc.go_rd_i)
                 go_wr_i.append(dc.go_wr_i)