projects
/
nmutil.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fe2a5cf
)
Check equality between two PipeContext instances.
author
Samuel A. Falvo II
<kc5tja@arrl.net>
Fri, 17 Jul 2020 23:27:03 +0000
(16:27 -0700)
committer
Samuel A. Falvo II
<kc5tja@arrl.net>
Fri, 17 Jul 2020 23:27:03 +0000
(16:27 -0700)
src/nmutil/concurrentunit.py
patch
|
blob
|
history
diff --git
a/src/nmutil/concurrentunit.py
b/src/nmutil/concurrentunit.py
index fd11a3e99cdb8968e4bb61bb0fcc04207d0aedaa..f4667b6ed52634e82aba215a708ef63ec20e177a 100644
(file)
--- a/
src/nmutil/concurrentunit.py
+++ b/
src/nmutil/concurrentunit.py
@@
-10,6
+10,7
@@
from math import log
from nmigen import Module, Elaboratable, Signal
from math import log
from nmigen import Module, Elaboratable, Signal
+from nmigen.asserts import Assert
from nmigen.cli import main, verilog
from nmutil.singlepipe import PassThroughStage
from nmigen.cli import main, verilog
from nmutil.singlepipe import PassThroughStage
@@
-41,8
+42,20
@@
class PipeContext:
def eq(self, i):
ret = [self.muxid.eq(i.muxid)]
ret.append(self.op.eq(i.op))
def eq(self, i):
ret = [self.muxid.eq(i.muxid)]
ret.append(self.op.eq(i.op))
+ # don't forget to update matches if you add fields later.
return ret
return ret
+ def matches(self, another):
+ """
+ Returns a list of Assert()s validating that this context
+ matches the other context.
+ """
+ # I couldn't figure a clean way of overloading the == operator.
+ return [
+ Assert(self.muxid == another.muxid),
+ Assert(self.op == another.op),
+ ]
+
def __iter__(self):
yield self.muxid
yield self.op
def __iter__(self):
yield self.muxid
yield self.op