@@ -534,6 +534,15 @@ void Arch::update_alm_input_count(uint32_t lab, uint8_t alm)
534534 alm_data.unique_input_count = total_inputs;
535535}
536536
537+ const std::array<int , 6 > tdmux_set = {
538+ 0 , // A
539+ 1 , // B
540+ 2 , // C
541+ 1 , // D
542+ 3 , // E
543+ 2 , // F
544+ };
545+
537546bool Arch::check_lab_input_count (uint32_t lab) const
538547{
539548 // There are only 46 TD signals available to route signals from general routing to the ALM input. Currently, we
@@ -544,10 +553,40 @@ bool Arch::check_lab_input_count(uint32_t lab) const
544553 // currently perfunctory place and route algorithms to achieve satisfactory runtimes.
545554 int count = 0 ;
546555 auto &lab_data = labs.at (lab);
547- for (int i = 0 ; i < 10 ; i++) {
548- count += lab_data.alms .at (i).unique_input_count ;
556+ pool<std::pair<IdString, int >> unique_inputs;
557+
558+ for (int alm = 0 ; alm < 10 ; alm++) {
559+ // TODO: duplication with above
560+ auto &alm_data = labs.at (lab).alms .at (alm);
561+ // Get cells into an array for fast access
562+ std::array<const CellInfo *, 2 > luts{getBoundBelCell (alm_data.lut_bels [0 ]), getBoundBelCell (alm_data.lut_bels [1 ])};
563+ std::array<const CellInfo *, 4 > ffs{getBoundBelCell (alm_data.ff_bels [0 ]), getBoundBelCell (alm_data.ff_bels [1 ]),
564+ getBoundBelCell (alm_data.ff_bels [2 ]), getBoundBelCell (alm_data.ff_bels [3 ])};
565+ for (int i = 0 ; i < 2 ; i++) {
566+ if (!luts[i])
567+ continue ;
568+
569+ for (int j = 0 ; j < luts[i]->combInfo .lut_input_count ; j++)
570+ if (luts[i]->combInfo .lut_in [j])
571+ unique_inputs.insert (std::make_pair (luts[i]->combInfo .lut_in [j]->name , tdmux_set.at (j)));
572+ }
573+ for (int i = 0 ; i < 4 ; i++) {
574+ const CellInfo *ff = ffs[i];
575+ if (!ff)
576+ continue ;
577+ if (ff->ffInfo .sdata ) {
578+ unique_inputs.insert (std::make_pair (ff->ffInfo .sdata ->name , tdmux_set.at (4 )));
579+ unique_inputs.insert (std::make_pair (ff->ffInfo .sdata ->name , tdmux_set.at (5 )));
580+ }
581+ // FF input doesn't consume routing resources if driven by associated LUT
582+ if (ff->ffInfo .datain && (!luts[i / 2 ] || ff->ffInfo .datain != luts[i / 2 ]->combInfo .comb_out )) {
583+ unique_inputs.insert (std::make_pair (ff->ffInfo .datain ->name , tdmux_set.at (4 )));
584+ unique_inputs.insert (std::make_pair (ff->ffInfo .datain ->name , tdmux_set.at (5 )));
585+ }
586+ }
549587 }
550- return (count <= 42 );
588+
589+ return (unique_inputs.size () <= 42 );
551590}
552591
553592bool Arch::check_mlab_groups (uint32_t lab) const
0 commit comments