Skip to content

Commit b0c3382

Browse files
Test Userclaude
authored andcommitted
Fix incorrect IO tile corner detection in nextpnr-aegis
The previous corner detection used `x != y` / `x == y` which only excluded the (0,0) and (W-1,H-1) diagonal corners. The corners (W-1,0) and (0,H-1) were incorrectly treated as valid IO tiles, causing IO BELs, wires, and pips to be created at positions that don't correspond to actual IO pads in the FPGA hardware. This mismatch between the nextpnr model and the simulator/hardware could cause the placer to assign IO cells to non-existent pad positions, producing a bitstream that doesn't work on the device. Fix by adding an is_corner() helper that correctly identifies all four grid corners, and use it in init_wires, init_bels, and init_pips. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7802d83 commit b0c3382

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

nextpnr-aegis/aegis.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ struct AegisImpl : ViaductAPI {
180180
return (x == 0) || (x == (W - 1)) || (y == 0) || (y == (H - 1));
181181
}
182182

183+
bool is_corner(int x, int y) const {
184+
return (x == 0 || x == W - 1) && (y == 0 || y == H - 1);
185+
}
186+
183187
PipId add_pip(Loc loc, WireId src, WireId dst, delay_t delay = 0.05) {
184188
IdStringList name =
185189
IdStringList::concat(ctx->getWireName(dst), ctx->getWireName(src));
@@ -238,7 +242,7 @@ struct AegisImpl : ViaductAPI {
238242
tw.track_w.push_back(ctx->addWire(h.xy_id(x, y, ctx->idf("W%d", t)),
239243
ctx->id("ROUTING"), x, y));
240244
}
241-
} else if (x != y) {
245+
} else if (!is_corner(x, y)) {
242246
// IO tile wires
243247
for (int z = 0; z < 2; z++) {
244248
tw.pad.push_back(ctx->addWire(h.xy_id(x, y, ctx->idf("PAD%d", z)),
@@ -269,7 +273,7 @@ struct AegisImpl : ViaductAPI {
269273
for (int y = 0; y < H; y++) {
270274
for (int x = 0; x < W; x++) {
271275
if (is_io(x, y)) {
272-
if (x == y)
276+
if (is_corner(x, y))
273277
continue;
274278
add_io_bels(x, y);
275279
} else {
@@ -320,7 +324,7 @@ struct AegisImpl : ViaductAPI {
320324
for (int y = 0; y < H; y++) {
321325
for (int x = 0; x < W; x++) {
322326
if (is_io(x, y)) {
323-
if (x != y)
327+
if (!is_corner(x, y))
324328
add_io_pips(x, y);
325329
} else {
326330
add_logic_pips(x, y);

0 commit comments

Comments
 (0)