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: 9458de207927
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: 751ae33fe1a9
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 3, 2019

  1. build.dsl: accept Pins(invert=True).

    The PinsN() form is still preferred, but Pins(invert=) form is useful
    for code generic over pin polarity.
    whitequark committed Oct 3, 2019
    Copy the full SHA
    751ae33 View commit details
Showing with 6 additions and 2 deletions.
  1. +2 −2 nmigen/build/dsl.py
  2. +4 −0 nmigen/test/test_build_dsl.py
4 changes: 2 additions & 2 deletions nmigen/build/dsl.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@


class Pins:
def __init__(self, names, *, dir="io", conn=None, assert_width=None):
def __init__(self, names, *, dir="io", invert=False, conn=None, assert_width=None):
if not isinstance(names, str):
raise TypeError("Names must be a whitespace-separated string, not {!r}"
.format(names))
@@ -29,7 +29,7 @@ def __init__(self, names, *, dir="io", conn=None, assert_width=None):

self.names = names
self.dir = dir
self.invert = False
self.invert = bool(invert)

def __len__(self):
return len(self.names)
4 changes: 4 additions & 0 deletions nmigen/test/test_build_dsl.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,10 @@ def test_invert(self):
self.assertEqual(repr(p), "(pins-n io A0)")
self.assertEqual(p.invert, True)

def test_invert_arg(self):
p = Pins("A0", invert=True)
self.assertEqual(p.invert, True)

def test_conn(self):
p = Pins("0 1 2", conn=("pmod", 0))
self.assertEqual(list(p), ["pmod_0:0", "pmod_0:1", "pmod_0:2"])