aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-10 12:11:58 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-10 12:11:58 +0200
commit827a43c88c75f5daf4f3a626fce0e5dd1b3d47f2 (patch)
tree10593d2260f5cdd1087ae2a1942de029cf1ce909
parentd0431225f1f7d319714301d85893ad6d20f91c93 (diff)
downloadnextpnr-827a43c88c75f5daf4f3a626fce0e5dd1b3d47f2.tar.gz
nextpnr-827a43c88c75f5daf4f3a626fce0e5dd1b3d47f2.tar.bz2
nextpnr-827a43c88c75f5daf4f3a626fce0e5dd1b3d47f2.zip
ice40: Start adding routing to asc output
Signed-off-by: David Shah <davey1576@gmail.com>
-rw-r--r--ice40/bitstream.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index 1ee24f42..e5a045c5 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -25,6 +25,15 @@ inline TileType tile_at(const Chip &chip, int x, int y)
return chip.chip_info.tile_grid[y * chip.chip_info.width + x];
}
+const ConfigEntryPOD &find_config(const TileInfoPOD &tile, const std::string &name) {
+ for (int i = 0; i < tile.num_config_entries; i++) {
+ if (std::string(tile.entries[i].name) == name) {
+ return tile.entries[i];
+ }
+ }
+ assert(false);
+}
+
void write_asc(const Chip &chip, std::ostream &out)
{
// [y][x][row][col]
@@ -61,6 +70,31 @@ void write_asc(const Chip &chip, std::ostream &out)
default:
assert(false);
}
+ // Set pips
+ for (auto pip : chip.getPips()) {
+ if (chip.pip_to_net[pip.index] != IdString()) {
+ const PipInfoPOD &pi = ci.pip_data[pip.index];
+ const SwitchInfoPOD &swi = bi.switches[pi.switch_index];
+ for (int i = 0; i < swi.num_bits; i++) {
+ bool val = (pi.switch_mask & (1 << ((swi.num_bits - 1) - i))) != 0;
+ int8_t &cbit = config.at(swi.y).at(swi.x).at(swi.cbits[i].row).at(swi.cbits[i].col);
+ if (bool(cbit) != 0)
+ assert(false);
+ cbit = val;
+ }
+ }
+ }
+ // Set config bits - currently just disable RAM to stop icebox_vlog crashing
+ for (int y = 0; y < ci.height; y++) {
+ for (int x = 0; x < ci.width; x++) {
+ TileType tile = tile_at(chip, x, y);
+ if (tile == TILE_RAMB) {
+ auto cfg = find_config(bi.tiles_nonrouting[TILE_RAMB], "RamConfig.PowerUp");
+ for (int i = 0; i < cfg.num_bits; i++)
+ config.at(y).at(x).at(cfg.bits[i].row).at(cfg.bits[i].col) = 1;
+ }
+ }
+ }
// Write config out
for (int y = 0; y < ci.height; y++) {
for (int x = 0; x < ci.width; x++) {