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: amaranth-lang/amaranth
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7e2b72826fbf
Choose a base ref
...
head repository: amaranth-lang/amaranth
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7c161957bfe3
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Dec 11, 2021

  1. Copy the full SHA
    7c16195 View commit details
Showing with 10 additions and 1 deletion.
  1. +4 −1 amaranth/build/dsl.py
  2. +6 −0 tests/test_build_dsl.py
5 changes: 4 additions & 1 deletion amaranth/build/dsl.py
Original file line number Diff line number Diff line change
@@ -197,8 +197,11 @@ def family(cls, name_or_number, number=None, *, ios, default_name, name_suffix="
return cls(name_or_number + name_suffix, number, *ios)

def __init__(self, name, number, *args):
super().__init__(name, *args)
if not isinstance(number, int):
raise TypeError("Resource number must be an integer, not {!r}"
.format(number))

super().__init__(name, *args)
self.number = number

def __repr__(self):
6 changes: 6 additions & 0 deletions tests/test_build_dsl.py
Original file line number Diff line number Diff line change
@@ -242,6 +242,12 @@ def test_basic(self):
" (subsignal rx (pins i A1))"
" (attrs IOSTANDARD='LVCMOS33'))")

def test_number_wrong(self):
with self.assertRaisesRegex(TypeError,
r"^Resource number must be an integer, not \(pins o 1\)$"):
# number omitted by accident
Resource("led", Pins("1", dir="o"))

def test_family(self):
ios = [Subsignal("clk", Pins("A0", dir="o"))]
r1 = Resource.family(0, default_name="spi", ios=ios)