From fdf863b791ac3b09345e59456185d07589b9bbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20Horv=C3=A1th?= Date: Sun, 5 Mar 2017 22:25:47 +0100 Subject: LP384 support in icepack (tested on real chip) LP384 is now supported in icepack, it was fairly easy to realize as only the main chip dimensions are required that could be found out from the .bin bitsream file generated by iCEcube. Tested by creating .asc then packing it back to .bin. The testcase is just a simple LED on/off on a port though but that shows geometries are fine. Now I'm trying to have and support chipdb-384.txt hopefully with some help from the authors and anyone who already knows the internals of IceStorm well. I need info, how to reverse-engineer iCE40 chips the easiest way. Scripts maybe. I'm trying to reach my goal in any way coz iCEcube sucks and IceStorm integrates well into commandline... --- icepack/icepack.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/icepack/icepack.cc b/icepack/icepack.cc index b5db4c5..85a37d6 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -42,7 +42,7 @@ using std::vector; using std::string; -int log_level = 0; +int log_level = 1; // 0; #define log(...) fprintf(stderr, __VA_ARGS__); #define info(...) do { if (log_level > 0) fprintf(stderr, __VA_ARGS__); } while (0) #define debug(...) do { if (log_level > 1) fprintf(stderr, __VA_ARGS__); } while (0) @@ -390,7 +390,9 @@ void FpgaConfig::read_bits(std::istream &ifs) } } - if (this->cram_width == 332 && this->cram_height == 144) + if (this->cram_width == 182 && this->cram_height == 80) + this->device = "384"; + else if (this->cram_width == 332 && this->cram_height == 144) this->device = "1k"; else if (this->cram_width == 872 && this->cram_height == 272) this->device = "8k"; @@ -598,6 +600,12 @@ void FpgaConfig::read_ascii(std::istream &ifs) is >> this->device; + if (this->device == "384") { + this->cram_width = 182; + this->cram_height = 80; + this->bram_width = 0; + this->bram_height = 0; + } else if (this->device == "1k") { this->cram_width = 332; this->cram_height = 144; @@ -857,6 +865,7 @@ void FpgaConfig::write_bram_pbm(std::ostream &ofs, int bank_num) const int FpgaConfig::chip_width() const { + if (this->device == "384") return 6; if (this->device == "1k") return 12; if (this->device == "8k") return 32; panic("Unknown chip type '%s'.\n", this->device.c_str()); @@ -864,6 +873,7 @@ int FpgaConfig::chip_width() const int FpgaConfig::chip_height() const { + if (this->device == "384") return 8; if (this->device == "1k") return 16; if (this->device == "8k") return 32; panic("Unknown chip type '%s'.\n", this->device.c_str()); @@ -871,6 +881,7 @@ int FpgaConfig::chip_height() const vector FpgaConfig::chip_cols() const { + if (this->device == "384") return vector({18, 54, 54, 54, 54}); if (this->device == "1k") return vector({18, 54, 54, 42, 54, 54, 54}); if (this->device == "8k") return vector({18, 54, 54, 54, 54, 54, 54, 54, 42, 54, 54, 54, 54, 54, 54, 54, 54}); panic("Unknown chip type '%s'.\n", this->device.c_str()); @@ -881,6 +892,8 @@ string FpgaConfig::tile_type(int x, int y) const if ((x == 0 || x == this->chip_width()+1) && (y == 0 || y == this->chip_height()+1)) return "corner"; if ((x == 0 || x == this->chip_width()+1) || (y == 0 || y == this->chip_height()+1)) return "io"; + if (this->device == "384") return "logic"; + if (this->device == "1k") { if (x == 3 || x == 10) return y % 2 == 1 ? "ramb" : "ramt"; return "logic"; -- cgit v1.2.3 From e207307c74430d544dd33e43ebbeccf910827e1a Mon Sep 17 00:00:00 2001 From: hermitsoft Date: Mon, 6 Mar 2017 01:24:20 +0100 Subject: LP384 support in icepack - log_level back to 0 --- icepack/icepack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icepack/icepack.cc b/icepack/icepack.cc index 85a37d6..5b6cb3b 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -42,7 +42,7 @@ using std::vector; using std::string; -int log_level = 1; // 0; +int log_level = 0; #define log(...) fprintf(stderr, __VA_ARGS__); #define info(...) do { if (log_level > 0) fprintf(stderr, __VA_ARGS__); } while (0) #define debug(...) do { if (log_level > 1) fprintf(stderr, __VA_ARGS__); } while (0) -- cgit v1.2.3 From 4d4738beea12f3f0e9e6fbf7cc433a42c8ea51e6 Mon Sep 17 00:00:00 2001 From: hermitsoft Date: Mon, 6 Mar 2017 16:56:32 +0100 Subject: Disabling BRAM commands in bitsream for LP384 --- icepack/icepack.cc | 75 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/icepack/icepack.cc b/icepack/icepack.cc index 5b6cb3b..a077e92 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -487,46 +487,49 @@ void FpgaConfig::write_bits(std::ostream &ofs) const int bram_chunk_size = 128; - debug("BRAM: Setting bank width to %d.\n", this->bram_width); - write_byte(ofs, crc_value, file_offset, 0x62); - write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); - write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); - - debug("BRAM: Setting bank height to %d.\n", this->bram_height); - write_byte(ofs, crc_value, file_offset, 0x72); - write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); - write_byte(ofs, crc_value, file_offset, bram_chunk_size); - - for (int bram_bank = 0; bram_bank < 4; bram_bank++) + if (this->bram_width && this->bram_height) { - debug("BRAM: Setting bank %d.\n", bram_bank); - write_byte(ofs, crc_value, file_offset, 0x11); - write_byte(ofs, crc_value, file_offset, bram_bank); + debug("BRAM: Setting bank width to %d.\n", this->bram_width); + write_byte(ofs, crc_value, file_offset, 0x62); + write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); + write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); + + debug("BRAM: Setting bank height to %d.\n", this->bram_height); + write_byte(ofs, crc_value, file_offset, 0x72); + write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); + write_byte(ofs, crc_value, file_offset, bram_chunk_size); - for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) + for (int bram_bank = 0; bram_bank < 4; bram_bank++) { - vector bram_bits; - for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) - for (int bram_x = 0; bram_x < this->bram_width; bram_x++) - bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); - - debug("BRAM: Setting bank offset to %d.\n", offset); - write_byte(ofs, crc_value, file_offset, 0x82); - write_byte(ofs, crc_value, file_offset, offset >> 8); - write_byte(ofs, crc_value, file_offset, offset); - - debug("BRAM: Writing bank %d data.\n", bram_bank); - write_byte(ofs, crc_value, file_offset, 0x01); - write_byte(ofs, crc_value, file_offset, 0x03); - for (int i = 0; i < int(bram_bits.size()); i += 8) { - uint8_t byte = 0; - for (int j = 0; j < 8; j++) - byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); - write_byte(ofs, crc_value, file_offset, byte); - } + debug("BRAM: Setting bank %d.\n", bram_bank); + write_byte(ofs, crc_value, file_offset, 0x11); + write_byte(ofs, crc_value, file_offset, bram_bank); - write_byte(ofs, crc_value, file_offset, 0x00); - write_byte(ofs, crc_value, file_offset, 0x00); + for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) + { + vector bram_bits; + for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) + for (int bram_x = 0; bram_x < this->bram_width; bram_x++) + bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); + + debug("BRAM: Setting bank offset to %d.\n", offset); + write_byte(ofs, crc_value, file_offset, 0x82); + write_byte(ofs, crc_value, file_offset, offset >> 8); + write_byte(ofs, crc_value, file_offset, offset); + + debug("BRAM: Writing bank %d data.\n", bram_bank); + write_byte(ofs, crc_value, file_offset, 0x01); + write_byte(ofs, crc_value, file_offset, 0x03); + for (int i = 0; i < int(bram_bits.size()); i += 8) { + uint8_t byte = 0; + for (int j = 0; j < 8; j++) + byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); + write_byte(ofs, crc_value, file_offset, byte); + } + + write_byte(ofs, crc_value, file_offset, 0x00); + write_byte(ofs, crc_value, file_offset, 0x00); + } } } -- cgit v1.2.3 From 293198458787f38cdee1caff88466123f122b769 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 7 Mar 2017 08:08:10 +0100 Subject: Fix trailing whitespace in icepack.cc --- icepack/icepack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icepack/icepack.cc b/icepack/icepack.cc index a077e92..3230d06 100644 --- a/icepack/icepack.cc +++ b/icepack/icepack.cc @@ -487,7 +487,7 @@ void FpgaConfig::write_bits(std::ostream &ofs) const int bram_chunk_size = 128; - if (this->bram_width && this->bram_height) + if (this->bram_width && this->bram_height) { debug("BRAM: Setting bank width to %d.\n", this->bram_width); write_byte(ofs, crc_value, file_offset, 0x62); -- cgit v1.2.3