rtio: support direct 64-bit now CSR in KernelInitiator

This commit is contained in:
Sebastien Bourdeauducq 2020-04-26 16:04:32 +08:00
parent 251a0101a6
commit 3a7819704a
1 changed files with 20 additions and 14 deletions

View File

@ -60,11 +60,14 @@ class Interface(Record):
class KernelInitiator(Module, AutoCSR): class KernelInitiator(Module, AutoCSR):
def __init__(self, tsc, cri=None): def __init__(self, tsc, cri=None, now64=False):
self.target = CSRStorage(32) self.target = CSRStorage(32)
# not using CSRStorage atomic_write feature here to make storage reset_less if now64:
self.now_hi = CSR(32) self.now = CSRStorage(64)
self.now_lo = CSR(32) else:
# not using CSRStorage atomic_write feature here to make storage reset_less
self.now_hi = CSR(32)
self.now_lo = CSR(32)
# Writing target clears o_data. This implements automatic # Writing target clears o_data. This implements automatic
# zero-extension of output event data by the gateware. When staging an # zero-extension of output event data by the gateware. When staging an
@ -87,16 +90,19 @@ class KernelInitiator(Module, AutoCSR):
# # # # # #
now_hi_backing = Signal(32) if now64:
now = Signal(64, reset_less=True) now = self.now.storage
self.sync += [ else:
If(self.now_hi.re, now_hi_backing.eq(self.now_hi.r)), now = Signal(64, reset_less=True)
If(self.now_lo.re, now.eq(Cat(self.now_lo.r, now_hi_backing))) now_hi_backing = Signal(32)
] self.sync += [
self.comb += [ If(self.now_hi.re, now_hi_backing.eq(self.now_hi.r)),
self.now_hi.w.eq(now[32:]), If(self.now_lo.re, now.eq(Cat(self.now_lo.r, now_hi_backing)))
self.now_lo.w.eq(now[:32]) ]
] self.comb += [
self.now_hi.w.eq(now[32:]),
self.now_lo.w.eq(now[:32])
]
self.comb += [ self.comb += [
self.cri.cmd.eq(commands["nop"]), self.cri.cmd.eq(commands["nop"]),