|
1 | 1 | # SPDX-License-Identifier: BSD-2-Clause |
2 | 2 | import unittest |
3 | 3 |
|
4 | | -from chipflow_lib.platforms._ import ( |
5 | | - BareDiePackageDef, QuadPackageDef, Package, GAPackageDef, GALayout, GAPin |
| 4 | +from chipflow_lib.platforms import ( |
| 5 | + BareDiePackageDef, QuadPackageDef, GAPackageDef |
6 | 6 | ) |
7 | 7 |
|
8 | 8 |
|
@@ -74,56 +74,11 @@ def test_bringup_pins(self): |
74 | 74 | self.assertIsNotNone(jtag.tdo) |
75 | 75 |
|
76 | 76 |
|
77 | | -class TestPackage(unittest.TestCase): |
78 | | - def setUp(self): |
79 | | - self.package_def = BareDiePackageDef(name="test_package", width=8, height=4) |
80 | | - self.package = Package(type=self.package_def) |
81 | | - |
82 | | - def test_package_initialization(self): |
83 | | - """Test basic package initialization""" |
84 | | - self.assertIsNotNone(self.package.type) |
85 | | - self.assertEqual(self.package.type.name, "test_package") |
86 | | - self.assertEqual(self.package.type.width, 8) |
87 | | - self.assertEqual(self.package.type.height, 4) |
88 | | - |
89 | | - def test_package_type_access(self): |
90 | | - """Test accessing package type properties through Package""" |
91 | | - # Should be able to access package type bringup pins |
92 | | - bringup_pins = self.package.type.bringup_pins |
93 | | - self.assertIsNotNone(bringup_pins) |
94 | | - |
95 | | - # Test package discriminator |
96 | | - self.assertEqual(self.package.type.package_type, "BareDiePackageDef") |
97 | | - |
98 | | - |
99 | 77 | class TestGAPackage(unittest.TestCase): |
100 | | - def test_gapin_creation(self): |
101 | | - """Test GAPin creation and equality""" |
102 | | - pin1 = GAPin(h="A", w=1) |
103 | | - pin2 = GAPin(h="A", w=1) |
104 | | - pin3 = GAPin(h="B", w=2) |
105 | | - |
106 | | - # Test equality |
107 | | - self.assertEqual(pin1, pin2) |
108 | | - self.assertNotEqual(pin1, pin3) |
109 | | - |
110 | | - # Test attributes |
111 | | - self.assertEqual(pin1.h, "A") |
112 | | - self.assertEqual(pin1.w, 1) |
113 | | - self.assertEqual(pin3.h, "B") |
114 | | - self.assertEqual(pin3.w, 2) |
115 | | - |
116 | | - def test_galayout_enum_values(self): |
117 | | - """Test GALayout enum values""" |
118 | | - self.assertEqual(GALayout.FULL, "full") |
119 | | - self.assertEqual(GALayout.PERIMETER, "perimeter") |
120 | | - self.assertEqual(GALayout.CHANNEL, "channel") |
121 | | - self.assertEqual(GALayout.ISLAND, "island") |
122 | | - |
123 | 78 | def test_gapackagedef_class_structure(self): |
124 | 79 | """Test GAPackageDef class structure and type""" |
125 | 80 | # Test that we can import and access the class |
126 | | - from chipflow_lib.platforms._ import BasePackageDef |
| 81 | + from chipflow_lib.platforms._utils import BasePackageDef |
127 | 82 |
|
128 | 83 | # Test that GAPackageDef inherits from BasePackageDef |
129 | 84 | self.assertTrue(issubclass(GAPackageDef, BasePackageDef)) |
@@ -155,90 +110,15 @@ def test_gapackagedef_pydantic_model(self): |
155 | 110 | # Test that it has the expected type field in model_fields |
156 | 111 | self.assertIn('package_type', GAPackageDef.model_fields) |
157 | 112 |
|
158 | | - def test_missing_pins_configuration(self): |
159 | | - """Test missing pins configuration""" |
160 | | - # Since GAPin is not hashable, test individual pins |
161 | | - pin1 = GAPin(h="A", w=1) |
162 | | - pin2 = GAPin(h="B", w=2) |
163 | | - pin3 = GAPin(h="C", w=3) |
164 | | - |
165 | | - # Test that pins can be created correctly |
166 | | - self.assertEqual(pin1.h, "A") |
167 | | - self.assertEqual(pin1.w, 1) |
168 | | - self.assertEqual(pin2.h, "B") |
169 | | - self.assertEqual(pin2.w, 2) |
170 | | - self.assertEqual(pin3.h, "C") |
171 | | - self.assertEqual(pin3.w, 3) |
172 | | - |
173 | | - # Test that pins are equal to themselves |
174 | | - self.assertEqual(pin1, GAPin(h="A", w=1)) |
175 | | - self.assertEqual(pin2, GAPin(h="B", w=2)) |
176 | | - |
177 | | - def test_additional_pins_configuration(self): |
178 | | - """Test additional pins configuration""" |
179 | | - # Since GAPin is not hashable, test individual pins |
180 | | - pin1 = GAPin(h="D", w=4) |
181 | | - pin2 = GAPin(h="E", w=5) |
182 | | - |
183 | | - # Test that additional pins can be created correctly |
184 | | - self.assertEqual(pin1.h, "D") |
185 | | - self.assertEqual(pin1.w, 4) |
186 | | - self.assertEqual(pin2.h, "E") |
187 | | - self.assertEqual(pin2.w, 5) |
188 | | - |
189 | | - # Test equality |
190 | | - self.assertEqual(pin1, GAPin(h="D", w=4)) |
191 | | - self.assertEqual(pin2, GAPin(h="E", w=5)) |
192 | | - |
193 | | - def test_layout_type_values(self): |
194 | | - """Test different layout type values""" |
195 | | - # Test that GALayout values are correct |
196 | | - self.assertEqual(GALayout.FULL.value, "full") |
197 | | - self.assertEqual(GALayout.PERIMETER.value, "perimeter") |
198 | | - self.assertEqual(GALayout.CHANNEL.value, "channel") |
199 | | - self.assertEqual(GALayout.ISLAND.value, "island") |
200 | | - |
201 | 113 | def test_package_public_api_methods(self): |
202 | 114 | """Test that expected public API methods exist""" |
203 | 115 |
|
204 | 116 | # Test that expected methods exist |
205 | | - self.assertTrue(hasattr(GAPackageDef, 'allocate_pins')) |
206 | 117 | self.assertTrue(hasattr(GAPackageDef, 'bringup_pins')) |
207 | | - self.assertTrue(hasattr(GAPackageDef, 'heartbeat')) |
208 | | - self.assertTrue(hasattr(GAPackageDef, '_power')) |
209 | | - self.assertTrue(hasattr(GAPackageDef, '_jtag')) |
210 | | - |
211 | | - # Test that these are callable or properties |
212 | | - self.assertTrue(callable(GAPackageDef.allocate_pins)) |
213 | | - # bringup_pins, heartbeat, _power, _jtag are properties |
214 | | - |
215 | | - def test_gapin_equality_operations(self): |
216 | | - """Test that GAPin equality works correctly""" |
217 | | - pin1 = GAPin(h="A", w=1) |
218 | | - pin2 = GAPin(h="A", w=1) # Duplicate |
219 | | - pin3 = GAPin(h="B", w=2) |
220 | | - |
221 | | - # Test that GAPin equality works correctly |
222 | | - self.assertEqual(pin1, pin2) # pin1 and pin2 are equal |
223 | | - self.assertNotEqual(pin1, pin3) # pin1 and pin3 are different |
224 | | - self.assertNotEqual(pin2, pin3) # pin2 and pin3 are different |
225 | | - |
226 | | - # Test that different coordinates create different pins |
227 | | - self.assertNotEqual(GAPin(h="A", w=1), GAPin(h="A", w=2)) |
228 | | - self.assertNotEqual(GAPin(h="A", w=1), GAPin(h="B", w=1)) |
229 | | - |
230 | | - def test_gapin_string_representation(self): |
231 | | - """Test GAPin string representation""" |
232 | | - pin = GAPin(h="A", w=1) |
233 | | - |
234 | | - # Test that pin has reasonable string representation |
235 | | - str_repr = str(pin) |
236 | | - self.assertIn("A", str_repr) |
237 | | - self.assertIn("1", str_repr) |
238 | 118 |
|
239 | 119 | def test_inheritance_from_basepackagedef(self): |
240 | 120 | """Test that GAPackageDef properly inherits from BasePackageDef""" |
241 | | - from chipflow_lib.platforms._ import BasePackageDef |
| 121 | + from chipflow_lib.platforms._utils import BasePackageDef |
242 | 122 |
|
243 | 123 | # Test inheritance |
244 | 124 | self.assertTrue(issubclass(GAPackageDef, BasePackageDef)) |
|
0 commit comments