diff options
Diffstat (limited to 'icepack')
| -rw-r--r-- | icepack/.gitignore | 3 | ||||
| -rw-r--r-- | icepack/Makefile | 24 | ||||
| -rw-r--r-- | icepack/icepack.cc | 20 |
3 files changed, 30 insertions, 17 deletions
diff --git a/icepack/.gitignore b/icepack/.gitignore index ef4173d..a277e88 100644 --- a/icepack/.gitignore +++ b/icepack/.gitignore @@ -1,5 +1,8 @@ icepack icepack.exe +icepack.wasm iceunpack +iceunpack.exe +iceunpack.wasm icepack.o icepack.d diff --git a/icepack/Makefile b/icepack/Makefile index 3e8c774..46f2410 100644 --- a/icepack/Makefile +++ b/icepack/Makefile @@ -5,30 +5,30 @@ ifeq ($(STATIC),1) LDFLAGS += -static endif -all: icepack$(EXE) iceunpack$(EXE) +all: $(PROGRAM_PREFIX)icepack$(EXE) $(PROGRAM_PREFIX)iceunpack$(EXE) -icepack$(EXE): icepack.o +$(PROGRAM_PREFIX)icepack$(EXE): icepack.o $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) -iceunpack$(EXE): icepack$(EXE) - ln -sf icepack$(EXE) iceunpack$(EXE) +$(PROGRAM_PREFIX)iceunpack$(EXE): $(PROGRAM_PREFIX)icepack$(EXE) + ln -sf $(PROGRAM_PREFIX)icepack$(EXE) $(PROGRAM_PREFIX)iceunpack$(EXE) -iceunpack.exe: +$(PROGRAM_PREFIX)iceunpack.exe: # no iceunpack.exe, use icepack -u install: all mkdir -p $(DESTDIR)$(PREFIX)/bin - cp icepack$(EXE) $(DESTDIR)$(PREFIX)/bin/icepack$(EXE) - ln -sf icepack$(EXE) $(DESTDIR)$(PREFIX)/bin/iceunpack$(EXE) + cp $(PROGRAM_PREFIX)icepack$(EXE) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)icepack$(EXE) + ln -sf $(PROGRAM_PREFIX)icepack$(EXE) $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)iceunpack$(EXE) uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/icepack$(EXE) - rm -f $(DESTDIR)$(PREFIX)/bin/iceunpack$(EXE) + rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)icepack$(EXE) + rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_PREFIX)iceunpack$(EXE) clean: - rm -f icepack$(EXE) - rm -f iceunpack$(EXE) - rm -f icepack.exe + rm -f $(PROGRAM_PREFIX)icepack$(EXE) + rm -f $(PROGRAM_PREFIX)iceunpack$(EXE) + rm -f $(PROGRAM_PREFIX)icepack.exe rm -f *.o *.d -include *.d diff --git a/icepack/icepack.cc b/icepack/icepack.cc index 9b38ab5..565d5f9 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -968,7 +968,17 @@ 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].resize(this->cram_width); + for (int x = 0; x < this->cram_width; x++) + tile_type[bank][x].resize(this->cram_height); + } + for (int y = 0; y <= this->chip_height()+1; y++) for (int x = 0; x <= this->chip_width()+1; x++) { @@ -1321,10 +1331,10 @@ void BramIndexConverter::get_bram_index(int bit_x, int bit_y, int &bram_bank, in // ================================================================== // Main program -void usage() +void usage(const char *cmd) { log("\n"); - log("Usage: icepack [options] [input-file [output-file]]\n"); + log("Usage: %s [options] [input-file [output-file]]\n", cmd); log("\n"); log(" -u\n"); log(" unpack mode (implied when called as 'iceunpack')\n"); @@ -1416,7 +1426,7 @@ int main(int argc, char **argv) } else if (arg[i] == 'n') { skip_bram_initialization = true; } else - usage(); + usage(argv[0]); continue; } @@ -1448,7 +1458,7 @@ int main(int argc, char **argv) } if (parameters.size() > 2) - usage(); + usage(argv[0]); FpgaConfig fpga_config; |
