From 3907a17efb753f56a7c289984687c1c31375c494 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Tue, 15 Jan 2019 16:05:25 -0500 Subject: [PATCH] hdl.xfrm: Add on_AnyConst and on_AnySeq abstract methods for ValueVisitor and children. --- nmigen/back/pysim.py | 12 ++++++++++++ nmigen/hdl/xfrm.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 1278923..95b2355 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -87,6 +87,12 @@ class _RHSValueCompiler(_ValueCompiler): def on_Const(self, value): return lambda state: value.value + def on_AnyConst(self, value): + raise NotImplementedError # :nocov: + + def on_AnySeq(self, value): + raise NotImplementedError # :nocov: + def on_Signal(self, value): if self.sensitivity is not None: self.sensitivity.add(value) @@ -219,6 +225,12 @@ class _LHSValueCompiler(_ValueCompiler): def on_Const(self, value): raise TypeError # :nocov: + def on_AnyConst(self, value): + raise TypeError # :nocov: + + def on_AnySeq(self, value): + raise TypeError # :nocov: + def on_Signal(self, value): shape = value.shape() value_slot = self.signal_slots[value] diff --git a/nmigen/hdl/xfrm.py b/nmigen/hdl/xfrm.py index 33c534e..728b95b 100644 --- a/nmigen/hdl/xfrm.py +++ b/nmigen/hdl/xfrm.py @@ -23,6 +23,14 @@ class ValueVisitor(metaclass=ABCMeta): def on_Const(self, value): pass # :nocov: + @abstractmethod + def on_AnyConst(self, value): + pass # :nocov: + + @abstractmethod + def on_AnySeq(self, value): + pass # :nocov: + @abstractmethod def on_Signal(self, value): pass # :nocov: @@ -69,6 +77,10 @@ class ValueVisitor(metaclass=ABCMeta): def on_value(self, value): if type(value) is Const: new_value = self.on_Const(value) + elif type(value) is AnyConst: + new_value = self.on_AnyConst(value) + elif type(value) is AnySeq: + new_value = self.on_AnySeq(value) elif type(value) is Signal: new_value = self.on_Signal(value) elif type(value) is Record: @@ -104,6 +116,12 @@ class ValueTransformer(ValueVisitor): def on_Const(self, value): return value + def on_AnyConst(self, value): + return value + + def on_AnySeq(self, value): + return value + def on_Signal(self, value): return value -- 2.30.2