@@ -298,9 +298,18 @@ private Net createTestNet(Design design, String netName, String[] pips) {
298298 }
299299 return net ;
300300 }
301-
302- @ Test
303- public void testRemoveSourcePin () {
301+
302+ private void removeSourcePinHelper (boolean useUnroutePins , SitePinInst spi , int expectedPIPs ) {
303+ if (useUnroutePins ) {
304+ DesignTools .unroutePins (spi .getNet (), Arrays .asList (spi ));
305+ } else {
306+ Assertions .assertEquals (expectedPIPs , DesignTools .unrouteSourcePin (spi ).size ());
307+ }
308+ }
309+
310+ @ ParameterizedTest
311+ @ ValueSource (booleans = {true , false })
312+ public void testRemoveSourcePin (boolean useUnroutePins ) {
304313 Design design = new Design ("test" , Device .KCU105 );
305314
306315 // Net with one source (AQ2) and two sinks (A_I & FX) and a stub (INT_NODE_IMUX_71_INT_OUT)
@@ -325,9 +334,8 @@ public void testRemoveSourcePin() {
325334 net1 .createPin ("AQ2" , si ).setRouted (true );
326335 net1 .createPin ("A_I" , si ).setRouted (true );
327336 net1 .createPin ("FX" , si ).setRouted (true );
328-
329- Assertions .assertEquals (12 , DesignTools .unrouteSourcePin (net1 .getSource ()).size ());
330-
337+
338+ removeSourcePinHelper (useUnroutePins , net1 .getSource (), 12 );
331339 Assertions .assertEquals (0 , net1 .getPIPs ().size ());
332340 for (SitePinInst pin : net1 .getPins ()) {
333341 Assertions .assertFalse (pin .isRouted ());
@@ -346,9 +354,8 @@ public void testRemoveSourcePin() {
346354 net2 .createPin ("HMUX" , si ).setRouted (true );
347355 si = design .createSiteInst (design .getDevice ().getSite ("SLICE_X64Y158" ));
348356 net2 .createPin ("SRST_B2" , si ).setRouted (true );
349-
350- Assertions .assertEquals (4 , DesignTools .unrouteSourcePin (net2 .getSource ()).size ());
351-
357+
358+ removeSourcePinHelper (useUnroutePins , net2 .getSource (), 4 );
352359 Assertions .assertEquals (0 , net2 .getPIPs ().size ());
353360 for (SitePinInst pin : net2 .getPins ()) {
354361 Assertions .assertFalse (pin .isRouted ());
@@ -362,46 +369,45 @@ public void testRemoveSourcePin() {
362369
363370 // Net with two outputs (HMUX primary and H_O alternate) and two sinks (SRST_B2 & B2)
364371 Net net3 = createTestNet (design , "net3" , new String []{
365- // SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2
366- "INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT" ,
367- "INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT" ,
368- "INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1" ,
369- "INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7" ,
370- // Adding dual output net
371- // SLICE_X65Y158/H_O-> SLICE_X64Y158/B2
372- "INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT" ,
373- "INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3" ,
374- "INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT" ,
375- "INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14" ,
376- "INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT" ,
377- "INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3" ,
378- "INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT" ,
379- "INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12" ,
380- "INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1" ,
381- "INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT" ,
382- "INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0" ,
383- });
384-
385- si = design .createSiteInst (design .getDevice ().getSite ("SLICE_X65Y158" ));
386- SitePinInst src = net3 .createPin ("HMUX" , si );
387- src .setRouted (true );
388- SitePinInst altSrc = net3 .createPin ("H_O" , si );
389- altSrc .setRouted (true );
390- Assertions .assertNotNull (net3 .getAlternateSource ());
391- Assertions .assertTrue (net3 .getAlternateSource ().getName ().equals ("H_O" ));
392- si = design .createSiteInst (design .getDevice ().getSite ("SLICE_X64Y158" ));
393- SitePinInst snk = net3 .createPin ("SRST_B2" , si );
394- snk .setRouted (true );
395- SitePinInst altSnk = net3 .createPin ("B2" , si );
396- altSnk .setRouted (true );
397-
398- // Unroute just the H_O alternate source
399- Set <PIP > unroutedPIPs = DesignTools .unrouteSourcePin (net3 .getAlternateSource ());
400- Assertions .assertEquals (11 , unroutedPIPs .size ());
401- Assertions .assertEquals (4 , net3 .getPIPs ().size ());
402- Assertions .assertTrue (src .isRouted ());
403- Assertions .assertFalse (altSrc .isRouted ());
404- Assertions .assertTrue (snk .isRouted ());
405- Assertions .assertFalse (altSnk .isRouted ());
372+ // SLICE_X65Y158/HMUX-> SLICE_X64Y158/SRST_B2
373+ "INT_X42Y158/INT.LOGIC_OUTS_E16->>INT_NODE_SINGLE_DOUBLE_46_INT_OUT" ,
374+ "INT_X42Y158/INT.INT_NODE_SINGLE_DOUBLE_46_INT_OUT->>INT_INT_SINGLE_51_INT_OUT" ,
375+ "INT_X42Y158/INT.INT_INT_SINGLE_51_INT_OUT->>INT_NODE_GLOBAL_3_OUT1" ,
376+ "INT_X42Y158/INT.INT_NODE_GLOBAL_3_OUT1->>CTRL_W_B7" ,
377+ // Adding dual output net
378+ // SLICE_X65Y158/H_O-> SLICE_X64Y158/B2
379+ "INT_X42Y158/INT.LOGIC_OUTS_E29->>INT_NODE_QUAD_LONG_5_INT_OUT" ,
380+ "INT_X42Y158/INT.INT_NODE_QUAD_LONG_5_INT_OUT->>NN16_BEG3" ,
381+ "INT_X42Y174/INT.NN16_END3->>INT_NODE_QUAD_LONG_53_INT_OUT" ,
382+ "INT_X42Y174/INT.INT_NODE_QUAD_LONG_53_INT_OUT->>WW4_BEG14" ,
383+ "INT_X40Y174/INT.WW4_END14->>INT_NODE_QUAD_LONG_117_INT_OUT" ,
384+ "INT_X40Y174/INT.INT_NODE_QUAD_LONG_117_INT_OUT->>SS16_BEG3" ,
385+ "INT_X40Y158/INT.SS16_END3->>INT_NODE_QUAD_LONG_84_INT_OUT" ,
386+ "INT_X40Y158/INT.INT_NODE_QUAD_LONG_84_INT_OUT->>EE4_BEG12" ,
387+ "INT_X42Y158/INT.EE4_END12->>INT_NODE_GLOBAL_8_OUT1" ,
388+ "INT_X42Y158/INT.INT_NODE_GLOBAL_8_OUT1->>INT_NODE_IMUX_61_INT_OUT" ,
389+ "INT_X42Y158/INT.INT_NODE_IMUX_61_INT_OUT->>IMUX_W0" ,
390+ });
391+
392+ si = design .createSiteInst (design .getDevice ().getSite ("SLICE_X65Y158" ));
393+ SitePinInst src = net3 .createPin ("HMUX" , si );
394+ src .setRouted (true );
395+ SitePinInst altSrc = net3 .createPin ("H_O" , si );
396+ altSrc .setRouted (true );
397+ Assertions .assertNotNull (net3 .getAlternateSource ());
398+ Assertions .assertTrue (net3 .getAlternateSource ().getName ().equals ("H_O" ));
399+ si = design .createSiteInst (design .getDevice ().getSite ("SLICE_X64Y158" ));
400+ SitePinInst snk = net3 .createPin ("SRST_B2" , si );
401+ snk .setRouted (true );
402+ SitePinInst altSnk = net3 .createPin ("B2" , si );
403+ altSnk .setRouted (true );
404+
405+ // Unroute just the H_O alternate source
406+ removeSourcePinHelper (useUnroutePins , net3 .getAlternateSource (), 11 );
407+ Assertions .assertEquals (4 , net3 .getPIPs ().size ());
408+ Assertions .assertTrue (src .isRouted ());
409+ Assertions .assertFalse (altSrc .isRouted ());
410+ Assertions .assertTrue (snk .isRouted ());
411+ Assertions .assertFalse (altSnk .isRouted ());
406412 }
407413}
0 commit comments