aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaire Wolf <clifford@clifford.at>2020-04-22 18:01:58 +0200
committerGitHub <noreply@github.com>2020-04-22 18:01:58 +0200
commit3fb2d2f73561d05050e83e623a3d3c3e0e60dc01 (patch)
treec2a0bb546488d33211aec16d6f2aeff14030c8bc
parentcf3f4b53c38f7428ba5edb82e2ed27e032bf0c44 (diff)
parent578037dedf557806a5a39ab40a22b9cceade9a07 (diff)
downloadicestorm-3fb2d2f73561d05050e83e623a3d3c3e0e60dc01.tar.gz
icestorm-3fb2d2f73561d05050e83e623a3d3c3e0e60dc01.tar.bz2
icestorm-3fb2d2f73561d05050e83e623a3d3c3e0e60dc01.zip
Merge pull request #242 from The6P4C/master
icepack: Fix Windows-only stack overflow in CRAM pbm generation (fixe…
-rw-r--r--icepack/icepack.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/icepack/icepack.cc b/icepack/icepack.cc
index 9b38ab5..2eec7ed 100644
--- a/icepack/icepack.cc
+++ b/icepack/icepack.cc
@@ -968,7 +968,25 @@ void FpgaConfig::write_cram_pbm(std::ostream &ofs, int bank_num) const
ofs << "P3\n";
ofs << stringf("%d %d\n", 2*this->cram_width, 2*this->cram_height);
ofs << "255\n";
- uint32_t tile_type[4][this->cram_width][this->cram_height];
+
+ vector<vector<uint32_t>> tile_type[4];
+
+ // We require random access to tile_type, so ensure that each column of each
+ // bank is initialised so that all possible indices are valid
+ for (int bank = 0; bank < 4; bank++) {
+ tile_type[bank].reserve(this->cram_width);
+
+ for (int x = 0; x < this->cram_width; x++) {
+ tile_type[bank].push_back(vector<uint32_t>(this->cram_height));
+
+ for (int y = 0; y < this->cram_height; y++) {
+ // Initialisation value unimportant - will be overwritten during
+ // image generation
+ tile_type[bank][x].push_back(0);
+ }
+ }
+ }
+
for (int y = 0; y <= this->chip_height()+1; y++)
for (int x = 0; x <= this->chip_width()+1; x++)
{