From: Luke Kenneth Casson Leighton Date: Tue, 26 May 2020 15:54:33 +0000 (+0100) Subject: sort-of (maybe) implemented a virtual port on top of RegFileArray. X-Git-Tag: div_pipeline~814 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4c54a8a8f3d4c375171e1efd4524801c78c95b5;p=soc.git sort-of (maybe) implemented a virtual port on top of RegFileArray. needs checking --- diff --git a/src/soc/regfile/virtual_port.py b/src/soc/regfile/virtual_port.py index 159ff04d..4f025887 100644 --- a/src/soc/regfile/virtual_port.py +++ b/src/soc/regfile/virtual_port.py @@ -21,15 +21,19 @@ class VirtualRegPort(RegFileArray): def __init__(self, bitwidth, n_regs): self.bitwidth = bitwidth self.nregs = n_regs - self.regwidth = bitwidth // n_regs + self.regwidth = regwidth = bitwidth // n_regs super().__init__(self.regwidth, n_regs) # create suite of 8 write and 8 read ports for external use - self.wr_ports = self.write_reg_port(f"extw") - self.rd_ports = self.read_reg_port(f"extr") - # now for internal use - self._wr_regs = self.write_reg_port(f"intw") - self._rd_regs = self.read_reg_port(f"intr") + self.wr_ports = [] + self.rd_ports = [] + for i in range(n_regs): + self.wr_ports.append(RecordObject([("wen", n_regs), + ("data_i", regwidth)], + name="w%d" % i)) + self.rd_ports.append(RecordObject([("ren", n_regs), + ("data_o", regwidth)], + name="r%d" % i)) # and append the "full" depth variant to the "external" ports self.wr_ports.append(RecordObject([("wen", n_regs), ("data_i", bitwidth)], # *full* wid @@ -37,6 +41,9 @@ class VirtualRegPort(RegFileArray): self.rd_ports.append(RecordObject([("ren", n_regs), ("data_o", bitwidth)], # *full* wid name="full_rd")) + # now for internal use + self._wr_regs = self.write_reg_port(f"intw") + self._rd_regs = self.read_reg_port(f"intr") def elaborate(self, platform): m = super().elaborate(platform) @@ -45,20 +52,23 @@ class VirtualRegPort(RegFileArray): # connect up: detect if read is requested on large (full) port # nothing fancy needed because reads are same-cycle rlast = self.rd_ports[-1] + ren_sig = Signal(reset_less=True) + comb += ren_sig.eq(rlast.ren.bool()) print (rlast) - with m.If(self._get_en_sig([rlast], "ren") != 0): - # wire up the enable signals and accumulate the data - l = [] - print (self._rdports) - for i, port in enumerate(self._rdports[:-1]): - print (port) - comb += port.ren.eq(1<