hdl.ast: remove Shape<>tuple comparisons.
See #691.
I missed this in commit 29502442
.
This commit is contained in:
parent
f133646e9b
commit
7044e09110
|
@ -116,15 +116,6 @@ class Shape:
|
||||||
return "unsigned({})".format(self.width)
|
return "unsigned({})".format(self.width)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
# TODO(nmigen-0.4): remove
|
|
||||||
if isinstance(other, tuple) and len(other) == 2:
|
|
||||||
width, signed = other
|
|
||||||
if isinstance(width, int) and isinstance(signed, bool):
|
|
||||||
return self.width == width and self.signed == signed
|
|
||||||
else:
|
|
||||||
raise TypeError("Shapes may be compared with other Shapes and (int, bool) tuples, "
|
|
||||||
"not {!r}"
|
|
||||||
.format(other))
|
|
||||||
if not isinstance(other, Shape):
|
if not isinstance(other, Shape):
|
||||||
try:
|
try:
|
||||||
other = self.__class__.cast(other)
|
other = self.__class__.cast(other)
|
||||||
|
|
|
@ -53,8 +53,7 @@ class ShapeTestCase(FHDLTestCase):
|
||||||
|
|
||||||
def test_compare_tuple_wrong(self):
|
def test_compare_tuple_wrong(self):
|
||||||
with self.assertRaisesRegex(TypeError,
|
with self.assertRaisesRegex(TypeError,
|
||||||
r"^Shapes may be compared with other Shapes and \(int, bool\) tuples, "
|
r"^Shapes may be compared with shape-castable objects, not \(2, 3\)$"):
|
||||||
r"not \(2, 3\)$"):
|
|
||||||
Shape(1, True) == (2, 3)
|
Shape(1, True) == (2, 3)
|
||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
|
|
|
@ -30,28 +30,28 @@ class LayoutTestCase(FHDLTestCase):
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
self.assertFieldEqual(layout["cyc"], ((1, False), DIR_NONE))
|
self.assertFieldEqual(layout["cyc"], (unsigned(1), DIR_NONE))
|
||||||
self.assertFieldEqual(layout["data"], ((32, True), DIR_NONE))
|
self.assertFieldEqual(layout["data"], (signed(32), DIR_NONE))
|
||||||
self.assertFieldEqual(layout["stb"], ((1, False), DIR_FANOUT))
|
self.assertFieldEqual(layout["stb"], (unsigned(1), DIR_FANOUT))
|
||||||
self.assertFieldEqual(layout["ack"], ((1, False), DIR_FANIN))
|
self.assertFieldEqual(layout["ack"], (unsigned(1), DIR_FANIN))
|
||||||
sublayout = layout["info"][0]
|
sublayout = layout["info"][0]
|
||||||
self.assertEqual(layout["info"][1], DIR_NONE)
|
self.assertEqual(layout["info"][1], DIR_NONE)
|
||||||
self.assertFieldEqual(sublayout["a"], ((1, False), DIR_NONE))
|
self.assertFieldEqual(sublayout["a"], (unsigned(1), DIR_NONE))
|
||||||
self.assertFieldEqual(sublayout["b"], ((1, False), DIR_NONE))
|
self.assertFieldEqual(sublayout["b"], (unsigned(1), DIR_NONE))
|
||||||
|
|
||||||
def test_enum_field(self):
|
def test_enum_field(self):
|
||||||
layout = Layout.cast([
|
layout = Layout.cast([
|
||||||
("enum", UnsignedEnum),
|
("enum", UnsignedEnum),
|
||||||
("enum_dir", UnsignedEnum, DIR_FANOUT),
|
("enum_dir", UnsignedEnum, DIR_FANOUT),
|
||||||
])
|
])
|
||||||
self.assertFieldEqual(layout["enum"], ((2, False), DIR_NONE))
|
self.assertFieldEqual(layout["enum"], (unsigned(2), DIR_NONE))
|
||||||
self.assertFieldEqual(layout["enum_dir"], ((2, False), DIR_FANOUT))
|
self.assertFieldEqual(layout["enum_dir"], (unsigned(2), DIR_FANOUT))
|
||||||
|
|
||||||
def test_range_field(self):
|
def test_range_field(self):
|
||||||
layout = Layout.cast([
|
layout = Layout.cast([
|
||||||
("range", range(0, 7)),
|
("range", range(0, 7)),
|
||||||
])
|
])
|
||||||
self.assertFieldEqual(layout["range"], ((3, False), DIR_NONE))
|
self.assertFieldEqual(layout["range"], (unsigned(3), DIR_NONE))
|
||||||
|
|
||||||
def test_slice_tuple(self):
|
def test_slice_tuple(self):
|
||||||
layout = Layout.cast([
|
layout = Layout.cast([
|
||||||
|
|
|
@ -19,51 +19,51 @@ class PinLayoutCombTestCase(PinLayoutTestCase):
|
||||||
def test_pin_layout_i(self):
|
def test_pin_layout_i(self):
|
||||||
layout_1 = pin_layout(1, dir="i")
|
layout_1 = pin_layout(1, dir="i")
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i": ((1, False), DIR_NONE),
|
"i": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="i")
|
layout_2 = pin_layout(2, dir="i")
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i": ((2, False), DIR_NONE),
|
"i": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_o(self):
|
def test_pin_layout_o(self):
|
||||||
layout_1 = pin_layout(1, dir="o")
|
layout_1 = pin_layout(1, dir="o")
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="o")
|
layout_2 = pin_layout(2, dir="o")
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_oe(self):
|
def test_pin_layout_oe(self):
|
||||||
layout_1 = pin_layout(1, dir="oe")
|
layout_1 = pin_layout(1, dir="oe")
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="oe")
|
layout_2 = pin_layout(2, dir="oe")
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_io(self):
|
def test_pin_layout_io(self):
|
||||||
layout_1 = pin_layout(1, dir="io")
|
layout_1 = pin_layout(1, dir="io")
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i": ((1, False), DIR_NONE),
|
"i": (unsigned(1), DIR_NONE),
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="io")
|
layout_2 = pin_layout(2, dir="io")
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i": ((2, False), DIR_NONE),
|
"i": (unsigned(2), DIR_NONE),
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,61 +71,61 @@ class PinLayoutSDRTestCase(PinLayoutTestCase):
|
||||||
def test_pin_layout_i(self):
|
def test_pin_layout_i(self):
|
||||||
layout_1 = pin_layout(1, dir="i", xdr=1)
|
layout_1 = pin_layout(1, dir="i", xdr=1)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i": ((1, False), DIR_NONE),
|
"i": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="i", xdr=1)
|
layout_2 = pin_layout(2, dir="i", xdr=1)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i": ((2, False), DIR_NONE),
|
"i": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_o(self):
|
def test_pin_layout_o(self):
|
||||||
layout_1 = pin_layout(1, dir="o", xdr=1)
|
layout_1 = pin_layout(1, dir="o", xdr=1)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="o", xdr=1)
|
layout_2 = pin_layout(2, dir="o", xdr=1)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_oe(self):
|
def test_pin_layout_oe(self):
|
||||||
layout_1 = pin_layout(1, dir="oe", xdr=1)
|
layout_1 = pin_layout(1, dir="oe", xdr=1)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="oe", xdr=1)
|
layout_2 = pin_layout(2, dir="oe", xdr=1)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_io(self):
|
def test_pin_layout_io(self):
|
||||||
layout_1 = pin_layout(1, dir="io", xdr=1)
|
layout_1 = pin_layout(1, dir="io", xdr=1)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i": ((1, False), DIR_NONE),
|
"i": (unsigned(1), DIR_NONE),
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((1, False), DIR_NONE),
|
"o": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="io", xdr=1)
|
layout_2 = pin_layout(2, dir="io", xdr=1)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i": ((2, False), DIR_NONE),
|
"i": (unsigned(2), DIR_NONE),
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o": ((2, False), DIR_NONE),
|
"o": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,71 +133,71 @@ class PinLayoutDDRTestCase(PinLayoutTestCase):
|
||||||
def test_pin_layout_i(self):
|
def test_pin_layout_i(self):
|
||||||
layout_1 = pin_layout(1, dir="i", xdr=2)
|
layout_1 = pin_layout(1, dir="i", xdr=2)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i0": ((1, False), DIR_NONE),
|
"i0": (unsigned(1), DIR_NONE),
|
||||||
"i1": ((1, False), DIR_NONE),
|
"i1": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="i", xdr=2)
|
layout_2 = pin_layout(2, dir="i", xdr=2)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i0": ((2, False), DIR_NONE),
|
"i0": (unsigned(2), DIR_NONE),
|
||||||
"i1": ((2, False), DIR_NONE),
|
"i1": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_o(self):
|
def test_pin_layout_o(self):
|
||||||
layout_1 = pin_layout(1, dir="o", xdr=2)
|
layout_1 = pin_layout(1, dir="o", xdr=2)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((1, False), DIR_NONE),
|
"o0": (unsigned(1), DIR_NONE),
|
||||||
"o1": ((1, False), DIR_NONE),
|
"o1": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="o", xdr=2)
|
layout_2 = pin_layout(2, dir="o", xdr=2)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((2, False), DIR_NONE),
|
"o0": (unsigned(2), DIR_NONE),
|
||||||
"o1": ((2, False), DIR_NONE),
|
"o1": (unsigned(2), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_oe(self):
|
def test_pin_layout_oe(self):
|
||||||
layout_1 = pin_layout(1, dir="oe", xdr=2)
|
layout_1 = pin_layout(1, dir="oe", xdr=2)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((1, False), DIR_NONE),
|
"o0": (unsigned(1), DIR_NONE),
|
||||||
"o1": ((1, False), DIR_NONE),
|
"o1": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="oe", xdr=2)
|
layout_2 = pin_layout(2, dir="oe", xdr=2)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((2, False), DIR_NONE),
|
"o0": (unsigned(2), DIR_NONE),
|
||||||
"o1": ((2, False), DIR_NONE),
|
"o1": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_pin_layout_io(self):
|
def test_pin_layout_io(self):
|
||||||
layout_1 = pin_layout(1, dir="io", xdr=2)
|
layout_1 = pin_layout(1, dir="io", xdr=2)
|
||||||
self.assertLayoutEqual(layout_1.fields, {
|
self.assertLayoutEqual(layout_1.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i0": ((1, False), DIR_NONE),
|
"i0": (unsigned(1), DIR_NONE),
|
||||||
"i1": ((1, False), DIR_NONE),
|
"i1": (unsigned(1), DIR_NONE),
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((1, False), DIR_NONE),
|
"o0": (unsigned(1), DIR_NONE),
|
||||||
"o1": ((1, False), DIR_NONE),
|
"o1": (unsigned(1), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
layout_2 = pin_layout(2, dir="io", xdr=2)
|
layout_2 = pin_layout(2, dir="io", xdr=2)
|
||||||
self.assertLayoutEqual(layout_2.fields, {
|
self.assertLayoutEqual(layout_2.fields, {
|
||||||
"i_clk": ((1, False), DIR_NONE),
|
"i_clk": (unsigned(1), DIR_NONE),
|
||||||
"i0": ((2, False), DIR_NONE),
|
"i0": (unsigned(2), DIR_NONE),
|
||||||
"i1": ((2, False), DIR_NONE),
|
"i1": (unsigned(2), DIR_NONE),
|
||||||
"o_clk": ((1, False), DIR_NONE),
|
"o_clk": (unsigned(1), DIR_NONE),
|
||||||
"o0": ((2, False), DIR_NONE),
|
"o0": (unsigned(2), DIR_NONE),
|
||||||
"o1": ((2, False), DIR_NONE),
|
"o1": (unsigned(2), DIR_NONE),
|
||||||
"oe": ((1, False), DIR_NONE),
|
"oe": (unsigned(1), DIR_NONE),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue