From: Luke Kenneth Casson Leighton Date: Mon, 17 Aug 2020 09:40:14 +0000 (+0100) Subject: use shift module in mmu. to be moved to nmutil X-Git-Tag: semi_working_ecp5~308 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ccd99a97805548fd20156c2b417f5a3e09a31230;p=soc.git use shift module in mmu. to be moved to nmutil --- diff --git a/src/soc/experiment/mmu.py b/src/soc/experiment/mmu.py index cdeb7f48..554367c7 100644 --- a/src/soc/experiment/mmu.py +++ b/src/soc/experiment/mmu.py @@ -9,6 +9,7 @@ from nmigen.cli import main from nmigen.cli import rtlil from nmutil.iocontrol import RecordObject from nmutil.byterev import byte_reverse +from nmigen.utils import log2_int from soc.experiment.mem_types import (LoadStore1ToMmuType, MmuToLoadStore1Type, @@ -67,6 +68,24 @@ class RegStage(RecordObject): self.rc_error = Signal() +class Mask(Elaboratable): + def __init__(self, sz): + self.sz = sz + self.shift = Signal(log2_int(sz, False)) + self.mask = Signal(sz) + + def elaborate(self, platform): + m = Module() + + comb = m.d.comb + + for i in range(self.sz): + with m.If(self.shift > i): + comb += self.mask[i].eq(1) + + return m + + class MMU(Elaboratable): """Radix MMU @@ -334,11 +353,15 @@ class MMU(Elaboratable): data = byte_reverse(m, "data", d_in.data, 8) # generate mask for extracting address fields for PTE addr generation - comb += mask.eq(Cat(C(0x1f,5), ((1< 4kB - comb += finalmask.eq(((1<