Skip to content

Commit 31387db

Browse files
committed
nexus: Promote CE/LSR globals
Signed-off-by: gatecat <[email protected]>
1 parent ae8a910 commit 31387db

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

nexus/arch.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,10 @@ enum CellPinStyle
785785

786786
PINDEF_MASK = 0x30,
787787

788-
PINGLB_CLK = 0x100, // pin is a 'clock' for global purposes
788+
PINGLB_CLK = 0x100, // pin is a 'clock' for global purposes
789+
PINGLB_CE_LSR = 0x200, // pin is CE/LSR for global purposes
789790

790-
PINGLB_MASK = 0x100,
791+
PINGLB_MASK = 0x300,
791792

792793
PINBIT_GATED = 0x1000, // pin must be enabled in bitstream if used
793794
PINBIT_1 = 0x2000, // pin has an explicit bit that must be set if tied to 1
@@ -796,8 +797,8 @@ enum CellPinStyle
796797
PINSTYLE_NONE = 0x0000, // default
797798
PINSTYLE_CIB = 0x4012, // 'CIB' signal, floats high but explicitly zeroed if not used
798799
PINSTYLE_CLK = 0x0107, // CLK type signal, invertible and defaults to disconnected
799-
PINSTYLE_CE = 0x0027, // CE type signal, invertible and defaults to enabled
800-
PINSTYLE_LSR = 0x0017, // LSR type signal, invertible and defaults to not reset
800+
PINSTYLE_CE = 0x0227, // CE type signal, invertible and defaults to enabled
801+
PINSTYLE_LSR = 0x0217, // LSR type signal, invertible and defaults to not reset
801802
PINSTYLE_DEDI = 0x0000, // dedicated signals, leave alone
802803
PINSTYLE_PU = 0x4022, // signals that float high and default high
803804
PINSTYLE_PU_NONCIB = 0x0022, // signals that float high and default high

nexus/pack.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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>(clk_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

Comments
 (0)