From ccd99a97805548fd20156c2b417f5a3e09a31230 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Mon, 17 Aug 2020 10:40:14 +0100 Subject: [PATCH] use shift module in mmu. to be moved to nmutil --- src/soc/experiment/mmu.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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<