上传文件至「tests」
This commit is contained in:
@@ -104,6 +104,15 @@ class EdaRouterPinsContractTest(unittest.TestCase):
|
||||
"stage_1",
|
||||
)
|
||||
|
||||
def test_route_pcb_flag_uses_electrical_family(self):
|
||||
from mxpic_router.builder import _route_pcb_enabled
|
||||
from mxpic_router.eda_loader import LinkSpec
|
||||
|
||||
self.assertTrue(_route_pcb_enabled(LinkSpec(xsection="custom_metal_top", family="electrical")))
|
||||
self.assertTrue(_route_pcb_enabled(LinkSpec(xsection="strip", family="Electrical")))
|
||||
self.assertFalse(_route_pcb_enabled(LinkSpec(xsection="metal_1", family="optical")))
|
||||
self.assertFalse(_route_pcb_enabled(LinkSpec(xsection="metal_2", family="")))
|
||||
|
||||
def test_port_element_creates_named_io_pins_and_inside_route_pins(self):
|
||||
from mxpic_router.builder import _register_element_pins
|
||||
from mxpic_router.eda_loader import parse_cell_dict
|
||||
@@ -674,6 +683,96 @@ class EdaRouterPinsContractTest(unittest.TestCase):
|
||||
self.assertEqual(lstarts[:4], [50.0, 100.0, 150.0, 200.0])
|
||||
self.assertEqual(lstarts[4:], [150.0, 200.0, 100.0, 50.0])
|
||||
|
||||
def test_automatic_routes_are_ordered_from_lower_x_to_higher_x(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 put(self):
|
||||
self.calls.append(("put", {}))
|
||||
|
||||
FakeRoute.calls = []
|
||||
links = [
|
||||
LinkSpec(src_inst="left_top", src_pin="out", dst_inst="right_top", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="right_mid", src_pin="out", dst_inst="left_mid", dst_pin="in", width=40, radius=10),
|
||||
LinkSpec(src_inst="left_bot", src_pin="out", dst_inst="right_bot", dst_pin="in", width=40, radius=10),
|
||||
]
|
||||
pin_map = {
|
||||
("left_top", "out"): FakePin(0, 40, 0),
|
||||
("right_top", "in"): FakePin(100, 10, 180),
|
||||
("right_mid", "out"): FakePin(100, 0, 180),
|
||||
("left_mid", "in"): FakePin(0, 30, 0),
|
||||
("left_bot", "out"): FakePin(0, 20, 0),
|
||||
("right_bot", "in"): FakePin(100, -10, 180),
|
||||
}
|
||||
|
||||
_route_bundle_links(links, pin_map, FakeRoute, [])
|
||||
|
||||
calls = [call[1] for call in FakeRoute.calls if call[0] == "sbend_p2p"]
|
||||
self.assertTrue(all(call["pin1"].x <= call["pin2"].x for call in calls))
|
||||
self.assertEqual([call["Lstart"] for call in calls], [150.0, 100.0, 50.0])
|
||||
|
||||
def test_sbend_lstart_spacing_keeps_nearby_span_bucket_boundary_routes_together(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 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(2090.95, -1968.2, 0),
|
||||
("p1", "in"): FakePin(2651.75, -2090.5, 180),
|
||||
("r2", "out"): FakePin(2087.15, -2073.9, 0),
|
||||
("p2", "in"): FakePin(2653.25, -2201.4, 180),
|
||||
("r3", "out"): FakePin(2086.55, -2190.0, 0),
|
||||
("p3", "in"): FakePin(2647.45, -2312.3, 180),
|
||||
("r4", "out"): FakePin(2085.85, -2285.2, 0),
|
||||
("p4", "in"): FakePin(2649.45, -2411.1, 180),
|
||||
}
|
||||
|
||||
_route_bundle_links(links, pin_map, FakeRoute, [])
|
||||
|
||||
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_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