From 9b2a6304989519a3edce217b1f55432095e9cac9 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 17 Mar 2020 17:57:48 +0000 Subject: [PATCH] create MultiPriorityPicker which can mutually-exclusively select M outputs from Mx N-way inputs to be used for example to ensure that M "things" seeking access to M "other things" do not conflict: that only one "thing" at a time gets access to the other "things" --- src/nmutil/latch.py | 19 +++++++++---- src/nmutil/picker.py | 66 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/src/nmutil/latch.py b/src/nmutil/latch.py index 2086fe5..6bf6fd9 100644 --- a/src/nmutil/latch.py +++ b/src/nmutil/latch.py @@ -29,16 +29,23 @@ def latchregister(m, incoming, outgoing, settrue, name=None): with m.Else(): m.d.comb += outgoing.eq(reg) # return input (combinatorial) +def mkname(prefix, suffix): + if suffix is None: + return prefix + return "%s_%s" % (prefix, suffix) class SRLatch(Elaboratable): - def __init__(self, sync=True, llen=1): + def __init__(self, sync=True, llen=1, name=None): self.sync = sync self.llen = llen - self.s = Signal(llen, reset=0) - self.r = Signal(llen, reset=(1<