option for icepack to skip initializing BRAM (tested for ice40hx8k)

This commit is contained in:
Dennis Gnad 2019-05-15 16:57:17 +02:00
parent dd8c003e79
commit 992d8c97ea
1 changed files with 22 additions and 11 deletions

View File

@ -112,6 +112,7 @@ struct FpgaConfig
// bram[BANK][X][Y] // bram[BANK][X][Y]
int bram_width, bram_height; int bram_width, bram_height;
vector<vector<vector<bool>>> bram; vector<vector<vector<bool>>> bram;
bool skip_bram_initialization;
// data before preamble // data before preamble
vector<uint8_t> initblop; vector<uint8_t> initblop;
@ -579,6 +580,7 @@ void FpgaConfig::write_bits(std::ostream &ofs) const
} }
if (!this->skip_bram_initialization) {
debug("BRAM: Writing bank %d data.\n", bram_bank); debug("BRAM: Writing bank %d data.\n", bram_bank);
write_byte(ofs, crc_value, file_offset, 0x01); write_byte(ofs, crc_value, file_offset, 0x01);
write_byte(ofs, crc_value, file_offset, 0x03); write_byte(ofs, crc_value, file_offset, 0x03);
@ -594,6 +596,7 @@ void FpgaConfig::write_bits(std::ostream &ofs) const
} }
} }
} }
}
debug("Writing CRC value.\n"); debug("Writing CRC value.\n");
write_byte(ofs, crc_value, file_offset, 0x22); write_byte(ofs, crc_value, file_offset, 0x22);
@ -1348,6 +1351,9 @@ void usage()
log(" -B0, -B1, -B2, -B3\n"); log(" -B0, -B1, -B2, -B3\n");
log(" only include the specified bank in the netpbm file\n"); log(" only include the specified bank in the netpbm file\n");
log("\n"); log("\n");
log(" -n\n");
log(" skip initializing BRAM\n");
log("\n");
exit(1); exit(1);
} }
@ -1372,6 +1378,7 @@ int main(int argc, char **argv)
bool netpbm_bram = false; bool netpbm_bram = false;
bool netpbm_fill_tiles = false; bool netpbm_fill_tiles = false;
bool netpbm_checkerboard = false; bool netpbm_checkerboard = false;
bool skip_bram_initialization = false;
int netpbm_banknum = -1; int netpbm_banknum = -1;
int checkerboard_m = 1; int checkerboard_m = 1;
@ -1406,6 +1413,8 @@ int main(int argc, char **argv)
nosleep_mode = true; nosleep_mode = true;
} else if (arg[i] == 'v') { } else if (arg[i] == 'v') {
log_level++; log_level++;
} else if (arg[i] == 'n') {
skip_bram_initialization = true;
} else } else
usage(); usage();
continue; continue;
@ -1443,6 +1452,8 @@ int main(int argc, char **argv)
FpgaConfig fpga_config; FpgaConfig fpga_config;
fpga_config.skip_bram_initialization = skip_bram_initialization;
if (unpack_mode) { if (unpack_mode) {
fpga_config.read_bits(*isp); fpga_config.read_bits(*isp);
if (!netpbm_mode) if (!netpbm_mode)