@@ -852,7 +852,9 @@ struct NexusPacker
852852 void promote_globals ()
853853 {
854854 std::vector<std::pair<int , IdString>> clk_fanout;
855- int available_globals = 16 ;
855+ std::vector<std::pair<int , IdString>> ce_lsr_fanout;
856+ // TODO: if we are more cunning about placement, the real limits are 16 per device half and 8 per row segment
857+ int available_globals = 8 ;
856858 for (auto &net : ctx->nets ) {
857859 NetInfo *ni = net.second .get ();
858860 // Skip undriven nets; and nets that are already global
@@ -863,26 +865,41 @@ struct NexusPacker
863865 continue ;
864866 }
865867 // Count the number of clock ports
866- int clk_count = 0 ;
868+ int clk_count = 0 , ce_lsr_count = 0 ;
867869 for (const auto &usr : ni->users ) {
868870 auto port_style = ctx->get_cell_pin_style (usr.cell , usr.port );
869871 if (port_style & PINGLB_CLK)
870872 ++clk_count;
873+ if (port_style & PINGLB_CE_LSR)
874+ ++ce_lsr_count;
871875 }
872876 if (clk_count > 0 )
873877 clk_fanout.emplace_back (clk_count, ni->name );
878+ if (ce_lsr_count > 150 )
879+ ce_lsr_fanout.emplace_back (ce_lsr_count, ni->name );
874880 }
875881 if (available_globals <= 0 )
876882 return ;
877883 // Sort clocks by max fanout
878884 std::sort (clk_fanout.begin (), clk_fanout.end (), std::greater<std::pair<int , IdString>>());
885+ std::sort (ce_lsr_fanout.begin (), ce_lsr_fanout.end (), std::greater<std::pair<int , IdString>>());
886+
879887 log_info (" Promoting globals...\n " );
880888 // Promote the N highest fanout clocks
881889 for (size_t i = 0 ; i < std::min<size_t >(clk_fanout.size (), available_globals); i++) {
882890 NetInfo *net = ctx->nets .at (clk_fanout.at (i).second ).get ();
883891 log_info (" promoting clock net '%s'\n " , ctx->nameOf (net));
884892 insert_buffer (net, id_DCC, " glb_clk" , id_CLKI, id_CLKO, [](const PortRef &port) { return true ; });
885893 }
894+ // Limit to 6 LSR/CE to avoid routeability issues
895+ int available_ce_lsr_globals = std::min<int >(available_globals, 6 );
896+ for (size_t i = 0 ; i < std::min<size_t >(ce_lsr_fanout.size (), available_ce_lsr_globals); i++) {
897+ NetInfo *net = ctx->nets .at (ce_lsr_fanout.at (i).second ).get ();
898+ log_info (" promoting CE/LSR net '%s'\n " , ctx->nameOf (net));
899+ insert_buffer (net, id_DCC, " glb_ce_lsr" , id_CLKI, id_CLKO, [this ](const PortRef &port) {
900+ return ctx->get_cell_pin_style (port.cell , port.port ) & PINGLB_CE_LSR;
901+ });
902+ }
886903 }
887904
888905 // Place certain global cells
0 commit comments