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: 4948162f33d2
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: 4bf80a6e3356
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Jan 26, 2019

  1. compat.sim: fix deprecated stdlib import.

    whitequark committed Jan 26, 2019
    Copy the full SHA
    4887771 View commit details
  2. test.compat: reenable tests converting to Verilog.

    whitequark committed Jan 26, 2019
    Copy the full SHA
    7890c0a View commit details
  3. Copy the full SHA
    4bf80a6 View commit details
Showing with 38 additions and 17 deletions.
  1. +1 −1 nmigen/compat/fhdl/verilog.py
  2. +9 −9 nmigen/compat/genlib/fsm.py
  3. +2 −2 nmigen/compat/sim/__init__.py
  4. +6 −4 nmigen/test/compat/support.py
  5. +20 −1 nmigen/tools.py
2 changes: 1 addition & 1 deletion nmigen/compat/fhdl/verilog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings

from ...hdl import Fragment
from ...hdl.ir import Fragment
from ...back import verilog
from .conv_output import ConvOutput

18 changes: 9 additions & 9 deletions nmigen/compat/genlib/fsm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import warnings
from collections import OrderedDict

from ...tools import _ignore_deprecated
from ...hdl.xfrm import ValueTransformer, StatementTransformer
from ...hdl.ast import *
from ..fhdl.module import CompatModule, CompatFinalizeError
@@ -153,6 +153,7 @@ def after_leaving(self, state):
self.sync += signal.eq(self.before_leaving(state))
return signal

@_ignore_deprecated
def do_finalize(self):
nstates = len(self.actions)
self.encoding = dict((s, n) for n, s in enumerate(self.actions.keys()))
@@ -178,11 +179,10 @@ def _lower_controls(self):

def _finalize_sync(self, ls):
cases = dict((self.encoding[k], ls.on_statement(v)) for k, v in self.actions.items() if v)
with warnings.catch_warnings():
self.comb += [
self.next_state.eq(self.state),
Case(self.state, cases).makedefault(self.encoding[self.reset_state])
]
self.sync += self.state.eq(self.next_state)
for register, next_value_ce, next_value in ls.registers:
self.sync += If(next_value_ce, register.eq(next_value))
self.comb += [
self.next_state.eq(self.state),
Case(self.state, cases).makedefault(self.encoding[self.reset_state])
]
self.sync += self.state.eq(self.next_state)
for register, next_value_ce, next_value in ls.registers:
self.sync += If(next_value_ce, register.eq(next_value))
4 changes: 2 additions & 2 deletions nmigen/compat/sim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import functools
import collections
import inspect
from collections.abc import Iterable
from ...back.pysim import *


@@ -23,7 +23,7 @@ def run_simulation(fragment_or_module, generators, clocks={"sync": 10}, vcd_name
for domain, period in clocks.items():
sim.add_clock(period / 1e9, domain=domain)
for domain, processes in generators.items():
if isinstance(processes, collections.Iterable) and not inspect.isgenerator(processes):
if isinstance(processes, Iterable) and not inspect.isgenerator(processes):
for process in processes:
sim.add_sync_process(process, domain=domain)
else:
10 changes: 6 additions & 4 deletions nmigen/test/compat/support.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from ...tools import _ignore_deprecated
from ...compat import *
# from ...compat.fhdl import verilog
from ...compat.fhdl import verilog


class SimCase:
def setUp(self, *args, **kwargs):
self.tb = self.TestBench(*args, **kwargs)
with _ignore_deprecated():
self.tb = self.TestBench(*args, **kwargs)

# def test_to_verilog(self):
# verilog.convert(self.tb)
def test_to_verilog(self):
verilog.convert(self.tb)

def run_with(self, generator):
run_simulation(self.tb, generator)
21 changes: 20 additions & 1 deletion nmigen/tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from collections.abc import Iterable
import contextlib
import functools
import warnings
from collections.abc import Iterable
from contextlib import contextmanager


__all__ = ["flatten", "union", "log2_int", "bits_for", "deprecated"]
@@ -54,6 +56,23 @@ def wrapper(*args, **kwargs):
return decorator


def _ignore_deprecated(f=None):
if f is None:
@contextlib.contextmanager
def context_like():
with warnings.catch_warnings():
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
yield
return context_like()
else:
@functools.wraps(f)
def decorator_like(*args, **kwargs):
with warnings.catch_warnings():
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
f(*args, **kwargs)
return decorator_like


def extend(cls):
def decorator(f):
if isinstance(f, property):