Skip to content

Commit c9ed601

Browse files
committed
Implement SB_DRIVE support
1 parent 38e9c9e commit c9ed601

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

himbaechel/uarch/gatemate/bitstream.cc

+22
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ struct BitstreamBackend
164164
boost::replace_all(word, "RES.", stringf("RES%d.", id));
165165
else if (boost::starts_with(word, "TES."))
166166
boost::replace_all(word, "TES.", stringf("TES%d.", id));
167+
if (boost::starts_with(word, "SB_DRIVE.")) {
168+
Loc l;
169+
tile_xy(ctx->chip_info, pip.tile, l.x, l.y);
170+
l.z = 0;
171+
BelId cpe_bel = ctx->getBelByLocation(l);
172+
// Only if switchbox is inside core (same as sharing location with CPE)
173+
if (cpe_bel != BelId() && ctx->getBelType(cpe_bel) == id_CPE) {
174+
// Convert coordinates into in-tile coordinates
175+
int xt = ((l.x-2-1)+16) % 8;
176+
int yt = ((l.y-2-1)+16) % 8;
177+
// Bitstream data for certain SB_DRIVES is located in other tiles
178+
switch(word[14]) {
179+
case '3' : if (xt >= 4) { loc.x -= 2; word[14] = '1'; }; break;
180+
case '4' : if (yt >= 4) { loc.y -= 2; word[14] = '2'; }; break;
181+
case '1' : if (xt <= 3) { loc.x += 2; word[14] = '3'; }; break;
182+
case '2' : if (yt <= 3) { loc.y += 2; word[14] = '4'; }; break;
183+
default:
184+
break;
185+
}
186+
}
187+
}
188+
167189
cc.tiles[loc].add_word(word, int_to_bitvector(extra_data.value, extra_data.bits));
168190
}
169191
}

0 commit comments

Comments
 (0)