Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 71304c9fe72a
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7e3cf26cf8df
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Dec 14, 2018

  1. back.pysim: revert 70ebc6f.

    whitequark committed Dec 14, 2018
    Copy the full SHA
    7e3cf26 View commit details
Showing with 10 additions and 28 deletions.
  1. +10 −28 nmigen/back/pysim.py
38 changes: 10 additions & 28 deletions nmigen/back/pysim.py
Original file line number Diff line number Diff line change
@@ -47,19 +47,14 @@ def commit(self, signal):
class _RHSValueCompiler(ValueTransformer):
def __init__(self, sensitivity=None):
self.sensitivity = sensitivity
self.signal_mode = "next"

def on_Const(self, value):
return lambda state: value.value

def on_Signal(self, value):
if self.sensitivity is not None:
self.sensitivity.add(value)
if self.signal_mode == "curr":
return lambda state: state.curr[value]
if self.signal_mode == "next":
return lambda state: state.next[value]
raise NotImplementedError # :nocov:
return lambda state: state.curr[value]

def on_ClockSignal(self, value):
raise NotImplementedError # :nocov:
@@ -151,14 +146,6 @@ def __init__(self):
self.sensitivity = ValueSet()
self.rhs_compiler = _RHSValueCompiler(self.sensitivity)

@contextmanager
def initial(self):
try:
self.rhs_compiler.signal_mode = "curr"
yield
finally:
self.rhs_compiler.signal_mode = "next"

def lhs_compiler(self, value):
# TODO
return lambda state, arg: state.set(value, arg)
@@ -354,22 +341,15 @@ def add_fragment(fragment, scope=()):
self._sync_signals.update(signals)
self._domain_signals[domain].update(signals)

initial_stmts = []
statements = []
for signal in fragment.iter_comb():
initial_stmts.append(signal.eq(signal.reset))
statements.append(signal.eq(signal.reset))
for domain, signal in fragment.iter_sync():
initial_stmts.append(signal.eq(signal))
statements.append(signal.eq(signal))
statements += fragment.statements

compiler = _StatementCompiler()
def make_funclet():
with compiler.initial():
funclet_init = compiler(initial_stmts)
funclet_frag = compiler(fragment.statements)
def funclet(state):
funclet_init(state)
funclet_frag(state)
return funclet
funclet = make_funclet()
funclet = compiler(statements)

def add_funclet(signal, funclet):
if signal not in self._funclets:
@@ -484,7 +464,8 @@ def format_process(process):
self._passive.add(process)

elif isinstance(cmd, Value):
funclet = _RHSValueCompiler()(cmd)
compiler = _RHSValueCompiler()
funclet = compiler(cmd)
cmd = process.send(funclet(self._state))
continue

@@ -501,7 +482,8 @@ def format_process(process):
"simulation"
.format(format_process(process), signal))

funclet = _StatementCompiler()(cmd)
compiler = _StatementCompiler()
funclet = compiler(cmd)
funclet(self._state)

domains = set()