From 83ecb65af9f5d068a2f766580080f5d327f28757 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 15 Dec 2018 21:01:38 +0000 Subject: [PATCH] back.pysim: add (stub) LHSValueCompiler. --- nmigen/back/pysim.py | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index e42169f..103466b 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -159,17 +159,45 @@ class _RHSValueCompiler(ValueTransformer): return lambda state: normalize(elems[index(state)](state), shape) +class _LHSValueCompiler(ValueTransformer): + def on_Const(self, value): + raise TypeError # :nocov: + + def on_Signal(self, value): + return lambda state, arg: state.set(value, arg) + + def on_ClockSignal(self, value): + raise NotImplementedError # :nocov: + + def on_ResetSignal(self, value): + raise NotImplementedError # :nocov: + + def on_Operator(self, value): + raise TypeError # :nocov: + + def on_Slice(self, value): + raise NotImplementedError + + def on_Part(self, value): + raise NotImplementedError + + def on_Cat(self, value): + raise NotImplementedError + + def on_Repl(self, value): + raise TypeError # :nocov: + + def on_ArrayProxy(self, value): + raise NotImplementedError + + class _StatementCompiler(StatementTransformer): def __init__(self): self.sensitivity = ValueSet() self.rhs_compiler = _RHSValueCompiler(self.sensitivity) - - def lhs_compiler(self, value): - # TODO - return lambda state, arg: state.set(value, arg) + self.lhs_compiler = _LHSValueCompiler() def on_Assign(self, stmt): - assert isinstance(stmt.lhs, Signal) shape = stmt.lhs.shape() lhs = self.lhs_compiler(stmt.lhs) rhs = self.rhs_compiler(stmt.rhs) -- 2.30.2