From: whitequark Date: Sat, 15 Dec 2018 21:01:38 +0000 (+0000) Subject: back.pysim: add (stub) LHSValueCompiler. X-Git-Tag: working~213 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bdb8db2826891dd09de516b6514e8bd202906ed5;p=nmigen.git back.pysim: add (stub) LHSValueCompiler. --- 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)