@@ -283,6 +283,13 @@ void InitialPlace::createSparseMatrix()
283283 instLocVecY_ (idx) = inst->cy ();
284284
285285 fixedInstForceVecX_ (idx) = fixedInstForceVecY_ (idx) = 0 ;
286+
287+ if (inst->isLocked ()) {
288+ listX.emplace_back (idx, idx, 1 .0f );
289+ listY.emplace_back (idx, idx, 1 .0f );
290+ fixedInstForceVecX_ (idx) = inst->cx ();
291+ fixedInstForceVecY_ (idx) = inst->cy ();
292+ }
286293 }
287294
288295 // for each net
@@ -325,24 +332,40 @@ void InitialPlace::createSparseMatrix()
325332
326333 // both pin cames from instance
327334 if (pin1->isPlaceInstConnected () && pin2->isPlaceInstConnected ()) {
328- const int inst1 = pin1->getInstance ()->getExtId ();
329- const int inst2 = pin2->getInstance ()->getExtId ();
330-
331- listX.emplace_back (inst1, inst1, weightX);
332- listX.emplace_back (inst2, inst2, weightX);
333-
334- listX.emplace_back (inst1, inst2, -weightX);
335- listX.emplace_back (inst2, inst1, -weightX);
336-
337- fixedInstForceVecX_ (inst1)
338- += -weightX
339- * ((pin1->cx () - pin1->getInstance ()->cx ())
340- - (pin2->cx () - pin2->getInstance ()->cx ()));
341-
342- fixedInstForceVecX_ (inst2)
343- += -weightX
344- * ((pin2->cx () - pin2->getInstance ()->cx ())
345- - (pin1->cx () - pin1->getInstance ()->cx ()));
335+ Instance* instance1 = pin1->getInstance ();
336+ Instance* instance2 = pin2->getInstance ();
337+ const int inst1 = instance1->getExtId ();
338+ const int inst2 = instance2->getExtId ();
339+ const bool locked1 = instance1->isLocked ();
340+ const bool locked2 = instance2->isLocked ();
341+
342+ if (!locked1 && !locked2) {
343+ // Both movable: standard B2B matrix terms
344+ listX.emplace_back (inst1, inst1, weightX);
345+ listX.emplace_back (inst2, inst2, weightX);
346+ listX.emplace_back (inst1, inst2, -weightX);
347+ listX.emplace_back (inst2, inst1, -weightX);
348+
349+ fixedInstForceVecX_ (inst1)
350+ += -weightX
351+ * ((pin1->cx () - instance1->cx ())
352+ - (pin2->cx () - instance2->cx ()));
353+ fixedInstForceVecX_ (inst2)
354+ += -weightX
355+ * ((pin2->cx () - instance2->cx ())
356+ - (pin1->cx () - instance1->cx ()));
357+ } else if (locked1 && !locked2) {
358+ // inst1 is fixed: treat pin1 as a fixed terminal for inst2
359+ listX.emplace_back (inst2, inst2, weightX);
360+ fixedInstForceVecX_ (inst2)
361+ += weightX * (pin1->cx () - (pin2->cx () - instance2->cx ()));
362+ } else if (!locked1 && locked2) {
363+ // inst2 is fixed: treat pin2 as a fixed terminal for inst1
364+ listX.emplace_back (inst1, inst1, weightX);
365+ fixedInstForceVecX_ (inst1)
366+ += weightX * (pin2->cx () - (pin1->cx () - instance1->cx ()));
367+ }
368+ // both locked: no matrix or RHS contribution needed
346369 }
347370 // pin1 from IO port / pin2 from Instance
348371 else if (!pin1->isPlaceInstConnected ()
@@ -379,24 +402,40 @@ void InitialPlace::createSparseMatrix()
379402
380403 // both pin cames from instance
381404 if (pin1->isPlaceInstConnected () && pin2->isPlaceInstConnected ()) {
382- const int inst1 = pin1->getInstance ()->getExtId ();
383- const int inst2 = pin2->getInstance ()->getExtId ();
384-
385- listY.emplace_back (inst1, inst1, weightY);
386- listY.emplace_back (inst2, inst2, weightY);
387-
388- listY.emplace_back (inst1, inst2, -weightY);
389- listY.emplace_back (inst2, inst1, -weightY);
390-
391- fixedInstForceVecY_ (inst1)
392- += -weightY
393- * ((pin1->cy () - pin1->getInstance ()->cy ())
394- - (pin2->cy () - pin2->getInstance ()->cy ()));
395-
396- fixedInstForceVecY_ (inst2)
397- += -weightY
398- * ((pin2->cy () - pin2->getInstance ()->cy ())
399- - (pin1->cy () - pin1->getInstance ()->cy ()));
405+ Instance* instance1 = pin1->getInstance ();
406+ Instance* instance2 = pin2->getInstance ();
407+ const int inst1 = instance1->getExtId ();
408+ const int inst2 = instance2->getExtId ();
409+ const bool locked1 = instance1->isLocked ();
410+ const bool locked2 = instance2->isLocked ();
411+
412+ if (!locked1 && !locked2) {
413+ // Both movable: standard B2B matrix terms
414+ listY.emplace_back (inst1, inst1, weightY);
415+ listY.emplace_back (inst2, inst2, weightY);
416+ listY.emplace_back (inst1, inst2, -weightY);
417+ listY.emplace_back (inst2, inst1, -weightY);
418+
419+ fixedInstForceVecY_ (inst1)
420+ += -weightY
421+ * ((pin1->cy () - instance1->cy ())
422+ - (pin2->cy () - instance2->cy ()));
423+ fixedInstForceVecY_ (inst2)
424+ += -weightY
425+ * ((pin2->cy () - instance2->cy ())
426+ - (pin1->cy () - instance1->cy ()));
427+ } else if (locked1 && !locked2) {
428+ // inst1 is fixed: treat pin1 as a fixed terminal for inst2
429+ listY.emplace_back (inst2, inst2, weightY);
430+ fixedInstForceVecY_ (inst2)
431+ += weightY * (pin1->cy () - (pin2->cy () - instance2->cy ()));
432+ } else if (!locked1 && locked2) {
433+ // inst2 is fixed: treat pin2 as a fixed terminal for inst1
434+ listY.emplace_back (inst1, inst1, weightY);
435+ fixedInstForceVecY_ (inst1)
436+ += weightY * (pin2->cy () - (pin1->cy () - instance1->cy ()));
437+ }
438+ // both locked: no matrix or RHS contribution needed
400439 }
401440 // pin1 from IO port / pin2 from Instance
402441 else if (!pin1->isPlaceInstConnected ()
0 commit comments