From f700880e9add726c01ace79e2a36e48faa83946c Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 9 Jun 2020 14:01:06 +0100 Subject: [PATCH] expand LenExpand (haha) to cover bytes, with an argument "cover" all puns intentional --- src/soc/scoreboard/addr_match.py | 49 ++++++++++++++++++++++++++++---- src/soc/scoreboard/addr_split.py | 1 + 2 files changed, 44 insertions(+), 6 deletions(-) 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<