self.clocks = OrderedDict()
self._ports = []
- self._tristates = []
- self._diffpairs = []
+ self._se_pins = []
+ self._dp_pins = []
self.add_resources(resources)
for name_number, frequency in clocks:
yield (value, subsignal.io[0], subsignal.extras)
for (pin, io, extras) in match_constraints(value, resource):
- if isinstance(io, DiffPairs):
- p = Signal(pin.width, name="{}_p".format(pin.name))
- n = Signal(pin.width, name="{}_n".format(pin.name))
- self._diffpairs.append((pin, p, n))
- self._ports.append((p, io.p.names, extras))
- self._ports.append((n, io.n.names, extras))
- elif isinstance(io, Pins):
- if pin.dir == "io":
- port = Signal(pin.width, name="{}_io".format(pin.name))
- self._tristates.append((pin, port))
- else:
- port = getattr(pin, pin.dir)
+ if isinstance(io, Pins):
+ port = Signal(pin.width, name="{}_io".format(pin.name))
+ self._se_pins.append((pin, port))
self._ports.append((port, io.names, extras))
+ elif isinstance(io, DiffPairs):
+ p_port = Signal(pin.width, name="{}_p".format(pin.name))
+ n_port = Signal(pin.width, name="{}_n".format(pin.name))
+ self._dp_pins.append((pin, p_port, n_port))
+ self._ports.append((p_port, io.p.names, extras))
+ self._ports.append((n_port, io.n.names, extras))
else:
assert False # :nocov:
raise ConstraintError("Cannot constrain frequency of resource {}#{} because "
"it has been requested as a tristate buffer"
.format(name, number))
- if isinstance(resource.io[0], DiffPairs):
+ if isinstance(resource.io[0], Pins):
+ port_name = "{}_io".format(pin.name)
+ elif isinstance(resource.io[0], DiffPairs):
port_name = "{}_p".format(pin.name)
else:
- port_name = getattr(pin, pin.dir).name
+ assert False
yield (port_name, period)
ports = list(self.cm.iter_ports())
self.assertEqual(len(ports), 1)
- self.assertIs(user_led.o, ports[0])
self.assertEqual(list(self.cm.iter_port_constraints()), [
- ("user_led_0__o", ["A0"], [])
+ ("user_led_0_io", ["A0"], [])
])
def test_request_with_dir(self):
ports = list(self.cm.iter_ports())
self.assertEqual(len(ports), 2)
- self.assertIs(i2c.scl.o, ports[0]),
+ scl, sda = ports
self.assertEqual(ports[1].name, "i2c_0__sda_io")
self.assertEqual(ports[1].nbits, 1)
- self.assertEqual(self.cm._tristates, [(i2c.sda, ports[1])])
+ self.assertEqual(self.cm._se_pins, [
+ (i2c.scl, scl),
+ (i2c.sda, sda),
+ ])
self.assertEqual(list(self.cm.iter_port_constraints()), [
- ("i2c_0__scl__o", ["N10"], []),
+ ("i2c_0__scl_io", ["N10"], []),
("i2c_0__sda_io", ["N11"], [])
])
self.assertEqual(n.name, "clk100_0_n")
self.assertEqual(n.nbits, clk100.width)
- self.assertEqual(self.cm._diffpairs, [(clk100, p, n)])
+ self.assertEqual(self.cm._dp_pins, [
+ (clk100, p, n),
+ ])
self.assertEqual(list(self.cm.iter_port_constraints()), [
("clk100_0_p", ["H1"], []),
("clk100_0_n", ["H2"], [])
clk50 = self.cm.request("clk50", 0, dir="i")
self.assertEqual(list(sorted(self.cm.iter_clock_constraints())), [
("clk100_0_p", 10e6),
- ("clk50_0__i", 5e6)
+ ("clk50_0_io", 5e6)
])
def test_wrong_resources(self):