from .dsl import Pins, DiffPairs, Subsignal, Resource, Connector
+from .res import ConstraintError
from .plat import Platform, TemplatedPlatform
def add_clock(self, name, number, frequency):
resource = self.lookup(name, number)
if isinstance(resource.io[0], Subsignal):
- raise ConstraintError("Cannot constrain frequency of resource {}#{} because it has "
- "subsignals"
- .format(resource.name, resource.number, frequency))
+ raise TypeError("Cannot constrain frequency of resource {}#{} because it has "
+ "subsignals"
+ .format(resource.name, resource.number, frequency))
if (resource.name, resource.number) in self.clocks:
other = self.clocks[resource.name, resource.number]
raise ConstraintError("Resource {}#{} is already constrained to a frequency of "
def lookup(self, name, number=0):
if (name, number) not in self.resources:
- raise NameError("Resource {}#{} does not exist"
- .format(name, number))
+ raise ConstraintError("Resource {}#{} does not exist"
+ .format(name, number))
return self.resources[name, number]
def request(self, name, number=0, *, dir=None, xdr=None):
self.cm.add_connectors([Connector("pmod", 0, "1 2")])
def test_wrong_lookup(self):
- with self.assertRaises(NameError,
+ with self.assertRaises(ConstraintError,
msg="Resource user_led#1 does not exist"):
r = self.cm.lookup("user_led", 1)
def test_wrong_frequency_subsignals(self):
- with self.assertRaises(ConstraintError,
+ with self.assertRaises(TypeError,
msg="Cannot constrain frequency of resource i2c#0 because "
"it has subsignals"):
self.cm.add_clock("i2c", 0, 10e6)