From f690846a710a75ea8ed809a7b7a4351236210fc9 Mon Sep 17 00:00:00 2001 From: colepoirier Date: Mon, 25 May 2020 18:04:37 -0700 Subject: [PATCH] First attempt at implementing block access rd and wr regfile port onto an array-based regfile --- src/soc/regfile/virtual_port.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/soc/regfile/virtual_port.py diff --git a/src/soc/regfile/virtual_port.py b/src/soc/regfile/virtual_port.py new file mode 100644 index 00000000..7f02ecc2 --- /dev/null +++ b/src/soc/regfile/virtual_port.py @@ -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" -- 2.30.2