From: Luke Kenneth Casson Leighton Date: Tue, 9 Jun 2020 13:01:06 +0000 (+0100) Subject: expand LenExpand (haha) to cover bytes, with an argument "cover" X-Git-Tag: div_pipeline~448 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f700880e9add726c01ace79e2a36e48faa83946c;p=soc.git expand LenExpand (haha) to cover bytes, with an argument "cover" all puns intentional --- diff --git a/src/soc/scoreboard/addr_match.py b/src/soc/scoreboard/addr_match.py index a47f635f..704e1b9b 100644 --- a/src/soc/scoreboard/addr_match.py +++ b/src/soc/scoreboard/addr_match.py @@ -31,10 +31,11 @@ Notes: > the L2 cache was Line sized. """ -from nmigen.compat.sim import run_simulation +from nmigen.compat.sim import run_simulation, Settle from nmigen.cli import verilog, rtlil -from nmigen import Module, Signal, Const, Array, Cat, Elaboratable +from nmigen import Module, Signal, Const, Array, Cat, Elaboratable, Repl from nmigen.lib.coding import Decoder +from nmigen.utils import log2_int from nmutil.latch import latchregister, SRLatch @@ -117,23 +118,36 @@ class LenExpand(Elaboratable): => 0b1111000 (bit_len=4) len=8, addr=0b0101 => 0b11111111 << addr => 0b1111111100000 + + note: by setting cover=8 this can also be used as a shift-mask. the + bit-mask is replicated (expanded out), each bit expanded to "cover" bits. """ - def __init__(self, bit_len): + def __init__(self, bit_len, cover=1): self.bit_len = bit_len + self.cover = cover + cl = log2_int(cover) self.len_i = Signal(bit_len, reset_less=True) self.addr_i = Signal(bit_len, reset_less=True) - self.lexp_o = Signal(1<<(bit_len+1), reset_less=True) + self.lexp_o = Signal((cover<<(bit_len))+(cl<