[libre-riscv-dev] [Bug 154] Cell for Dependency Matrices is needed

bugzilla-daemon at libre-riscv.org bugzilla-daemon at libre-riscv.org
Mon Jan 13 16:15:12 GMT 2020


http://bugs.libre-riscv.org/show_bug.cgi?id=154

--- Comment #8 from Staf Verhaegen <staf at fibraservi.eu> ---
(Sorry accidently commit previous comment. Redo comment)

After reading a little further I think that the architecture was developed at a
moment where not the current synthesis, place-and-route and timing check tools
were available. With current tools I think it is better to implement it all on
the DependencyMatrix level without sublevels. Incomplete and non-checked code
but I hope to get the idea across:

    class DependencyMatrix(Elaboratable):
        def __init__(self, n_fus, n_regs):
             self.fu_start = Signal(n_fus)
             self.fu_read_in = Array(Signal(n_regs) for _ in range(n_fus))
             self.fu_write_in = Array(Signal(n_regs) for _ in range(n_fus))
             self.fu_read_ok = Signal(n_fus)
             self.fu_read_done = Signal(n_fus)
             self.reg_read_reserve = Signal(n_refs)
             self.fu_write_ok = Signal(n_fus)
             self.fu_write_done = Signal(n_fus)
             self.reg_write_reserve = Signal(n_refs)

             self._n_fus = n_fus
             self._n_regs = n_regs

        def elaborate(self, platform):
            n_fus = self._n_fus
            n_regs = self._n_regs

            m = Module()

            matrix_read_regs = Array(Signal(n_regs) for _ in range(n_fus))
            matrix_write_regs = Array(Signal(n_regs) for _ in range(n_fus))
            matrix_read_fus = Array(
                Cat(matrix_read_regs[i][j] for i in range(n_fus))
                for j in range(n_regs)
            )
            matrix_write_fus = Array(
                Cat(matrix_write_regs[i][j] for i in range(n_fus))
                for j in range(n_regs)
            )

            m.d.comb += [
                 self.reg_read_reserve.eq(Cat(matrix_read_fus[i] != 0) for i in
range(n_regs)),
                 self.reg_write_reserve.eq(Cat(matrix_write_fus[i] != 0) for i
in range(n_regs)),
            ]

            for i in range(n_fus):
                 needed = matrix_read_regs[i]
                 not_reserved_read = self.reg_read_reserve &
~matrix_read_refs[i]
                 m.d.comb += self.fu_read_ok.eq(~(needed | not_reserved_read)
== 0)

                 needed = matrix_write_regs[i]
                 not_reserved_write = self.reg_write_reserve &
~matrix_write_refs[i]
                 m.d.comb += self.fu_write_ok.eq(~(needed | (not_reserved_read
& not_reserved_write)) == 0)

                 with m.If(self.fu_start[i]):
                      m.d.sync += [
                          matrix_read_regs[i].eq(self.fu_read_in[i]),
                          matrix_write_regs[i].eq(self.fu_write_in[i]),
                      ]
                 with m.Else():
                      with m.If(self.fu_read_done[i]):
                          m.d.sync += matrix_read_regs[i].eq(0)
                      with m.If(self.fu_write_done[i]):
                          m.d.sync += matrix_write_regs[i].eq(0)

            ...

            return m

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-riscv-dev mailing list