lib.io: Add missing __repr__ to signature type.
This commit is contained in:
parent
8af9fe2606
commit
1dd2e6150c
|
@ -114,6 +114,10 @@ class Pin(wiring.PureInterface):
|
||||||
self.dir == other.dir and
|
self.dir == other.dir and
|
||||||
self.xdr == other.xdr)
|
self.xdr == other.xdr)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
xdr = f", xdr={self.xdr}" if self.xdr != 0 else ""
|
||||||
|
return f"Pin.Signature({self.width}, dir={self.dir!r}{xdr})"
|
||||||
|
|
||||||
def create(self, *, path=None, src_loc_at=0):
|
def create(self, *, path=None, src_loc_at=0):
|
||||||
return Pin(self.width, self.dir, xdr=self.xdr, path=path, src_loc_at=1 + src_loc_at)
|
return Pin(self.width, self.dir, xdr=self.xdr, path=path, src_loc_at=1 + src_loc_at)
|
||||||
|
|
||||||
|
@ -128,11 +132,11 @@ class Pin(wiring.PureInterface):
|
||||||
@property
|
@property
|
||||||
def width(self):
|
def width(self):
|
||||||
return self.signature.width
|
return self.signature.width
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dir(self):
|
def dir(self):
|
||||||
return self.signature.dir
|
return self.signature.dir
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def xdr(self):
|
def xdr(self):
|
||||||
return self.signature.xdr
|
return self.signature.xdr
|
||||||
|
|
|
@ -199,6 +199,16 @@ class PinSignatureDDRTestCase(PinSignatureTestCase):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class PinSignatureReprCase(FHDLTestCase):
|
||||||
|
def test_repr(self):
|
||||||
|
sig_0 = Pin.Signature(1, dir="i")
|
||||||
|
self.assertRepr(sig_0, "Pin.Signature(1, dir='i')")
|
||||||
|
sig_0 = Pin.Signature(2, dir="o", xdr=1)
|
||||||
|
self.assertRepr(sig_0, "Pin.Signature(2, dir='o', xdr=1)")
|
||||||
|
sig_0 = Pin.Signature(3, dir="io", xdr=2)
|
||||||
|
self.assertRepr(sig_0, "Pin.Signature(3, dir='io', xdr=2)")
|
||||||
|
|
||||||
|
|
||||||
class PinTestCase(FHDLTestCase):
|
class PinTestCase(FHDLTestCase):
|
||||||
def test_attributes(self):
|
def test_attributes(self):
|
||||||
pin = Pin(2, dir="io", xdr=2)
|
pin = Pin(2, dir="io", xdr=2)
|
||||||
|
@ -208,4 +218,3 @@ class PinTestCase(FHDLTestCase):
|
||||||
self.assertEqual(pin.signature.width, 2)
|
self.assertEqual(pin.signature.width, 2)
|
||||||
self.assertEqual(pin.signature.dir, "io")
|
self.assertEqual(pin.signature.dir, "io")
|
||||||
self.assertEqual(pin.signature.xdr, 2)
|
self.assertEqual(pin.signature.xdr, 2)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue