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