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: c9c9307a5e6c
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: a74cacdc69af
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Apr 3, 2019

  1. Copy the full SHA
    a74cacd View commit details
Showing with 8 additions and 0 deletions.
  1. +2 −0 nmigen/hdl/ast.py
  2. +6 −0 nmigen/test/test_hdl_ast.py
2 changes: 2 additions & 0 deletions nmigen/hdl/ast.py
Original file line number Diff line number Diff line change
@@ -581,6 +581,8 @@ def __init__(self, shape=None, name=None, reset=0, reset_less=False, min=None, m
attrs=None, decoder=None, src_loc_at=0):
super().__init__(src_loc_at=src_loc_at)

if name is not None and not isinstance(name, str):
raise TypeError("Name must be a string, not '{!r}'".format(name))
self.name = name or tracer.get_var_name(depth=2 + src_loc_at, default="$signal")

if shape is None:
6 changes: 6 additions & 0 deletions nmigen/test/test_hdl_ast.py
Original file line number Diff line number Diff line change
@@ -429,6 +429,12 @@ def test_name(self):
s2 = Signal(name="sig")
self.assertEqual(s2.name, "sig")

def test_name_bad(self):
with self.assertRaises(TypeError,
msg="Name must be a string, not 'True'"):
# A common typo: forgetting to put parens around width and signedness
Signal(1, True)

def test_reset(self):
s1 = Signal(4, reset=0b111, reset_less=True)
self.assertEqual(s1.reset, 0b111)