@@ -531,6 +531,16 @@ class B2BSolver : public AnalyticalSolver {
531
531
// / number, the solver will focus more on timing and less on wirelength.
532
532
static constexpr double timing_slope_fac_ = 0.75 ;
533
533
534
+ // / @brief For most FPGA architectures, the cost of moving horizontally is
535
+ // / equivalent to the cost moving vertically (i.e. moving in increasing
536
+ // / x-dimension has the same cost as moving the same amount in the
537
+ // / y-dimension). However, for 3D FPGAs, moving between layers is
538
+ // / much more expensive than moving in the x or y dimension. We account
539
+ // / for this by adding a cost penalty factor to the "z"-dimension.
540
+ // / TODO: This cost factor was randomly selected because it felt ok. Should
541
+ // / choose a better factor that is chosen empirically.
542
+ static constexpr double layer_distance_cost_fac_ = 10.0 ;
543
+
534
544
public:
535
545
B2BSolver (const APNetlist& ap_netlist,
536
546
const DeviceGrid& device_grid,
@@ -699,15 +709,41 @@ class B2BSolver : public AnalyticalSolver {
699
709
void update_linear_system_with_anchors (unsigned iteration);
700
710
701
711
/* *
702
- * @brief Store the x and y solutions in Eigen's vectors into the partial
703
- * placement object.
704
- *
705
- * Note: The x_soln and y_soln may be modified if it is found that the
706
- * solution is imposible (i.e. has negative positions).
712
+ * @brief Solves the linear system of equations using the connectivity
713
+ * matrix (A), the constant vector (b), and a guess for the solution.
707
714
*/
708
- void store_solution_into_placement (Eigen::VectorXd& x_soln,
709
- Eigen::VectorXd& y_soln,
710
- PartialPlacement& p_placement);
715
+ Eigen::VectorXd solve_linear_system (Eigen::SparseMatrix<double > &A,
716
+ Eigen::VectorXd &b,
717
+ Eigen::VectorXd &guess);
718
+
719
+ /* *
720
+ * @brief Store the solutions from the linear system into the partial
721
+ * placement object for the given dimension.
722
+ *
723
+ * Note: The dim_soln may be modified if it is found that the solution is
724
+ * imposible (e.g. has negative positions).
725
+ *
726
+ * @param dim_soln
727
+ * The solution of the linear system for a given dimension.
728
+ * @param block_dim_locs
729
+ * The block locations in the partial placement for the dimension.
730
+ * @param dim_max_pos
731
+ * The maximum position allowed for the dimension. For example, for the
732
+ * x-dimension, this would be the width of the device. This is used to
733
+ * ensure that the positions do not go off device.
734
+ */
735
+ void store_solution_into_placement (Eigen::VectorXd &dim_soln,
736
+ vtr::vector<APBlockId, double > &block_dim_locs,
737
+ double dim_max_pos);
738
+
739
+ /* *
740
+ * @brief Does the FPGA that the AP flow is currently targeting have more
741
+ * than one die. Having multiple dies would imply that the solver
742
+ * needs to add another dimension to solve for.
743
+ */
744
+ inline bool is_multi_die () const {
745
+ return device_grid_num_layers_ > 1 ;
746
+ }
711
747
712
748
// The following are variables used to store the system of equations to be
713
749
// solved in the x and y dimensions. The equations are of the form:
@@ -720,22 +756,28 @@ class B2BSolver : public AnalyticalSolver {
720
756
Eigen::SparseMatrix<double > A_sparse_x;
721
757
// / @brief The coefficient / connectivity matrix for the y dimension.
722
758
Eigen::SparseMatrix<double > A_sparse_y;
759
+ // / @brief The coefficient / connectivity matrix for the z dimension (layer dimension).
760
+ Eigen::SparseMatrix<double > A_sparse_z;
723
761
// / @brief The constant vector in the x dimension.
724
762
Eigen::VectorXd b_x;
725
763
// / @brief The constant vector in the y dimension.
726
764
Eigen::VectorXd b_y;
765
+ // / @brief The constant vector in the z dimension (layer dimension).
766
+ Eigen::VectorXd b_z;
727
767
728
768
// The following is the solution of the previous iteration of this solver.
729
769
// They are updated at the end of solve() and are used as the starting point
730
770
// for the next call to solve.
731
771
vtr::vector<APBlockId, double > block_x_locs_solved;
732
772
vtr::vector<APBlockId, double > block_y_locs_solved;
773
+ vtr::vector<APBlockId, double > block_z_locs_solved;
733
774
734
775
// The following are the legalized solution coming into the analytical solver
735
776
// (other than the first iteration). These are stored to be used as anchor
736
777
// blocks during the solver.
737
778
vtr::vector<APBlockId, double > block_x_locs_legalized;
738
779
vtr::vector<APBlockId, double > block_y_locs_legalized;
780
+ vtr::vector<APBlockId, double > block_z_locs_legalized;
739
781
740
782
// / @brief The total number of CG iterations that this solver has performed
741
783
// / so far. This can be a useful metric for the amount of work the
0 commit comments