First attempt at implementing block access rd and wr regfile port onto
authorcolepoirier <colepoirier@gmail.com>
Tue, 26 May 2020 01:04:37 +0000 (18:04 -0700)
committercolepoirier <colepoirier@gmail.com>
Tue, 26 May 2020 01:04:37 +0000 (18:04 -0700)
an array-based regfile

src/soc/regfile/virtual_port.py [new file with mode: 0644]

diff --git a/src/soc/regfile/virtual_port.py b/src/soc/regfile/virtual_port.py
new file mode 100644 (file)
index 0000000..7f02ecc
--- /dev/null
@@ -0,0 +1,25 @@
+from nmigen.compat.sim import run_simulation
+from nmigen.cli import verilog, rtlil
+
+from nmigen import Cat, Const, Array, Signal, Elaboratable, Module
+from nmutil.iocontrol import RecordObject
+
+from soc.regfile import RegFileArray
+
+
+class VirtualPort(RegFileArray):
+    def __init__(self, bitwidth, n_regs):
+        self.bitwidth = bitwidth
+        self.nregs = n_regs
+        self.regwidth = bitwidth / n_regs
+        self.w_ports = [ self.write_port(f"{i}") for i in range(n_regs) ]
+        self.r_ports = [ self.read_port(f"{i}") for i in range(n_regs) ]
+        self.extra_wr.append(RecordObject([("ren", nregs), ("data_o", bitwidth, name="extra")]))
+        self.extra_rd.append(RecordObject([("ren", nregs), ("data_o", bitwidth, name="extra")]))
+
+    def elaborate(self, platform):
+        m = Module()
+        with m.If(self._get_en_sig(extra, "ren") == 0)
+            pass
+        with m.Else()
+            "send data through the corresponding lower indexed ports"