上传文件至「tests」
This commit is contained in:
@@ -773,6 +773,198 @@ class EdaRouterPinsContractTest(unittest.TestCase):
|
||||
lstarts = [call[1]["Lstart"] for call in FakeRoute.calls if call[0] == "sbend_p2p"]
|
||||
self.assertEqual(lstarts, [200.0, 150.0, 100.0, 50.0])
|
||||
|
||||
def test_ubend_spacing_uses_inner_shorter_outer_longer_length_within_bundle(self):
|
||||
from mxpic_router.builder import _route_bundle_links
|
||||
from mxpic_router.eda_loader import LinkSpec
|
||||
|
||||
class FakePin:
|
||||
def __init__(self, x, y, angle):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.a = angle
|
||||
|
||||
class FakeRoute:
|
||||
calls = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def ubend_p2p(self, **kwargs):
|
||||
self.calls.append(("ubend_p2p", kwargs))
|
||||
return self
|
||||
|
||||
def put(self):
|
||||
self.calls.append(("put", {}))
|
||||
|
||||
FakeRoute.calls = []
|
||||
links = [
|
||||
LinkSpec(src_inst="r1", src_pin="out", dst_inst="p1", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="r2", src_pin="out", dst_inst="p2", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="r3", src_pin="out", dst_inst="p3", dst_pin="in", width=40, radius=10),
|
||||
]
|
||||
pin_map = {
|
||||
("r1", "out"): FakePin(0, 40, 0),
|
||||
("p1", "in"): FakePin(100, 40, 0),
|
||||
("r2", "out"): FakePin(0, 30, 0),
|
||||
("p2", "in"): FakePin(100, 30, 0),
|
||||
("r3", "out"): FakePin(0, 20, 0),
|
||||
("p3", "in"): FakePin(100, 20, 0),
|
||||
}
|
||||
|
||||
warnings = []
|
||||
_route_bundle_links(links, pin_map, FakeRoute, warnings)
|
||||
|
||||
calls = [call[1] for call in FakeRoute.calls if call[0] == "ubend_p2p"]
|
||||
self.assertEqual([call["length"] for call in calls], [100.0, 50.0, 100.0])
|
||||
self.assertTrue(all("Lstart" not in call for call in calls))
|
||||
self.assertTrue(any("Applied ubend length 50um" in warning for warning in warnings))
|
||||
|
||||
def test_ubend_spacing_uses_symmetric_nested_lengths_for_even_group(self):
|
||||
from mxpic_router.builder import _route_bundle_links
|
||||
from mxpic_router.eda_loader import LinkSpec
|
||||
|
||||
class FakePin:
|
||||
def __init__(self, x, y, angle):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.a = angle
|
||||
|
||||
class FakeRoute:
|
||||
calls = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def ubend_p2p(self, **kwargs):
|
||||
self.calls.append(("ubend_p2p", kwargs))
|
||||
return self
|
||||
|
||||
def put(self):
|
||||
self.calls.append(("put", {}))
|
||||
|
||||
FakeRoute.calls = []
|
||||
links = [
|
||||
LinkSpec(src_inst="r1", src_pin="out", dst_inst="p1", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="r2", src_pin="out", dst_inst="p2", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="r3", src_pin="out", dst_inst="p3", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="r4", src_pin="out", dst_inst="p4", dst_pin="in", width=40, radius=10),
|
||||
]
|
||||
pin_map = {
|
||||
("r1", "out"): FakePin(0, 40, 0),
|
||||
("p1", "in"): FakePin(100, 40, 0),
|
||||
("r2", "out"): FakePin(0, 30, 0),
|
||||
("p2", "in"): FakePin(100, 30, 0),
|
||||
("r3", "out"): FakePin(0, 20, 0),
|
||||
("p3", "in"): FakePin(100, 20, 0),
|
||||
("r4", "out"): FakePin(0, 10, 0),
|
||||
("p4", "in"): FakePin(100, 10, 0),
|
||||
}
|
||||
|
||||
_route_bundle_links(links, pin_map, FakeRoute, [])
|
||||
|
||||
calls = [call[1] for call in FakeRoute.calls if call[0] == "ubend_p2p"]
|
||||
self.assertEqual([call["length"] for call in calls], [100.0, 50.0, 50.0, 100.0])
|
||||
|
||||
def test_ubend_spacing_uses_route_span_for_reversed_port_order(self):
|
||||
from mxpic_router.builder import _route_bundle_links
|
||||
from mxpic_router.eda_loader import LinkSpec
|
||||
|
||||
class FakePin:
|
||||
def __init__(self, x, y, angle):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.a = angle
|
||||
|
||||
class FakeRoute:
|
||||
calls = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def ubend_p2p(self, **kwargs):
|
||||
self.calls.append(("ubend_p2p", kwargs))
|
||||
return self
|
||||
|
||||
def put(self):
|
||||
self.calls.append(("put", {}))
|
||||
|
||||
FakeRoute.calls = []
|
||||
links = [
|
||||
LinkSpec(src_inst="port_3", src_pin="io1", dst_inst="port_4", dst_pin="io4", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_3", src_pin="io2", dst_inst="port_4", dst_pin="io3", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_3", src_pin="io3", dst_inst="port_4", dst_pin="io2", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_3", src_pin="io4", dst_inst="port_4", dst_pin="io1", width=0.5, radius=10),
|
||||
]
|
||||
pin_map = {
|
||||
("port_3", "io1"): FakePin(1772.6, -2515.2, 0),
|
||||
("port_3", "io2"): FakePin(1772.6, -2525.2, 0),
|
||||
("port_3", "io3"): FakePin(1772.6, -2535.2, 0),
|
||||
("port_3", "io4"): FakePin(1772.6, -2545.2, 0),
|
||||
("port_4", "io1"): FakePin(1771.3, -2399.9, 0),
|
||||
("port_4", "io2"): FakePin(1771.3, -2409.9, 0),
|
||||
("port_4", "io3"): FakePin(1771.3, -2419.9, 0),
|
||||
("port_4", "io4"): FakePin(1771.3, -2429.9, 0),
|
||||
}
|
||||
|
||||
_route_bundle_links(links, pin_map, FakeRoute, [])
|
||||
|
||||
calls = [call[1] for call in FakeRoute.calls if call[0] == "ubend_p2p"]
|
||||
self.assertEqual([call["length"] for call in calls], [10.5, 21.0, 31.5, 42.0])
|
||||
|
||||
def test_mixed_sbend_and_ubend_spacing_share_route_ranks(self):
|
||||
from mxpic_router.builder import _route_bundle_links
|
||||
from mxpic_router.eda_loader import LinkSpec
|
||||
|
||||
class FakePin:
|
||||
def __init__(self, x, y, angle):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.a = angle
|
||||
|
||||
class FakeRoute:
|
||||
calls = []
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def sbend_p2p(self, **kwargs):
|
||||
self.calls.append(("sbend_p2p", kwargs))
|
||||
return self
|
||||
|
||||
def ubend_p2p(self, **kwargs):
|
||||
self.calls.append(("ubend_p2p", kwargs))
|
||||
return self
|
||||
|
||||
def put(self):
|
||||
self.calls.append(("put", {}))
|
||||
|
||||
FakeRoute.calls = []
|
||||
links = [
|
||||
LinkSpec(src_inst="port_7", src_pin="io2", dst_inst="port_5", dst_pin="io1", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_7", src_pin="io1", dst_inst="port_5", dst_pin="io2", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_6", src_pin="io2", dst_inst="port_5", dst_pin="io3", width=0.5, radius=10),
|
||||
LinkSpec(src_inst="port_6", src_pin="io1", dst_inst="port_5", dst_pin="io4", width=0.5, radius=10),
|
||||
]
|
||||
pin_map = {
|
||||
("port_7", "io2"): FakePin(2071.8, -2464.4, 0),
|
||||
("port_7", "io1"): FakePin(2071.8, -2454.4, 0),
|
||||
("port_6", "io2"): FakePin(2173.4, -2405.6, 180),
|
||||
("port_6", "io1"): FakePin(2173.4, -2415.6, 180),
|
||||
("port_5", "io1"): FakePin(2074.2, -2513.1, 0),
|
||||
("port_5", "io2"): FakePin(2074.2, -2523.1, 0),
|
||||
("port_5", "io3"): FakePin(2074.2, -2533.1, 0),
|
||||
("port_5", "io4"): FakePin(2074.2, -2543.1, 0),
|
||||
}
|
||||
|
||||
_route_bundle_links(links, pin_map, FakeRoute, [])
|
||||
|
||||
calls = [(name, call) for name, call in FakeRoute.calls if name in {"sbend_p2p", "ubend_p2p"}]
|
||||
ubend_lengths = [call["length"] for name, call in calls if name == "ubend_p2p"]
|
||||
sbend_lstarts = [call["Lstart"] for name, call in calls if name == "sbend_p2p"]
|
||||
self.assertEqual(ubend_lengths, [10.5, 21.0])
|
||||
self.assertTrue(max(ubend_lengths) < min(sbend_lstarts))
|
||||
self.assertEqual(sbend_lstarts, [63.0, 73.5])
|
||||
|
||||
def test_route_backend_falls_back_to_nazca_interconnect_when_forge_is_absent(self):
|
||||
import mxpic_router.builder as builder
|
||||
|
||||
|
||||
Reference in New Issue
Block a user