build.dsl: add conn argument to Connector.
This commit is contained in:
parent
84f2c3df2b
commit
8e048c5a7c
3 changed files with 49 additions and 4 deletions
|
|
@ -278,6 +278,19 @@ class ConnectorTestCase(FHDLTestCase):
|
|||
("DP1", "A1"),
|
||||
]))
|
||||
|
||||
def test_conn(self):
|
||||
c = Connector("pmod", 0, "0 1 2 3 - - 4 5 6 7 - -", conn=("expansion", 0))
|
||||
self.assertEqual(c.mapping, OrderedDict([
|
||||
("1", "expansion_0:0"),
|
||||
("2", "expansion_0:1"),
|
||||
("3", "expansion_0:2"),
|
||||
("4", "expansion_0:3"),
|
||||
("7", "expansion_0:4"),
|
||||
("8", "expansion_0:5"),
|
||||
("9", "expansion_0:6"),
|
||||
("10", "expansion_0:7"),
|
||||
]))
|
||||
|
||||
def test_wrong_io(self):
|
||||
with self.assertRaises(TypeError,
|
||||
msg="Connector I/Os must be a dictionary or a string, not []"):
|
||||
|
|
|
|||
|
|
@ -168,6 +168,27 @@ class ResourceManagerTestCase(FHDLTestCase):
|
|||
("spi_0__mosi__io", ["B3"], {}),
|
||||
])
|
||||
|
||||
def test_request_via_nested_connector(self):
|
||||
new_connectors = [
|
||||
Connector("pmod_extension", 0, "1 2 3 4 - -", conn=("pmod", 0)),
|
||||
]
|
||||
self.cm.add_connectors(new_connectors)
|
||||
self.cm.add_resources([
|
||||
Resource("spi", 0,
|
||||
Subsignal("ss", Pins("1", conn=("pmod_extension", 0))),
|
||||
Subsignal("clk", Pins("2", conn=("pmod_extension", 0))),
|
||||
Subsignal("miso", Pins("3", conn=("pmod_extension", 0))),
|
||||
Subsignal("mosi", Pins("4", conn=("pmod_extension", 0))),
|
||||
)
|
||||
])
|
||||
spi0 = self.cm.request("spi", 0)
|
||||
self.assertEqual(list(self.cm.iter_port_constraints()), [
|
||||
("spi_0__ss__io", ["B0"], {}),
|
||||
("spi_0__clk__io", ["B1"], {}),
|
||||
("spi_0__miso__io", ["B2"], {}),
|
||||
("spi_0__mosi__io", ["B3"], {}),
|
||||
])
|
||||
|
||||
def test_request_clock(self):
|
||||
clk100 = self.cm.request("clk100", 0)
|
||||
clk50 = self.cm.request("clk50", 0, dir="i")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue