<86>Jul 19 13:30:15 userdel[4056660]: delete user 'rooter' <86>Jul 19 13:30:15 groupadd[4057007]: group added to /etc/group: name=rooter, GID=636 <86>Jul 19 13:30:15 groupadd[4057007]: group added to /etc/gshadow: name=rooter <86>Jul 19 13:30:15 groupadd[4057007]: new group: name=rooter, GID=636 <86>Jul 19 13:30:15 useradd[4057035]: new user: name=rooter, UID=636, GID=636, home=/root, shell=/bin/bash <86>Jul 19 13:30:15 userdel[4057089]: delete user 'builder' <86>Jul 19 13:30:15 userdel[4057089]: removed group 'builder' owned by 'builder' <86>Jul 19 13:30:15 userdel[4057089]: removed shadow group 'builder' owned by 'builder' <86>Jul 19 13:30:15 groupadd[4057199]: group added to /etc/group: name=builder, GID=637 <86>Jul 19 13:30:15 groupadd[4057199]: group added to /etc/gshadow: name=builder <86>Jul 19 13:30:15 groupadd[4057199]: new group: name=builder, GID=637 <86>Jul 19 13:30:15 useradd[4057204]: new user: name=builder, UID=637, GID=637, home=/usr/src, shell=/bin/bash <13>Jul 19 13:30:17 rpmi: libgdbm-1.8.3-alt10 sisyphus+278100.1600.1.1 1626059138 installed <13>Jul 19 13:30:17 rpmi: libexpat-2.2.10-alt1 sisyphus+276608.100.1.2 1625153360 installed <13>Jul 19 13:30:17 rpmi: libp11-kit-0.23.15-alt2 sisyphus+278382.100.1.2 1626190687 installed <13>Jul 19 13:30:17 rpmi: libtasn1-4.17.0-alt1 sisyphus+276722.100.1.1 1625211286 installed <13>Jul 19 13:30:17 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Jul 19 13:30:17 rpmi: alternatives-0.5.1-alt1 sisyphus+278157.100.2.1 1626055790 installed <13>Jul 19 13:30:17 rpmi: ca-certificates-2021.06.03-alt1 sisyphus+273509.400.1.1 1622736045 installed <13>Jul 19 13:30:17 rpmi: ca-trust-0.1.2-alt1 sisyphus+233348.100.1.1 1561653823 installed <13>Jul 19 13:30:17 rpmi: p11-kit-trust-0.23.15-alt2 sisyphus+278382.100.1.2 1626190687 installed <13>Jul 19 13:30:17 rpmi: libcrypto1.1-1.1.1k-alt1 sisyphus+279286.100.1.1 1626469643 installed <13>Jul 19 13:30:17 rpmi: libssl1.1-1.1.1k-alt1 sisyphus+279286.100.1.1 1626469643 installed <13>Jul 19 13:30:17 rpmi: python3-3.9.6-alt1 sisyphus+276295.100.1.1 1624964545 installed <13>Jul 19 13:30:18 rpmi: python3-base-3.9.6-alt1 sisyphus+276295.100.1.1 1624964545 installed <13>Jul 19 13:30:18 rpmi: libpython3-3.9.6-alt1 sisyphus+276295.100.1.1 1624964545 installed <13>Jul 19 13:30:18 rpmi: tests-for-installed-python3-pkgs-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed <13>Jul 19 13:30:18 rpmi: rpm-build-python3-0.1.17-alt1 sisyphus+271082.100.1.1 1619820927 installed <13>Jul 19 13:30:20 rpmi: libusb-1.0.24-alt1 sisyphus+279483.100.1.1 1626549443 installed <13>Jul 19 13:30:20 rpmi: libftdi1-1.5-alt2 sisyphus+279318.100.1.2 1626503438 installed <13>Jul 19 13:30:20 rpmi: libusb-devel-1.0.24-alt1 sisyphus+279483.100.1.1 1626549443 installed <13>Jul 19 13:30:20 rpmi: gcc-c++-common-1.4.27-alt1 sisyphus+278099.1300.1.1 1626028636 installed <13>Jul 19 13:30:21 rpmi: libstdc++10-devel-10.3.1-alt2 sisyphus+277353.100.2.1 1625526466 installed <13>Jul 19 13:30:21 rpmi: gcc10-c++-10.3.1-alt2 sisyphus+277353.100.2.1 1625526466 installed <13>Jul 19 13:30:21 rpmi: gcc-c++-10-alt1 sisyphus+263054.200.3.1 1607516810 installed <13>Jul 19 13:30:21 rpmi: libftdi1-devel-1.5-alt2 sisyphus+279318.100.1.2 1626503438 installed Building target platforms: i586 Building for target i586 Wrote: /usr/src/in/nosrpm/icestorm-0.0.0.777.gc495861-alt1.nosrc.rpm (w1.gzdio) Installing icestorm-0.0.0.777.gc495861-alt1.src.rpm Building target platforms: i586 Building for target i586 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.71040 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf icestorm-0.0.0.777.gc495861 + echo 'Source #0 (icestorm-0.0.0.777.gc495861.tar):' Source #0 (icestorm-0.0.0.777.gc495861.tar): + /bin/tar -xf /usr/src/RPM/SOURCES/icestorm-0.0.0.777.gc495861.tar + cd icestorm-0.0.0.777.gc495861 + /bin/chmod -c -Rf u+rwX,go-w . + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.71040 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd icestorm-0.0.0.777.gc495861 ++ pkg-config --cflags libftdi1 ++ pkg-config --libs libftdi1 + make -j8 CC=gcc CXX=g++ 'CFLAGS=-pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -I/usr/include/libftdi1 -I/usr/include/libusb-1.0' 'CXXFLAGS=-pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra' 'LDLIBS=-lftdi1 -lusb-1.0 -lm' make -C icebox all make -C icepack all make -C icemulti all make -C icepll all make -C icebram all make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -c -o icepll.o icepll.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' g++ -o icepll icepll.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' make -C icetime all make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -c -o icemulti.o icemulti.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' g++ -o icemulti icemulti.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' make -C iceprog all make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' gcc -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -I/usr/include/libftdi1 -I/usr/include/libusb-1.0 -c -o iceprog.o iceprog.c make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -c -o icebram.o icebram.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' g++ -o icebram icebram.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' gcc -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -I/usr/include/libftdi1 -I/usr/include/libusb-1.0 -c -o mpsse.o mpsse.c mpsse.c: In function 'mpsse_init': mpsse.c:317:2: warning: 'ftdi_usb_purge_buffers' is deprecated [-Wdeprecated-declarations] 317 | if (ftdi_usb_purge_buffers(&mpsse_ftdic)) { | ^~ In file included from mpsse.c:26: /usr/include/libftdi1/ftdi.h:566:20: note: declared here 566 | int DEPRECATED(ftdi_usb_purge_buffers(struct ftdi_context *ftdi)); | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/libftdi1/ftdi.h:247:55: note: in definition of macro 'DEPRECATED' 247 | #define DEPRECATED(func) __attribute__ ((deprecated)) func | ^~~~ make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' gcc -o iceprog iceprog.o mpsse.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -c -o icepack.o icepack.cc icepack.cc: In member function 'void FpgaConfig::write_ascii(std::ostream&) const': icepack.cc:53:41: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'std::vector >::size_type' {aka 'unsigned int'} [-Wformat=] 53 | #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | | 56 | string vstringf(const char *fmt, va_list ap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | { | ~ 58 | string string; | ~~~~~~~~~~~~~~ 59 | char *str = NULL; | ~~~~~~~~~~~~~~~~~ 60 | | 61 | #ifdef _WIN32 | ~~~~~~~~~~~~~ 62 | int sz = 64, rc; | ~~~~~~~~~~~~~~~~ 63 | while (1) { | ~~~~~~~~~~~ 64 | va_list apc; | ~~~~~~~~~~~~ 65 | va_copy(apc, ap); | ~~~~~~~~~~~~~~~~~ 66 | str = (char*)realloc(str, sz); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 67 | rc = vsnprintf(str, sz, fmt, apc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | va_end(apc); | ~~~~~~~~~~~~ 69 | if (rc >= 0 && rc < sz) | ~~~~~~~~~~~~~~~~~~~~~~~ 70 | break; | ~~~~~~ 71 | sz *= 2; | ~~~~~~~~ 72 | } | ~ 73 | #else | ~~~~~ 74 | if (vasprintf(&str, fmt, ap) < 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | str = NULL; | ~~~~~~~~~~~ 76 | #endif | ~~~~~~ 77 | | 78 | if (str != NULL) { | ~~~~~~~~~~~~~~~~~~ 79 | string = str; | ~~~~~~~~~~~~~ 80 | free(str); | ~~~~~~~~~~ 81 | } | ~ 82 | | 83 | return string; | ~~~~~~~~~~~~~~ 84 | } | ~ 85 | | 86 | string stringf(const char *fmt, ...) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | { | ~ 88 | string string; | ~~~~~~~~~~~~~~ 89 | va_list ap; | ~~~~~~~~~~~ 90 | | 91 | va_start(ap, fmt); | ~~~~~~~~~~~~~~~~~~ 92 | string = vstringf(fmt, ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | va_end(ap); | ~~~~~~~~~~~ 94 | | 95 | return string; | ~~~~~~~~~~~~~~ 96 | } | ~ 97 | | 98 | // ================================================================== | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 | // FpgaConfig stuff | ~~~~~~~~~~~~~~~~~~~ 100 | | 101 | struct FpgaConfig | ~~~~~~~~~~~~~~~~~ 102 | { | ~ 103 | string device; | ~~~~~~~~~~~~~~ 104 | string freqrange; | ~~~~~~~~~~~~~~~~~ 105 | string nosleep; | ~~~~~~~~~~~~~~~ 106 | string warmboot; | ~~~~~~~~~~~~~~~~ 107 | | 108 | // cram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 109 | int cram_width, cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | vector>> cram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | | 112 | // bram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 113 | int bram_width, bram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | vector>> bram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | bool skip_bram_initialization; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | | 117 | // data before preamble | ~~~~~~~~~~~~~~~~~~~~~~~ 118 | vector initblop; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 119 | | 120 | // bitstream i/o | ~~~~~~~~~~~~~~~~ 121 | void read_bits(std::istream &ifs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | void write_bits(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 123 | | 124 | // icebox i/o | ~~~~~~~~~~~~~ 125 | void read_ascii(std::istream &ifs, bool nosleep); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 | void write_ascii(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 | | 128 | // netpbm i/o | ~~~~~~~~~~~~~ 129 | void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 130 | void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | | 132 | // query chip type metadata | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 133 | int chip_width() const; | ~~~~~~~~~~~~~~~~~~~~~~~ 134 | int chip_height() const; | ~~~~~~~~~~~~~~~~~~~~~~~~ 135 | vector chip_cols() const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136 | | 137 | // query tile metadata | ~~~~~~~~~~~~~~~~~~~~~~ 138 | string tile_type(int x, int y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | int tile_width(const string &type) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | | 141 | // cram bit manipulation | ~~~~~~~~~~~~~~~~~~~~~~~~ 142 | void cram_clear(); | ~~~~~~~~~~~~~~~~~~ 143 | void cram_fill_tiles(); | ~~~~~~~~~~~~~~~~~~~~~~~ 144 | void cram_checkerboard(int m = 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 145 | }; | ~~ 146 | | 147 | struct CramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 148 | { | ~ 149 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 150 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 151 | | 152 | string tile_type; | ~~~~~~~~~~~~~~~~~ 153 | int tile_width; | ~~~~~~~~~~~~~~~ 154 | int column_width; | ~~~~~~~~~~~~~~~~~ 155 | | 156 | bool left_right_io; | ~~~~~~~~~~~~~~~~~~~ 157 | bool right_half; | ~~~~~~~~~~~~~~~~ 158 | bool top_half; | ~~~~~~~~~~~~~~ 159 | | 160 | int bank_num; | ~~~~~~~~~~~~~ 161 | int bank_tx; | ~~~~~~~~~~~~ 162 | int bank_ty; | ~~~~~~~~~~~~ 163 | int bank_xoff; | ~~~~~~~~~~~~~~ 164 | int bank_yoff; | ~~~~~~~~~~~~~~ 165 | | 166 | CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167 | void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 168 | }; | ~~ 169 | | 170 | struct BramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 171 | { | ~ 172 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 173 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 174 | | 175 | int bank_num; | ~~~~~~~~~~~~~ 176 | int bank_off; | ~~~~~~~~~~~~~ 177 | | 178 | BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 179 | void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 180 | }; | ~~ 181 | | 182 | static void update_crc16(uint16_t &crc, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 | { | ~ 184 | // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 | for (int i = 7; i >= 0; i--) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 186 | uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187 | crc = (crc << 1) ^ xor_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | } | ~ 189 | } | ~ 190 | | 191 | static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 192 | { | ~ 193 | int byte = ifs.get(); | ~~~~~~~~~~~~~~~~~~~~~ 194 | | 195 | if (byte < 0) | ~~~~~~~~~~~~~ 196 | error("Unexpected end of file.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 197 | | 198 | file_offset++; | ~~~~~~~~~~~~~~ 199 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 200 | | 201 | return byte; | ~~~~~~~~~~~~ 202 | } | ~ 203 | | 204 | static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 205 | { | ~ 206 | ofs << byte; | ~~~~~~~~~~~~ 207 | file_offset++; | ~~~~~~~~~~~~~~ 208 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 209 | } | ~ 210 | | 211 | void FpgaConfig::read_bits(std::istream &ifs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 212 | { | ~ 213 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 214 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 215 | | 216 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | info("Parsing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 218 | | 219 | // skip initial comments until preamble is found | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 220 | | 221 | uint32_t preamble = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 222 | | 223 | while (1) | ~~~~~~~~~ 224 | { | ~ 225 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 226 | preamble = (preamble << 8) | byte; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 227 | if (preamble == 0xffffffff) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 | error("No preamble found in bitstream.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 | if (preamble == 0x7EAA997E) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230 | info("Found preamble at offset %d.\n", file_offset-4); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 | break; | ~~~~~~ 232 | } | ~ 233 | initblop.push_back(byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 234 | } | ~ 235 | | 236 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 237 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 238 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 239 | | 240 | // main parser loop | ~~~~~~~~~~~~~~~~~~~ 241 | | 242 | int current_bank = 0; | ~~~~~~~~~~~~~~~~~~~~~ 243 | int current_width = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 244 | int current_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 245 | int current_offset = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 246 | bool wakeup = false; | ~~~~~~~~~~~~~~~~~~~~ 247 | | 248 | this->cram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 249 | this->cram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 250 | | 251 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 252 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 253 | | 254 | while (!wakeup) | ~~~~~~~~~~~~~~~ 255 | { | ~ 256 | // one command byte. the lower 4 bits of the command byte specify | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | // the length of the command payload. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | | 259 | uint8_t command = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 | uint32_t payload = 0; | ~~~~~~~~~~~~~~~~~~~~~ 261 | | 262 | for (int i = 0; i < (command & 0x0f); i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 263 | payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 264 | | 265 | debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 266 | command, 2*(command & 0x0f), payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 267 | | 268 | uint16_t end_token; | ~~~~~~~~~~~~~~~~~~~ 269 | | 270 | switch (command & 0xf0) | ~~~~~~~~~~~~~~~~~~~~~~~ 271 | { | ~ 272 | case 0x00: | ~~~~~~~~~~ 273 | switch (payload) | ~~~~~~~~~~~~~~~~ 274 | { | ~ 275 | case 0x01: | ~~~~~~~~~~ 276 | info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 277 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 278 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 279 | | 280 | this->cram_width = std::max(this->cram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281 | this->cram_height = std::max(this->cram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 282 | | 283 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 284 | this->cram[current_bank].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 285 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 286 | this->cram[current_bank][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 287 | | 288 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 290 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 291 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 293 | this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 294 | } | ~ 295 | } | ~ 296 | | 297 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 299 | if (end_token) | ~~~~~~~~~~~~~~ 300 | error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 301 | break; | ~~~~~~ 302 | | 303 | case 0x03: | ~~~~~~~~~~ 304 | info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 305 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 306 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 307 | | 308 | this->bram_width = std::max(this->bram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 309 | this->bram_height = std::max(this->bram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 310 | | 311 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 312 | this->bram[current_bank].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 313 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 314 | this->bram[current_bank][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 315 | | 316 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 317 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 318 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 319 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 320 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 321 | this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 322 | } | ~ 323 | } | ~ 324 | | 325 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 326 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 327 | if (end_token) | ~~~~~~~~~~~~~~ 328 | error("Expected 0x0000 after BRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329 | break; | ~~~~~~ 330 | | 331 | case 0x05: | ~~~~~~~~~~ 332 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 333 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 334 | break; | ~~~~~~ 335 | | 336 | case 0x06: | ~~~~~~~~~~ 337 | info("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~ 338 | wakeup = true; | ~~~~~~~~~~~~~~ 339 | break; | ~~~~~~ 340 | | 341 | default: | ~~~~~~~~ 342 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 343 | } | ~ 344 | break; | ~~~~~~ 345 | | 346 | case 0x10: | ~~~~~~~~~~ 347 | current_bank = payload; | ~~~~~~~~~~~~~~~~~~~~~~~ 348 | debug("Set bank to %d.\n", current_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 | break; | ~~~~~~ 350 | | 351 | case 0x20: | ~~~~~~~~~~ 352 | if (crc_value != 0) | ~~~~~~~~~~~~~~~~~~~ 353 | error("CRC Check FAILED.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 354 | info("CRC Check OK.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~ 355 | break; | ~~~~~~ 356 | | 357 | case 0x50: | ~~~~~~~~~~ 358 | if (payload == 0) | ~~~~~~~~~~~~~~~~~ 359 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 360 | else if (payload == 1) | ~~~~~~~~~~~~~~~~~~~~~~ 361 | this->freqrange = "medium"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 362 | else if (payload == 2) | ~~~~~~~~~~~~~~~~~~~~~~ 363 | this->freqrange = "high"; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 364 | else | ~~~~ 365 | error("Unknown freqrange payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 366 | info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 367 | break; | ~~~~~~ 368 | | 369 | case 0x60: | ~~~~~~~~~~ 370 | current_width = payload + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 | debug("Setting bank width to %d.\n", current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 372 | break; | ~~~~~~ 373 | | 374 | case 0x70: | ~~~~~~~~~~ 375 | current_height = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 376 | debug("Setting bank height to %d.\n", current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 377 | break; | ~~~~~~ 378 | | 379 | case 0x80: | ~~~~~~~~~~ 380 | current_offset = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 381 | debug("Setting bank offset to %d.\n", current_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 382 | break; | ~~~~~~ 383 | | 384 | case 0x90: | ~~~~~~~~~~ 385 | switch(payload) | ~~~~~~~~~~~~~~~ 386 | { | ~ 387 | case 0: | ~~~~~~~ 388 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 389 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 390 | break; | ~~~~~~ 391 | case 1: | ~~~~~~~ 392 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 394 | break; | ~~~~~~ 395 | case 32: | ~~~~~~~~ 396 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 397 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 398 | break; | ~~~~~~ 399 | case 33: | ~~~~~~~~ 400 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 401 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 402 | break; | ~~~~~~ 403 | default: | ~~~~~~~~ 404 | error("Unknown warmboot/nosleep payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 405 | } | ~ 406 | info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 407 | break; | ~~~~~~ 408 | | 409 | default: | ~~~~~~~~ 410 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 411 | } | ~ 412 | } | ~ 413 | | 414 | if (this->cram_width == 182 && this->cram_height == 80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 415 | this->device = "384"; | ~~~~~~~~~~~~~~~~~~~~~ 416 | else if (this->cram_width == 332 && this->cram_height == 144) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 417 | this->device = "1k"; | ~~~~~~~~~~~~~~~~~~~~ 418 | else if (this->cram_width == 872 && this->cram_height == 272) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 419 | this->device = "8k"; | ~~~~~~~~~~~~~~~~~~~~ 420 | else if (this->cram_width == 692 && this->cram_height == 336) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 421 | this->device = "5k"; | ~~~~~~~~~~~~~~~~~~~~ 422 | else if (this->cram_width == 692 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 423 | this->device = "u4k"; | ~~~~~~~~~~~~~~~~~~~~~ 424 | else if (this->cram_width == 656 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 425 | this->device = "lm4k"; | ~~~~~~~~~~~~~~~~~~~~~~ 426 | else | ~~~~ 427 | error("Failed to detect chip type.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 | | 429 | info("Chip type is '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 430 | } | ~ 431 | | 432 | void FpgaConfig::write_bits(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 433 | { | ~ 434 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 435 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 436 | | 437 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 438 | info("Writing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 439 | | 440 | for (auto byte : this->initblop) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 | ofs << byte; | ~~~~~~~~~~~~ 442 | | 443 | debug("Writing preamble.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 444 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 445 | write_byte(ofs, crc_value, file_offset, 0xAA); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 446 | write_byte(ofs, crc_value, file_offset, 0x99); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 447 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 448 | | 449 | debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 450 | write_byte(ofs, crc_value, file_offset, 0x51); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 451 | if (this->freqrange == "low") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 452 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 453 | else if (this->freqrange == "medium") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 454 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 455 | else if (this->freqrange == "high") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 | write_byte(ofs, crc_value, file_offset, 0x02); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 457 | else | ~~~~ 458 | error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 459 | | 460 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 461 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 462 | write_byte(ofs, crc_value, file_offset, 0x05); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 463 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 464 | | 465 | { | ~ 466 | uint8_t nosleep_flag; | ~~~~~~~~~~~~~~~~~~~~~ 467 | debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 468 | write_byte(ofs, crc_value, file_offset, 0x92); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 469 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 470 | | 471 | if (this->nosleep == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 | nosleep_flag = 0; | ~~~~~~~~~~~~~~~~~ 473 | else if (this->nosleep == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 474 | nosleep_flag = 1; | ~~~~~~~~~~~~~~~~~ 475 | else | ~~~~ 476 | error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 477 | | 478 | if (this->warmboot == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 479 | write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 480 | else if (this->warmboot == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 481 | write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 482 | else | ~~~~ 483 | error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 484 | } | ~ 485 | | 486 | debug("CRAM: Setting bank width to %d.\n", this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 487 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 488 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 489 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 490 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 491 | debug("CRAM: Setting bank height to %d.\n", this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 492 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 493 | write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 494 | write_byte(ofs, crc_value, file_offset, this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 495 | } | ~ 496 | | 497 | debug("CRAM: Setting bank offset to 0.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 498 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 500 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 501 | | 502 | for (int cram_bank = 0; cram_bank < 4; cram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 503 | { | ~ 504 | vector cram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 505 | int height = this->cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 506 | if(this->device == "5k" && ((cram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 507 | height = height / 2 + 8; | ~~~~~~~~~~~~~~~~~~~~~~~~ 508 | for (int cram_y = 0; cram_y < height; cram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 509 | for (int cram_x = 0; cram_x < this->cram_width; cram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 510 | cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 511 | | 512 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 513 | debug("CRAM: Setting bank height to %d.\n", height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 514 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 515 | write_byte(ofs, crc_value, file_offset, height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 516 | write_byte(ofs, crc_value, file_offset, height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 517 | } | ~ 518 | | 519 | debug("CRAM: Setting bank %d.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 520 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 521 | write_byte(ofs, crc_value, file_offset, cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 522 | | 523 | debug("CRAM: Writing bank %d data.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 524 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 525 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 526 | for (int i = 0; i < int(cram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 527 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 528 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 529 | byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 530 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 531 | } | ~ 532 | | 533 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 534 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 535 | } | ~ 536 | | 537 | int bram_chunk_size = 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 538 | | 539 | if (this->bram_width && this->bram_height) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 540 | { | ~ 541 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 542 | debug("BRAM: Setting bank width to %d.\n", this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 543 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 544 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 545 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 546 | } | ~ 547 | | 548 | | 549 | debug("BRAM: Setting bank height to %d.\n", this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 550 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 551 | write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 552 | write_byte(ofs, crc_value, file_offset, bram_chunk_size); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 553 | | 554 | for (int bram_bank = 0; bram_bank < 4; bram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 555 | { | ~ 556 | debug("BRAM: Setting bank %d.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 557 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558 | write_byte(ofs, crc_value, file_offset, bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 559 | | 560 | for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 561 | { | ~ 562 | vector bram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 563 | int width = this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 564 | if(this->device == "5k" && ((bram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 565 | width = width / 2; | ~~~~~~~~~~~~~~~~~~ 566 | for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 567 | for (int bram_x = 0; bram_x < width; bram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 | bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 569 | | 570 | debug("BRAM: Setting bank offset to %d.\n", offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 571 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 572 | write_byte(ofs, crc_value, file_offset, offset >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 573 | write_byte(ofs, crc_value, file_offset, offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 574 | | 575 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 576 | debug("BRAM: Setting bank width to %d.\n", width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 577 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 578 | write_byte(ofs, crc_value, file_offset, (width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 579 | write_byte(ofs, crc_value, file_offset, (width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 580 | } | ~ 581 | | 582 | | 583 | if (!this->skip_bram_initialization) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 584 | debug("BRAM: Writing bank %d data.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 585 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 586 | write_byte(ofs, crc_value, file_offset, 0x03); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 587 | for (int i = 0; i < int(bram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 588 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 589 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 590 | byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 591 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 592 | } | ~ 593 | | 594 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 595 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 596 | } | ~ 597 | } | ~ 598 | } | ~ 599 | } | ~ 600 | | 601 | debug("Writing CRC value.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 602 | write_byte(ofs, crc_value, file_offset, 0x22); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 603 | uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 604 | write_byte(ofs, crc_value, file_offset, crc_hi); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 605 | write_byte(ofs, crc_value, file_offset, crc_lo); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 606 | | 607 | debug("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~~ 608 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 609 | write_byte(ofs, crc_value, file_offset, 0x06); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 610 | | 611 | debug("Padding byte.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 612 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 613 | } | ~ 614 | | 615 | void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 616 | { | ~ 617 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 618 | info("Parsing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 619 | | 620 | bool got_device = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 621 | this->cram.clear(); | ~~~~~~~~~~~~~~~~~~~ 622 | this->bram.clear(); | ~~~~~~~~~~~~~~~~~~~ 623 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 624 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 625 | | 626 | bool reuse_line = true; | ~~~~~~~~~~~~~~~~~~~~~~~ 627 | string line, command; | ~~~~~~~~~~~~~~~~~~~~~ 628 | | 629 | while (reuse_line || getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 630 | { | ~ 631 | reuse_line = false; | ~~~~~~~~~~~~~~~~~~~ 632 | | 633 | std::istringstream is(line); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 634 | is >> command; | ~~~~~~~~~~~~~~ 635 | | 636 | if (command.empty()) | ~~~~~~~~~~~~~~~~~~~~ 637 | continue; | ~~~~~~~~~ 638 | | 639 | debug("Next command: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 640 | | 641 | if (command == ".comment") | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 642 | { | ~ 643 | this->initblop.clear(); | ~~~~~~~~~~~~~~~~~~~~~~~ 644 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 645 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 646 | | 647 | while (getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 648 | { | ~ 649 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 650 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 651 | break; | ~~~~~~ 652 | } | ~ 653 | | 654 | for (auto ch : line) | ~~~~~~~~~~~~~~~~~~~~ 655 | this->initblop.push_back(ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 656 | this->initblop.push_back(0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 657 | } | ~ 658 | | 659 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 660 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 661 | continue; | ~~~~~~~~~ 662 | } | ~ 663 | | 664 | if (command == ".device") | ~~~~~~~~~~~~~~~~~~~~~~~~~ 665 | { | ~ 666 | if (got_device) | ~~~~~~~~~~~~~~~ 667 | error("More than one .device statement.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 668 | | 669 | is >> this->device; | ~~~~~~~~~~~~~~~~~~~ 670 | | 671 | if (this->device == "384") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 672 | this->cram_width = 182; | ~~~~~~~~~~~~~~~~~~~~~~~ 673 | this->cram_height = 80; | ~~~~~~~~~~~~~~~~~~~~~~~ 674 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 675 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 676 | } else | ~~~~~~ 677 | if (this->device == "1k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | this->cram_width = 332; | ~~~~~~~~~~~~~~~~~~~~~~~ 679 | this->cram_height = 144; | ~~~~~~~~~~~~~~~~~~~~~~~~ 680 | this->bram_width = 64; | ~~~~~~~~~~~~~~~~~~~~~~ 681 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 682 | } else | ~~~~~~ 683 | if (this->device == "8k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 684 | this->cram_width = 872; | ~~~~~~~~~~~~~~~~~~~~~~~ 685 | this->cram_height = 272; | ~~~~~~~~~~~~~~~~~~~~~~~~ 686 | this->bram_width = 128; | ~~~~~~~~~~~~~~~~~~~~~~~ 687 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 688 | } else | ~~~~~~ 689 | if (this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 690 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 691 | this->cram_height = 336; | ~~~~~~~~~~~~~~~~~~~~~~~~ 692 | this->bram_width = 160; | ~~~~~~~~~~~~~~~~~~~~~~~ 693 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 694 | } else | ~~~~~~ 695 | if (this->device == "u4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 696 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 697 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 698 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 699 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 700 | } else | ~~~~~~ 701 | if (this->device == "lm4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 702 | this->cram_width = 656; | ~~~~~~~~~~~~~~~~~~~~~~~ 703 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 704 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 705 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 706 | } else | ~~~~~~ 707 | error("Unsupported chip type '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 708 | | 709 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 710 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 712 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 713 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 714 | this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 715 | } | ~ 716 | | 717 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 718 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 719 | int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 720 | this->bram[i].resize(width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 721 | for (int x = 0; x < width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 722 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 723 | } | ~ 724 | } else { | ~~~~~~~~ 725 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 726 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 727 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 728 | this->cram[i][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 729 | } | ~ 730 | | 731 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 732 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 733 | this->bram[i].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 734 | for (int x = 0; x < this->bram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 735 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 736 | } | ~ 737 | } | ~ 738 | | 739 | | 740 | got_device = true; | ~~~~~~~~~~~~~~~~~~ 741 | continue; | ~~~~~~~~~ 742 | } | ~ 743 | | 744 | if (command == ".warmboot") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 745 | { | ~ 746 | is >> this->warmboot; | ~~~~~~~~~~~~~~~~~~~~~ 747 | | 748 | if (this->warmboot != "disabled" && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 749 | this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 750 | error("Unknown warmboot setting '%s'.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 751 | this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~ 752 | | 753 | continue; | ~~~~~~~~~ 754 | } | ~ 755 | | 756 | // No ".nosleep" section despite sharing the same byte as .warmboot. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 757 | // ".nosleep" is specified when icepack is invoked, which is too late. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 758 | // So we inject the section based on command line argument. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 759 | if (nosleep) | ~~~~~~~~~~~~ 760 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 761 | else | ~~~~ 762 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 763 | | 764 | if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 765 | { | ~ 766 | if (!got_device) | ~~~~~~~~~~~~~~~~ 767 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 768 | | 769 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 770 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 771 | | 772 | CramIndexConverter cic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 773 | | 774 | if (("." + cic.tile_type + "_tile") != command) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 775 | error("Got %s statement for %s tile %d %d.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 776 | command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 777 | | 778 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 779 | { | ~ 780 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 781 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 782 | break; | ~~~~~~ 783 | } | ~ 784 | | 785 | for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 786 | if (line[bit_x] == '1') { | ~~~~~~~~~~~~~~~~~~~~~~~~~ 787 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 788 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 789 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 790 | } | ~ 791 | } | ~ 792 | | 793 | continue; | ~~~~~~~~~ 794 | } | ~ 795 | | 796 | if (command == ".ram_data") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 797 | { | ~ 798 | if (!got_device) | ~~~~~~~~~~~~~~~~ 799 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 800 | | 801 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 802 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 803 | | 804 | BramIndexConverter bic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 805 | | 806 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 807 | { | ~ 808 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 809 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 810 | break; | ~~~~~~ 811 | } | ~ 812 | | 813 | for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 814 | { | ~ 815 | int value = -1; | ~~~~~~~~~~~~~~~ 816 | if ('0' <= line[ch_idx] && line[ch_idx] <= '9') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 817 | value = line[ch_idx] - '0'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 818 | if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 819 | value = line[ch_idx] - 'a' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 820 | if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 821 | value = line[ch_idx] - 'A' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | if (value < 0) | ~~~~~~~~~~~~~~ 823 | error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 824 | | 825 | for (int i = 0; i < 4; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 826 | if ((value & (1 << i)) != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 827 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 828 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 829 | this->bram[bram_bank][bram_x][bram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 830 | } | ~ 831 | } | ~ 832 | } | ~ 833 | | 834 | continue; | ~~~~~~~~~ 835 | } | ~ 836 | | 837 | if (command == ".extra_bit") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 838 | { | ~ 839 | if (!got_device) | ~~~~~~~~~~~~~~~~ 840 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 841 | | 842 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 843 | is >> cram_bank >> cram_x >> cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 844 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 845 | | 846 | continue; | ~~~~~~~~~ 847 | } | ~ 848 | | 849 | if (command == ".sym") | ~~~~~~~~~~~~~~~~~~~~~~ 850 | continue; | ~~~~~~~~~ 851 | | 852 | if (command.substr(0, 1) == ".") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 853 | error("Unknown statement: %s\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 854 | error("Unexpected data line: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 855 | } | ~ 856 | } | ~ 857 | | 858 | void FpgaConfig::write_ascii(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | { | ~ 860 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 861 | info("Writing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 862 | | 863 | ofs << ".comment"; | ~~~~~~~~~~~~~~~~~~ 864 | bool insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 865 | for (auto ch : this->initblop) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 866 | if (ch == 0) { | ~~~~~~~~~~~~~~ 867 | insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~ 868 | } else if (ch == 0xff) { | ~~~~~~~~~~~~~~~~~~~~~~~~ 869 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 870 | } else { | ~~~~~~~~ 871 | if (insert_newline) | ~~~~~~~~~~~~~~~~~~~ 872 | ofs << '\n'; | ~~~~~~~~~~~~ 873 | ofs << ch; | ~~~~~~~~~~ 874 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 875 | } | ~ 876 | } | ~ 877 | | 878 | ofs << stringf("\n.device %s\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 879 | if (this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 880 | ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 881 | | 882 | // As "nosleep" is an icepack command, we do not write out a ".nosleep" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 883 | // section. However, we parse it in read_bits() and notify the user in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 884 | // info. | ~~~~~~~~ 885 | | 886 | typedef std::tuple tile_bit_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 887 | std::set tile_bits; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 888 | | 889 | for (int y = 0; y <= this->chip_height()+1; y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 890 | for (int x = 0; x <= this->chip_width()+1; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 891 | { | ~ 892 | CramIndexConverter cic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 893 | | 894 | if (cic.tile_type == "corner" || cic.tile_type == "unsupported") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 895 | continue; | ~~~~~~~~~ 896 | | 897 | ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 898 | | 899 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 900 | for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 901 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 902 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 903 | tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 904 | if (cram_x > int(this->cram[cram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | std::vector >::size_type {aka unsigned int} icepack.cc:905:6: note: in expansion of macro 'error' 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ^~~~~ icepack.cc:905:60: note: format string is defined here 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ~~^ | | | long unsigned int | %u icepack.cc:53:41: warning: format '%lu' expects argument of type 'long unsigned int', but argument 7 has type 'std::vector::size_type' {aka 'unsigned int'} [-Wformat=] 53 | #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | | 56 | string vstringf(const char *fmt, va_list ap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | { | ~ 58 | string string; | ~~~~~~~~~~~~~~ 59 | char *str = NULL; | ~~~~~~~~~~~~~~~~~ 60 | | 61 | #ifdef _WIN32 | ~~~~~~~~~~~~~ 62 | int sz = 64, rc; | ~~~~~~~~~~~~~~~~ 63 | while (1) { | ~~~~~~~~~~~ 64 | va_list apc; | ~~~~~~~~~~~~ 65 | va_copy(apc, ap); | ~~~~~~~~~~~~~~~~~ 66 | str = (char*)realloc(str, sz); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 67 | rc = vsnprintf(str, sz, fmt, apc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | va_end(apc); | ~~~~~~~~~~~~ 69 | if (rc >= 0 && rc < sz) | ~~~~~~~~~~~~~~~~~~~~~~~ 70 | break; | ~~~~~~ 71 | sz *= 2; | ~~~~~~~~ 72 | } | ~ 73 | #else | ~~~~~ 74 | if (vasprintf(&str, fmt, ap) < 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | str = NULL; | ~~~~~~~~~~~ 76 | #endif | ~~~~~~ 77 | | 78 | if (str != NULL) { | ~~~~~~~~~~~~~~~~~~ 79 | string = str; | ~~~~~~~~~~~~~ 80 | free(str); | ~~~~~~~~~~ 81 | } | ~ 82 | | 83 | return string; | ~~~~~~~~~~~~~~ 84 | } | ~ 85 | | 86 | string stringf(const char *fmt, ...) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | { | ~ 88 | string string; | ~~~~~~~~~~~~~~ 89 | va_list ap; | ~~~~~~~~~~~ 90 | | 91 | va_start(ap, fmt); | ~~~~~~~~~~~~~~~~~~ 92 | string = vstringf(fmt, ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | va_end(ap); | ~~~~~~~~~~~ 94 | | 95 | return string; | ~~~~~~~~~~~~~~ 96 | } | ~ 97 | | 98 | // ================================================================== | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 | // FpgaConfig stuff | ~~~~~~~~~~~~~~~~~~~ 100 | | 101 | struct FpgaConfig | ~~~~~~~~~~~~~~~~~ 102 | { | ~ 103 | string device; | ~~~~~~~~~~~~~~ 104 | string freqrange; | ~~~~~~~~~~~~~~~~~ 105 | string nosleep; | ~~~~~~~~~~~~~~~ 106 | string warmboot; | ~~~~~~~~~~~~~~~~ 107 | | 108 | // cram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 109 | int cram_width, cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | vector>> cram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | | 112 | // bram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 113 | int bram_width, bram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | vector>> bram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | bool skip_bram_initialization; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | | 117 | // data before preamble | ~~~~~~~~~~~~~~~~~~~~~~~ 118 | vector initblop; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 119 | | 120 | // bitstream i/o | ~~~~~~~~~~~~~~~~ 121 | void read_bits(std::istream &ifs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | void write_bits(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 123 | | 124 | // icebox i/o | ~~~~~~~~~~~~~ 125 | void read_ascii(std::istream &ifs, bool nosleep); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 | void write_ascii(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 | | 128 | // netpbm i/o | ~~~~~~~~~~~~~ 129 | void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 130 | void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | | 132 | // query chip type metadata | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 133 | int chip_width() const; | ~~~~~~~~~~~~~~~~~~~~~~~ 134 | int chip_height() const; | ~~~~~~~~~~~~~~~~~~~~~~~~ 135 | vector chip_cols() const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136 | | 137 | // query tile metadata | ~~~~~~~~~~~~~~~~~~~~~~ 138 | string tile_type(int x, int y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | int tile_width(const string &type) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | | 141 | // cram bit manipulation | ~~~~~~~~~~~~~~~~~~~~~~~~ 142 | void cram_clear(); | ~~~~~~~~~~~~~~~~~~ 143 | void cram_fill_tiles(); | ~~~~~~~~~~~~~~~~~~~~~~~ 144 | void cram_checkerboard(int m = 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 145 | }; | ~~ 146 | | 147 | struct CramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 148 | { | ~ 149 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 150 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 151 | | 152 | string tile_type; | ~~~~~~~~~~~~~~~~~ 153 | int tile_width; | ~~~~~~~~~~~~~~~ 154 | int column_width; | ~~~~~~~~~~~~~~~~~ 155 | | 156 | bool left_right_io; | ~~~~~~~~~~~~~~~~~~~ 157 | bool right_half; | ~~~~~~~~~~~~~~~~ 158 | bool top_half; | ~~~~~~~~~~~~~~ 159 | | 160 | int bank_num; | ~~~~~~~~~~~~~ 161 | int bank_tx; | ~~~~~~~~~~~~ 162 | int bank_ty; | ~~~~~~~~~~~~ 163 | int bank_xoff; | ~~~~~~~~~~~~~~ 164 | int bank_yoff; | ~~~~~~~~~~~~~~ 165 | | 166 | CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167 | void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 168 | }; | ~~ 169 | | 170 | struct BramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 171 | { | ~ 172 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 173 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 174 | | 175 | int bank_num; | ~~~~~~~~~~~~~ 176 | int bank_off; | ~~~~~~~~~~~~~ 177 | | 178 | BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 179 | void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 180 | }; | ~~ 181 | | 182 | static void update_crc16(uint16_t &crc, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 | { | ~ 184 | // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 | for (int i = 7; i >= 0; i--) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 186 | uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187 | crc = (crc << 1) ^ xor_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | } | ~ 189 | } | ~ 190 | | 191 | static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 192 | { | ~ 193 | int byte = ifs.get(); | ~~~~~~~~~~~~~~~~~~~~~ 194 | | 195 | if (byte < 0) | ~~~~~~~~~~~~~ 196 | error("Unexpected end of file.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 197 | | 198 | file_offset++; | ~~~~~~~~~~~~~~ 199 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 200 | | 201 | return byte; | ~~~~~~~~~~~~ 202 | } | ~ 203 | | 204 | static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 205 | { | ~ 206 | ofs << byte; | ~~~~~~~~~~~~ 207 | file_offset++; | ~~~~~~~~~~~~~~ 208 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 209 | } | ~ 210 | | 211 | void FpgaConfig::read_bits(std::istream &ifs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 212 | { | ~ 213 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 214 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 215 | | 216 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | info("Parsing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 218 | | 219 | // skip initial comments until preamble is found | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 220 | | 221 | uint32_t preamble = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 222 | | 223 | while (1) | ~~~~~~~~~ 224 | { | ~ 225 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 226 | preamble = (preamble << 8) | byte; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 227 | if (preamble == 0xffffffff) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 | error("No preamble found in bitstream.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 | if (preamble == 0x7EAA997E) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230 | info("Found preamble at offset %d.\n", file_offset-4); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 | break; | ~~~~~~ 232 | } | ~ 233 | initblop.push_back(byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 234 | } | ~ 235 | | 236 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 237 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 238 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 239 | | 240 | // main parser loop | ~~~~~~~~~~~~~~~~~~~ 241 | | 242 | int current_bank = 0; | ~~~~~~~~~~~~~~~~~~~~~ 243 | int current_width = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 244 | int current_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 245 | int current_offset = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 246 | bool wakeup = false; | ~~~~~~~~~~~~~~~~~~~~ 247 | | 248 | this->cram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 249 | this->cram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 250 | | 251 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 252 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 253 | | 254 | while (!wakeup) | ~~~~~~~~~~~~~~~ 255 | { | ~ 256 | // one command byte. the lower 4 bits of the command byte specify | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | // the length of the command payload. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | | 259 | uint8_t command = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 | uint32_t payload = 0; | ~~~~~~~~~~~~~~~~~~~~~ 261 | | 262 | for (int i = 0; i < (command & 0x0f); i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 263 | payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 264 | | 265 | debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 266 | command, 2*(command & 0x0f), payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 267 | | 268 | uint16_t end_token; | ~~~~~~~~~~~~~~~~~~~ 269 | | 270 | switch (command & 0xf0) | ~~~~~~~~~~~~~~~~~~~~~~~ 271 | { | ~ 272 | case 0x00: | ~~~~~~~~~~ 273 | switch (payload) | ~~~~~~~~~~~~~~~~ 274 | { | ~ 275 | case 0x01: | ~~~~~~~~~~ 276 | info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 277 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 278 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 279 | | 280 | this->cram_width = std::max(this->cram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281 | this->cram_height = std::max(this->cram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 282 | | 283 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 284 | this->cram[current_bank].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 285 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 286 | this->cram[current_bank][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 287 | | 288 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 290 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 291 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 293 | this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 294 | } | ~ 295 | } | ~ 296 | | 297 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 299 | if (end_token) | ~~~~~~~~~~~~~~ 300 | error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 301 | break; | ~~~~~~ 302 | | 303 | case 0x03: | ~~~~~~~~~~ 304 | info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 305 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 306 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 307 | | 308 | this->bram_width = std::max(this->bram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 309 | this->bram_height = std::max(this->bram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 310 | | 311 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 312 | this->bram[current_bank].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 313 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 314 | this->bram[current_bank][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 315 | | 316 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 317 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 318 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 319 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 320 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 321 | this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 322 | } | ~ 323 | } | ~ 324 | | 325 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 326 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 327 | if (end_token) | ~~~~~~~~~~~~~~ 328 | error("Expected 0x0000 after BRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329 | break; | ~~~~~~ 330 | | 331 | case 0x05: | ~~~~~~~~~~ 332 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 333 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 334 | break; | ~~~~~~ 335 | | 336 | case 0x06: | ~~~~~~~~~~ 337 | info("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~ 338 | wakeup = true; | ~~~~~~~~~~~~~~ 339 | break; | ~~~~~~ 340 | | 341 | default: | ~~~~~~~~ 342 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 343 | } | ~ 344 | break; | ~~~~~~ 345 | | 346 | case 0x10: | ~~~~~~~~~~ 347 | current_bank = payload; | ~~~~~~~~~~~~~~~~~~~~~~~ 348 | debug("Set bank to %d.\n", current_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 | break; | ~~~~~~ 350 | | 351 | case 0x20: | ~~~~~~~~~~ 352 | if (crc_value != 0) | ~~~~~~~~~~~~~~~~~~~ 353 | error("CRC Check FAILED.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 354 | info("CRC Check OK.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~ 355 | break; | ~~~~~~ 356 | | 357 | case 0x50: | ~~~~~~~~~~ 358 | if (payload == 0) | ~~~~~~~~~~~~~~~~~ 359 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 360 | else if (payload == 1) | ~~~~~~~~~~~~~~~~~~~~~~ 361 | this->freqrange = "medium"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 362 | else if (payload == 2) | ~~~~~~~~~~~~~~~~~~~~~~ 363 | this->freqrange = "high"; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 364 | else | ~~~~ 365 | error("Unknown freqrange payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 366 | info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 367 | break; | ~~~~~~ 368 | | 369 | case 0x60: | ~~~~~~~~~~ 370 | current_width = payload + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 | debug("Setting bank width to %d.\n", current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 372 | break; | ~~~~~~ 373 | | 374 | case 0x70: | ~~~~~~~~~~ 375 | current_height = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 376 | debug("Setting bank height to %d.\n", current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 377 | break; | ~~~~~~ 378 | | 379 | case 0x80: | ~~~~~~~~~~ 380 | current_offset = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 381 | debug("Setting bank offset to %d.\n", current_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 382 | break; | ~~~~~~ 383 | | 384 | case 0x90: | ~~~~~~~~~~ 385 | switch(payload) | ~~~~~~~~~~~~~~~ 386 | { | ~ 387 | case 0: | ~~~~~~~ 388 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 389 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 390 | break; | ~~~~~~ 391 | case 1: | ~~~~~~~ 392 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 394 | break; | ~~~~~~ 395 | case 32: | ~~~~~~~~ 396 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 397 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 398 | break; | ~~~~~~ 399 | case 33: | ~~~~~~~~ 400 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 401 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 402 | break; | ~~~~~~ 403 | default: | ~~~~~~~~ 404 | error("Unknown warmboot/nosleep payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 405 | } | ~ 406 | info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 407 | break; | ~~~~~~ 408 | | 409 | default: | ~~~~~~~~ 410 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 411 | } | ~ 412 | } | ~ 413 | | 414 | if (this->cram_width == 182 && this->cram_height == 80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 415 | this->device = "384"; | ~~~~~~~~~~~~~~~~~~~~~ 416 | else if (this->cram_width == 332 && this->cram_height == 144) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 417 | this->device = "1k"; | ~~~~~~~~~~~~~~~~~~~~ 418 | else if (this->cram_width == 872 && this->cram_height == 272) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 419 | this->device = "8k"; | ~~~~~~~~~~~~~~~~~~~~ 420 | else if (this->cram_width == 692 && this->cram_height == 336) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 421 | this->device = "5k"; | ~~~~~~~~~~~~~~~~~~~~ 422 | else if (this->cram_width == 692 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 423 | this->device = "u4k"; | ~~~~~~~~~~~~~~~~~~~~~ 424 | else if (this->cram_width == 656 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 425 | this->device = "lm4k"; | ~~~~~~~~~~~~~~~~~~~~~~ 426 | else | ~~~~ 427 | error("Failed to detect chip type.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 | | 429 | info("Chip type is '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 430 | } | ~ 431 | | 432 | void FpgaConfig::write_bits(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 433 | { | ~ 434 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 435 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 436 | | 437 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 438 | info("Writing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 439 | | 440 | for (auto byte : this->initblop) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 | ofs << byte; | ~~~~~~~~~~~~ 442 | | 443 | debug("Writing preamble.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 444 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 445 | write_byte(ofs, crc_value, file_offset, 0xAA); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 446 | write_byte(ofs, crc_value, file_offset, 0x99); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 447 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 448 | | 449 | debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 450 | write_byte(ofs, crc_value, file_offset, 0x51); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 451 | if (this->freqrange == "low") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 452 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 453 | else if (this->freqrange == "medium") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 454 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 455 | else if (this->freqrange == "high") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 | write_byte(ofs, crc_value, file_offset, 0x02); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 457 | else | ~~~~ 458 | error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 459 | | 460 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 461 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 462 | write_byte(ofs, crc_value, file_offset, 0x05); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 463 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 464 | | 465 | { | ~ 466 | uint8_t nosleep_flag; | ~~~~~~~~~~~~~~~~~~~~~ 467 | debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 468 | write_byte(ofs, crc_value, file_offset, 0x92); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 469 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 470 | | 471 | if (this->nosleep == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 | nosleep_flag = 0; | ~~~~~~~~~~~~~~~~~ 473 | else if (this->nosleep == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 474 | nosleep_flag = 1; | ~~~~~~~~~~~~~~~~~ 475 | else | ~~~~ 476 | error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 477 | | 478 | if (this->warmboot == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 479 | write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 480 | else if (this->warmboot == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 481 | write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 482 | else | ~~~~ 483 | error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 484 | } | ~ 485 | | 486 | debug("CRAM: Setting bank width to %d.\n", this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 487 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 488 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 489 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 490 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 491 | debug("CRAM: Setting bank height to %d.\n", this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 492 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 493 | write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 494 | write_byte(ofs, crc_value, file_offset, this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 495 | } | ~ 496 | | 497 | debug("CRAM: Setting bank offset to 0.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 498 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 500 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 501 | | 502 | for (int cram_bank = 0; cram_bank < 4; cram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 503 | { | ~ 504 | vector cram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 505 | int height = this->cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 506 | if(this->device == "5k" && ((cram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 507 | height = height / 2 + 8; | ~~~~~~~~~~~~~~~~~~~~~~~~ 508 | for (int cram_y = 0; cram_y < height; cram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 509 | for (int cram_x = 0; cram_x < this->cram_width; cram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 510 | cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 511 | | 512 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 513 | debug("CRAM: Setting bank height to %d.\n", height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 514 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 515 | write_byte(ofs, crc_value, file_offset, height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 516 | write_byte(ofs, crc_value, file_offset, height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 517 | } | ~ 518 | | 519 | debug("CRAM: Setting bank %d.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 520 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 521 | write_byte(ofs, crc_value, file_offset, cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 522 | | 523 | debug("CRAM: Writing bank %d data.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 524 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 525 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 526 | for (int i = 0; i < int(cram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 527 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 528 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 529 | byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 530 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 531 | } | ~ 532 | | 533 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 534 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 535 | } | ~ 536 | | 537 | int bram_chunk_size = 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 538 | | 539 | if (this->bram_width && this->bram_height) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 540 | { | ~ 541 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 542 | debug("BRAM: Setting bank width to %d.\n", this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 543 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 544 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 545 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 546 | } | ~ 547 | | 548 | | 549 | debug("BRAM: Setting bank height to %d.\n", this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 550 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 551 | write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 552 | write_byte(ofs, crc_value, file_offset, bram_chunk_size); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 553 | | 554 | for (int bram_bank = 0; bram_bank < 4; bram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 555 | { | ~ 556 | debug("BRAM: Setting bank %d.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 557 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558 | write_byte(ofs, crc_value, file_offset, bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 559 | | 560 | for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 561 | { | ~ 562 | vector bram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 563 | int width = this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 564 | if(this->device == "5k" && ((bram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 565 | width = width / 2; | ~~~~~~~~~~~~~~~~~~ 566 | for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 567 | for (int bram_x = 0; bram_x < width; bram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 | bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 569 | | 570 | debug("BRAM: Setting bank offset to %d.\n", offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 571 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 572 | write_byte(ofs, crc_value, file_offset, offset >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 573 | write_byte(ofs, crc_value, file_offset, offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 574 | | 575 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 576 | debug("BRAM: Setting bank width to %d.\n", width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 577 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 578 | write_byte(ofs, crc_value, file_offset, (width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 579 | write_byte(ofs, crc_value, file_offset, (width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 580 | } | ~ 581 | | 582 | | 583 | if (!this->skip_bram_initialization) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 584 | debug("BRAM: Writing bank %d data.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 585 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 586 | write_byte(ofs, crc_value, file_offset, 0x03); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 587 | for (int i = 0; i < int(bram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 588 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 589 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 590 | byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 591 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 592 | } | ~ 593 | | 594 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 595 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 596 | } | ~ 597 | } | ~ 598 | } | ~ 599 | } | ~ 600 | | 601 | debug("Writing CRC value.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 602 | write_byte(ofs, crc_value, file_offset, 0x22); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 603 | uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 604 | write_byte(ofs, crc_value, file_offset, crc_hi); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 605 | write_byte(ofs, crc_value, file_offset, crc_lo); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 606 | | 607 | debug("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~~ 608 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 609 | write_byte(ofs, crc_value, file_offset, 0x06); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 610 | | 611 | debug("Padding byte.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 612 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 613 | } | ~ 614 | | 615 | void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 616 | { | ~ 617 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 618 | info("Parsing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 619 | | 620 | bool got_device = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 621 | this->cram.clear(); | ~~~~~~~~~~~~~~~~~~~ 622 | this->bram.clear(); | ~~~~~~~~~~~~~~~~~~~ 623 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 624 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 625 | | 626 | bool reuse_line = true; | ~~~~~~~~~~~~~~~~~~~~~~~ 627 | string line, command; | ~~~~~~~~~~~~~~~~~~~~~ 628 | | 629 | while (reuse_line || getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 630 | { | ~ 631 | reuse_line = false; | ~~~~~~~~~~~~~~~~~~~ 632 | | 633 | std::istringstream is(line); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 634 | is >> command; | ~~~~~~~~~~~~~~ 635 | | 636 | if (command.empty()) | ~~~~~~~~~~~~~~~~~~~~ 637 | continue; | ~~~~~~~~~ 638 | | 639 | debug("Next command: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 640 | | 641 | if (command == ".comment") | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 642 | { | ~ 643 | this->initblop.clear(); | ~~~~~~~~~~~~~~~~~~~~~~~ 644 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 645 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 646 | | 647 | while (getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 648 | { | ~ 649 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 650 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 651 | break; | ~~~~~~ 652 | } | ~ 653 | | 654 | for (auto ch : line) | ~~~~~~~~~~~~~~~~~~~~ 655 | this->initblop.push_back(ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 656 | this->initblop.push_back(0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 657 | } | ~ 658 | | 659 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 660 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 661 | continue; | ~~~~~~~~~ 662 | } | ~ 663 | | 664 | if (command == ".device") | ~~~~~~~~~~~~~~~~~~~~~~~~~ 665 | { | ~ 666 | if (got_device) | ~~~~~~~~~~~~~~~ 667 | error("More than one .device statement.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 668 | | 669 | is >> this->device; | ~~~~~~~~~~~~~~~~~~~ 670 | | 671 | if (this->device == "384") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 672 | this->cram_width = 182; | ~~~~~~~~~~~~~~~~~~~~~~~ 673 | this->cram_height = 80; | ~~~~~~~~~~~~~~~~~~~~~~~ 674 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 675 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 676 | } else | ~~~~~~ 677 | if (this->device == "1k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | this->cram_width = 332; | ~~~~~~~~~~~~~~~~~~~~~~~ 679 | this->cram_height = 144; | ~~~~~~~~~~~~~~~~~~~~~~~~ 680 | this->bram_width = 64; | ~~~~~~~~~~~~~~~~~~~~~~ 681 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 682 | } else | ~~~~~~ 683 | if (this->device == "8k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 684 | this->cram_width = 872; | ~~~~~~~~~~~~~~~~~~~~~~~ 685 | this->cram_height = 272; | ~~~~~~~~~~~~~~~~~~~~~~~~ 686 | this->bram_width = 128; | ~~~~~~~~~~~~~~~~~~~~~~~ 687 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 688 | } else | ~~~~~~ 689 | if (this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 690 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 691 | this->cram_height = 336; | ~~~~~~~~~~~~~~~~~~~~~~~~ 692 | this->bram_width = 160; | ~~~~~~~~~~~~~~~~~~~~~~~ 693 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 694 | } else | ~~~~~~ 695 | if (this->device == "u4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 696 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 697 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 698 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 699 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 700 | } else | ~~~~~~ 701 | if (this->device == "lm4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 702 | this->cram_width = 656; | ~~~~~~~~~~~~~~~~~~~~~~~ 703 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 704 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 705 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 706 | } else | ~~~~~~ 707 | error("Unsupported chip type '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 708 | | 709 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 710 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 712 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 713 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 714 | this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 715 | } | ~ 716 | | 717 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 718 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 719 | int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 720 | this->bram[i].resize(width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 721 | for (int x = 0; x < width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 722 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 723 | } | ~ 724 | } else { | ~~~~~~~~ 725 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 726 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 727 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 728 | this->cram[i][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 729 | } | ~ 730 | | 731 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 732 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 733 | this->bram[i].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 734 | for (int x = 0; x < this->bram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 735 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 736 | } | ~ 737 | } | ~ 738 | | 739 | | 740 | got_device = true; | ~~~~~~~~~~~~~~~~~~ 741 | continue; | ~~~~~~~~~ 742 | } | ~ 743 | | 744 | if (command == ".warmboot") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 745 | { | ~ 746 | is >> this->warmboot; | ~~~~~~~~~~~~~~~~~~~~~ 747 | | 748 | if (this->warmboot != "disabled" && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 749 | this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 750 | error("Unknown warmboot setting '%s'.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 751 | this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~ 752 | | 753 | continue; | ~~~~~~~~~ 754 | } | ~ 755 | | 756 | // No ".nosleep" section despite sharing the same byte as .warmboot. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 757 | // ".nosleep" is specified when icepack is invoked, which is too late. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 758 | // So we inject the section based on command line argument. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 759 | if (nosleep) | ~~~~~~~~~~~~ 760 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 761 | else | ~~~~ 762 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 763 | | 764 | if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 765 | { | ~ 766 | if (!got_device) | ~~~~~~~~~~~~~~~~ 767 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 768 | | 769 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 770 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 771 | | 772 | CramIndexConverter cic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 773 | | 774 | if (("." + cic.tile_type + "_tile") != command) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 775 | error("Got %s statement for %s tile %d %d.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 776 | command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 777 | | 778 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 779 | { | ~ 780 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 781 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 782 | break; | ~~~~~~ 783 | } | ~ 784 | | 785 | for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 786 | if (line[bit_x] == '1') { | ~~~~~~~~~~~~~~~~~~~~~~~~~ 787 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 788 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 789 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 790 | } | ~ 791 | } | ~ 792 | | 793 | continue; | ~~~~~~~~~ 794 | } | ~ 795 | | 796 | if (command == ".ram_data") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 797 | { | ~ 798 | if (!got_device) | ~~~~~~~~~~~~~~~~ 799 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 800 | | 801 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 802 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 803 | | 804 | BramIndexConverter bic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 805 | | 806 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 807 | { | ~ 808 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 809 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 810 | break; | ~~~~~~ 811 | } | ~ 812 | | 813 | for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 814 | { | ~ 815 | int value = -1; | ~~~~~~~~~~~~~~~ 816 | if ('0' <= line[ch_idx] && line[ch_idx] <= '9') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 817 | value = line[ch_idx] - '0'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 818 | if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 819 | value = line[ch_idx] - 'a' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 820 | if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 821 | value = line[ch_idx] - 'A' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | if (value < 0) | ~~~~~~~~~~~~~~ 823 | error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 824 | | 825 | for (int i = 0; i < 4; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 826 | if ((value & (1 << i)) != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 827 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 828 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 829 | this->bram[bram_bank][bram_x][bram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 830 | } | ~ 831 | } | ~ 832 | } | ~ 833 | | 834 | continue; | ~~~~~~~~~ 835 | } | ~ 836 | | 837 | if (command == ".extra_bit") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 838 | { | ~ 839 | if (!got_device) | ~~~~~~~~~~~~~~~~ 840 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 841 | | 842 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 843 | is >> cram_bank >> cram_x >> cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 844 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 845 | | 846 | continue; | ~~~~~~~~~ 847 | } | ~ 848 | | 849 | if (command == ".sym") | ~~~~~~~~~~~~~~~~~~~~~~ 850 | continue; | ~~~~~~~~~ 851 | | 852 | if (command.substr(0, 1) == ".") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 853 | error("Unknown statement: %s\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 854 | error("Unexpected data line: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 855 | } | ~ 856 | } | ~ 857 | | 858 | void FpgaConfig::write_ascii(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | { | ~ 860 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 861 | info("Writing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 862 | | 863 | ofs << ".comment"; | ~~~~~~~~~~~~~~~~~~ 864 | bool insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 865 | for (auto ch : this->initblop) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 866 | if (ch == 0) { | ~~~~~~~~~~~~~~ 867 | insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~ 868 | } else if (ch == 0xff) { | ~~~~~~~~~~~~~~~~~~~~~~~~ 869 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 870 | } else { | ~~~~~~~~ 871 | if (insert_newline) | ~~~~~~~~~~~~~~~~~~~ 872 | ofs << '\n'; | ~~~~~~~~~~~~ 873 | ofs << ch; | ~~~~~~~~~~ 874 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 875 | } | ~ 876 | } | ~ 877 | | 878 | ofs << stringf("\n.device %s\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 879 | if (this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 880 | ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 881 | | 882 | // As "nosleep" is an icepack command, we do not write out a ".nosleep" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 883 | // section. However, we parse it in read_bits() and notify the user in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 884 | // info. | ~~~~~~~~ 885 | | 886 | typedef std::tuple tile_bit_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 887 | std::set tile_bits; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 888 | | 889 | for (int y = 0; y <= this->chip_height()+1; y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 890 | for (int x = 0; x <= this->chip_width()+1; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 891 | { | ~ 892 | CramIndexConverter cic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 893 | | 894 | if (cic.tile_type == "corner" || cic.tile_type == "unsupported") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 895 | continue; | ~~~~~~~~~ 896 | | 897 | ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 898 | | 899 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 900 | for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 901 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 902 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 903 | tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 904 | if (cram_x > int(this->cram[cram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 906 | } | ~ 907 | if (cram_y > int(this->cram[cram_bank][cram_x].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 908 | error("cram_y %d (bit %d, %d) larger than bank %d size %lu\n", cram_y, bit_x, bit_y, cram_bank, this->cram[cram_bank][cram_x].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | std::vector::size_type {aka unsigned int} icepack.cc:908:6: note: in expansion of macro 'error' 908 | error("cram_y %d (bit %d, %d) larger than bank %d size %lu\n", cram_y, bit_x, bit_y, cram_bank, this->cram[cram_bank][cram_x].size()); | ^~~~~ icepack.cc:908:63: note: format string is defined here 908 | error("cram_y %d (bit %d, %d) larger than bank %d size %lu\n", cram_y, bit_x, bit_y, cram_bank, this->cram[cram_bank][cram_x].size()); | ~~^ | | | long unsigned int | %u icepack.cc:53:41: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'std::vector >::size_type' {aka 'unsigned int'} [-Wformat=] 53 | #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | | 56 | string vstringf(const char *fmt, va_list ap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | { | ~ 58 | string string; | ~~~~~~~~~~~~~~ 59 | char *str = NULL; | ~~~~~~~~~~~~~~~~~ 60 | | 61 | #ifdef _WIN32 | ~~~~~~~~~~~~~ 62 | int sz = 64, rc; | ~~~~~~~~~~~~~~~~ 63 | while (1) { | ~~~~~~~~~~~ 64 | va_list apc; | ~~~~~~~~~~~~ 65 | va_copy(apc, ap); | ~~~~~~~~~~~~~~~~~ 66 | str = (char*)realloc(str, sz); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 67 | rc = vsnprintf(str, sz, fmt, apc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | va_end(apc); | ~~~~~~~~~~~~ 69 | if (rc >= 0 && rc < sz) | ~~~~~~~~~~~~~~~~~~~~~~~ 70 | break; | ~~~~~~ 71 | sz *= 2; | ~~~~~~~~ 72 | } | ~ 73 | #else | ~~~~~ 74 | if (vasprintf(&str, fmt, ap) < 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | str = NULL; | ~~~~~~~~~~~ 76 | #endif | ~~~~~~ 77 | | 78 | if (str != NULL) { | ~~~~~~~~~~~~~~~~~~ 79 | string = str; | ~~~~~~~~~~~~~ 80 | free(str); | ~~~~~~~~~~ 81 | } | ~ 82 | | 83 | return string; | ~~~~~~~~~~~~~~ 84 | } | ~ 85 | | 86 | string stringf(const char *fmt, ...) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | { | ~ 88 | string string; | ~~~~~~~~~~~~~~ 89 | va_list ap; | ~~~~~~~~~~~ 90 | | 91 | va_start(ap, fmt); | ~~~~~~~~~~~~~~~~~~ 92 | string = vstringf(fmt, ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | va_end(ap); | ~~~~~~~~~~~ 94 | | 95 | return string; | ~~~~~~~~~~~~~~ 96 | } | ~ 97 | | 98 | // ================================================================== | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 | // FpgaConfig stuff | ~~~~~~~~~~~~~~~~~~~ 100 | | 101 | struct FpgaConfig | ~~~~~~~~~~~~~~~~~ 102 | { | ~ 103 | string device; | ~~~~~~~~~~~~~~ 104 | string freqrange; | ~~~~~~~~~~~~~~~~~ 105 | string nosleep; | ~~~~~~~~~~~~~~~ 106 | string warmboot; | ~~~~~~~~~~~~~~~~ 107 | | 108 | // cram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 109 | int cram_width, cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | vector>> cram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | | 112 | // bram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 113 | int bram_width, bram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | vector>> bram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | bool skip_bram_initialization; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | | 117 | // data before preamble | ~~~~~~~~~~~~~~~~~~~~~~~ 118 | vector initblop; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 119 | | 120 | // bitstream i/o | ~~~~~~~~~~~~~~~~ 121 | void read_bits(std::istream &ifs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | void write_bits(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 123 | | 124 | // icebox i/o | ~~~~~~~~~~~~~ 125 | void read_ascii(std::istream &ifs, bool nosleep); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 | void write_ascii(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 | | 128 | // netpbm i/o | ~~~~~~~~~~~~~ 129 | void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 130 | void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | | 132 | // query chip type metadata | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 133 | int chip_width() const; | ~~~~~~~~~~~~~~~~~~~~~~~ 134 | int chip_height() const; | ~~~~~~~~~~~~~~~~~~~~~~~~ 135 | vector chip_cols() const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136 | | 137 | // query tile metadata | ~~~~~~~~~~~~~~~~~~~~~~ 138 | string tile_type(int x, int y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | int tile_width(const string &type) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | | 141 | // cram bit manipulation | ~~~~~~~~~~~~~~~~~~~~~~~~ 142 | void cram_clear(); | ~~~~~~~~~~~~~~~~~~ 143 | void cram_fill_tiles(); | ~~~~~~~~~~~~~~~~~~~~~~~ 144 | void cram_checkerboard(int m = 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 145 | }; | ~~ 146 | | 147 | struct CramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 148 | { | ~ 149 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 150 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 151 | | 152 | string tile_type; | ~~~~~~~~~~~~~~~~~ 153 | int tile_width; | ~~~~~~~~~~~~~~~ 154 | int column_width; | ~~~~~~~~~~~~~~~~~ 155 | | 156 | bool left_right_io; | ~~~~~~~~~~~~~~~~~~~ 157 | bool right_half; | ~~~~~~~~~~~~~~~~ 158 | bool top_half; | ~~~~~~~~~~~~~~ 159 | | 160 | int bank_num; | ~~~~~~~~~~~~~ 161 | int bank_tx; | ~~~~~~~~~~~~ 162 | int bank_ty; | ~~~~~~~~~~~~ 163 | int bank_xoff; | ~~~~~~~~~~~~~~ 164 | int bank_yoff; | ~~~~~~~~~~~~~~ 165 | | 166 | CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167 | void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 168 | }; | ~~ 169 | | 170 | struct BramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 171 | { | ~ 172 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 173 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 174 | | 175 | int bank_num; | ~~~~~~~~~~~~~ 176 | int bank_off; | ~~~~~~~~~~~~~ 177 | | 178 | BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 179 | void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 180 | }; | ~~ 181 | | 182 | static void update_crc16(uint16_t &crc, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 | { | ~ 184 | // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 | for (int i = 7; i >= 0; i--) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 186 | uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187 | crc = (crc << 1) ^ xor_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | } | ~ 189 | } | ~ 190 | | 191 | static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 192 | { | ~ 193 | int byte = ifs.get(); | ~~~~~~~~~~~~~~~~~~~~~ 194 | | 195 | if (byte < 0) | ~~~~~~~~~~~~~ 196 | error("Unexpected end of file.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 197 | | 198 | file_offset++; | ~~~~~~~~~~~~~~ 199 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 200 | | 201 | return byte; | ~~~~~~~~~~~~ 202 | } | ~ 203 | | 204 | static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 205 | { | ~ 206 | ofs << byte; | ~~~~~~~~~~~~ 207 | file_offset++; | ~~~~~~~~~~~~~~ 208 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 209 | } | ~ 210 | | 211 | void FpgaConfig::read_bits(std::istream &ifs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 212 | { | ~ 213 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 214 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 215 | | 216 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | info("Parsing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 218 | | 219 | // skip initial comments until preamble is found | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 220 | | 221 | uint32_t preamble = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 222 | | 223 | while (1) | ~~~~~~~~~ 224 | { | ~ 225 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 226 | preamble = (preamble << 8) | byte; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 227 | if (preamble == 0xffffffff) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 | error("No preamble found in bitstream.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 | if (preamble == 0x7EAA997E) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230 | info("Found preamble at offset %d.\n", file_offset-4); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 | break; | ~~~~~~ 232 | } | ~ 233 | initblop.push_back(byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 234 | } | ~ 235 | | 236 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 237 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 238 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 239 | | 240 | // main parser loop | ~~~~~~~~~~~~~~~~~~~ 241 | | 242 | int current_bank = 0; | ~~~~~~~~~~~~~~~~~~~~~ 243 | int current_width = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 244 | int current_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 245 | int current_offset = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 246 | bool wakeup = false; | ~~~~~~~~~~~~~~~~~~~~ 247 | | 248 | this->cram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 249 | this->cram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 250 | | 251 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 252 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 253 | | 254 | while (!wakeup) | ~~~~~~~~~~~~~~~ 255 | { | ~ 256 | // one command byte. the lower 4 bits of the command byte specify | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | // the length of the command payload. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | | 259 | uint8_t command = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 | uint32_t payload = 0; | ~~~~~~~~~~~~~~~~~~~~~ 261 | | 262 | for (int i = 0; i < (command & 0x0f); i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 263 | payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 264 | | 265 | debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 266 | command, 2*(command & 0x0f), payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 267 | | 268 | uint16_t end_token; | ~~~~~~~~~~~~~~~~~~~ 269 | | 270 | switch (command & 0xf0) | ~~~~~~~~~~~~~~~~~~~~~~~ 271 | { | ~ 272 | case 0x00: | ~~~~~~~~~~ 273 | switch (payload) | ~~~~~~~~~~~~~~~~ 274 | { | ~ 275 | case 0x01: | ~~~~~~~~~~ 276 | info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 277 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 278 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 279 | | 280 | this->cram_width = std::max(this->cram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281 | this->cram_height = std::max(this->cram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 282 | | 283 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 284 | this->cram[current_bank].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 285 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 286 | this->cram[current_bank][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 287 | | 288 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 290 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 291 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 293 | this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 294 | } | ~ 295 | } | ~ 296 | | 297 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 299 | if (end_token) | ~~~~~~~~~~~~~~ 300 | error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 301 | break; | ~~~~~~ 302 | | 303 | case 0x03: | ~~~~~~~~~~ 304 | info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 305 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 306 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 307 | | 308 | this->bram_width = std::max(this->bram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 309 | this->bram_height = std::max(this->bram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 310 | | 311 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 312 | this->bram[current_bank].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 313 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 314 | this->bram[current_bank][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 315 | | 316 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 317 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 318 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 319 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 320 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 321 | this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 322 | } | ~ 323 | } | ~ 324 | | 325 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 326 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 327 | if (end_token) | ~~~~~~~~~~~~~~ 328 | error("Expected 0x0000 after BRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329 | break; | ~~~~~~ 330 | | 331 | case 0x05: | ~~~~~~~~~~ 332 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 333 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 334 | break; | ~~~~~~ 335 | | 336 | case 0x06: | ~~~~~~~~~~ 337 | info("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~ 338 | wakeup = true; | ~~~~~~~~~~~~~~ 339 | break; | ~~~~~~ 340 | | 341 | default: | ~~~~~~~~ 342 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 343 | } | ~ 344 | break; | ~~~~~~ 345 | | 346 | case 0x10: | ~~~~~~~~~~ 347 | current_bank = payload; | ~~~~~~~~~~~~~~~~~~~~~~~ 348 | debug("Set bank to %d.\n", current_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 | break; | ~~~~~~ 350 | | 351 | case 0x20: | ~~~~~~~~~~ 352 | if (crc_value != 0) | ~~~~~~~~~~~~~~~~~~~ 353 | error("CRC Check FAILED.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 354 | info("CRC Check OK.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~ 355 | break; | ~~~~~~ 356 | | 357 | case 0x50: | ~~~~~~~~~~ 358 | if (payload == 0) | ~~~~~~~~~~~~~~~~~ 359 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 360 | else if (payload == 1) | ~~~~~~~~~~~~~~~~~~~~~~ 361 | this->freqrange = "medium"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 362 | else if (payload == 2) | ~~~~~~~~~~~~~~~~~~~~~~ 363 | this->freqrange = "high"; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 364 | else | ~~~~ 365 | error("Unknown freqrange payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 366 | info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 367 | break; | ~~~~~~ 368 | | 369 | case 0x60: | ~~~~~~~~~~ 370 | current_width = payload + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 | debug("Setting bank width to %d.\n", current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 372 | break; | ~~~~~~ 373 | | 374 | case 0x70: | ~~~~~~~~~~ 375 | current_height = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 376 | debug("Setting bank height to %d.\n", current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 377 | break; | ~~~~~~ 378 | | 379 | case 0x80: | ~~~~~~~~~~ 380 | current_offset = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 381 | debug("Setting bank offset to %d.\n", current_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 382 | break; | ~~~~~~ 383 | | 384 | case 0x90: | ~~~~~~~~~~ 385 | switch(payload) | ~~~~~~~~~~~~~~~ 386 | { | ~ 387 | case 0: | ~~~~~~~ 388 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 389 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 390 | break; | ~~~~~~ 391 | case 1: | ~~~~~~~ 392 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 394 | break; | ~~~~~~ 395 | case 32: | ~~~~~~~~ 396 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 397 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 398 | break; | ~~~~~~ 399 | case 33: | ~~~~~~~~ 400 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 401 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 402 | break; | ~~~~~~ 403 | default: | ~~~~~~~~ 404 | error("Unknown warmboot/nosleep payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 405 | } | ~ 406 | info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 407 | break; | ~~~~~~ 408 | | 409 | default: | ~~~~~~~~ 410 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 411 | } | ~ 412 | } | ~ 413 | | 414 | if (this->cram_width == 182 && this->cram_height == 80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 415 | this->device = "384"; | ~~~~~~~~~~~~~~~~~~~~~ 416 | else if (this->cram_width == 332 && this->cram_height == 144) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 417 | this->device = "1k"; | ~~~~~~~~~~~~~~~~~~~~ 418 | else if (this->cram_width == 872 && this->cram_height == 272) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 419 | this->device = "8k"; | ~~~~~~~~~~~~~~~~~~~~ 420 | else if (this->cram_width == 692 && this->cram_height == 336) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 421 | this->device = "5k"; | ~~~~~~~~~~~~~~~~~~~~ 422 | else if (this->cram_width == 692 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 423 | this->device = "u4k"; | ~~~~~~~~~~~~~~~~~~~~~ 424 | else if (this->cram_width == 656 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 425 | this->device = "lm4k"; | ~~~~~~~~~~~~~~~~~~~~~~ 426 | else | ~~~~ 427 | error("Failed to detect chip type.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 | | 429 | info("Chip type is '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 430 | } | ~ 431 | | 432 | void FpgaConfig::write_bits(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 433 | { | ~ 434 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 435 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 436 | | 437 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 438 | info("Writing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 439 | | 440 | for (auto byte : this->initblop) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 | ofs << byte; | ~~~~~~~~~~~~ 442 | | 443 | debug("Writing preamble.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 444 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 445 | write_byte(ofs, crc_value, file_offset, 0xAA); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 446 | write_byte(ofs, crc_value, file_offset, 0x99); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 447 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 448 | | 449 | debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 450 | write_byte(ofs, crc_value, file_offset, 0x51); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 451 | if (this->freqrange == "low") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 452 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 453 | else if (this->freqrange == "medium") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 454 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 455 | else if (this->freqrange == "high") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 | write_byte(ofs, crc_value, file_offset, 0x02); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 457 | else | ~~~~ 458 | error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 459 | | 460 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 461 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 462 | write_byte(ofs, crc_value, file_offset, 0x05); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 463 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 464 | | 465 | { | ~ 466 | uint8_t nosleep_flag; | ~~~~~~~~~~~~~~~~~~~~~ 467 | debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 468 | write_byte(ofs, crc_value, file_offset, 0x92); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 469 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 470 | | 471 | if (this->nosleep == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 | nosleep_flag = 0; | ~~~~~~~~~~~~~~~~~ 473 | else if (this->nosleep == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 474 | nosleep_flag = 1; | ~~~~~~~~~~~~~~~~~ 475 | else | ~~~~ 476 | error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 477 | | 478 | if (this->warmboot == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 479 | write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 480 | else if (this->warmboot == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 481 | write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 482 | else | ~~~~ 483 | error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 484 | } | ~ 485 | | 486 | debug("CRAM: Setting bank width to %d.\n", this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 487 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 488 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 489 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 490 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 491 | debug("CRAM: Setting bank height to %d.\n", this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 492 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 493 | write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 494 | write_byte(ofs, crc_value, file_offset, this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 495 | } | ~ 496 | | 497 | debug("CRAM: Setting bank offset to 0.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 498 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 500 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 501 | | 502 | for (int cram_bank = 0; cram_bank < 4; cram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 503 | { | ~ 504 | vector cram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 505 | int height = this->cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 506 | if(this->device == "5k" && ((cram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 507 | height = height / 2 + 8; | ~~~~~~~~~~~~~~~~~~~~~~~~ 508 | for (int cram_y = 0; cram_y < height; cram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 509 | for (int cram_x = 0; cram_x < this->cram_width; cram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 510 | cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 511 | | 512 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 513 | debug("CRAM: Setting bank height to %d.\n", height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 514 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 515 | write_byte(ofs, crc_value, file_offset, height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 516 | write_byte(ofs, crc_value, file_offset, height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 517 | } | ~ 518 | | 519 | debug("CRAM: Setting bank %d.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 520 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 521 | write_byte(ofs, crc_value, file_offset, cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 522 | | 523 | debug("CRAM: Writing bank %d data.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 524 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 525 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 526 | for (int i = 0; i < int(cram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 527 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 528 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 529 | byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 530 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 531 | } | ~ 532 | | 533 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 534 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 535 | } | ~ 536 | | 537 | int bram_chunk_size = 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 538 | | 539 | if (this->bram_width && this->bram_height) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 540 | { | ~ 541 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 542 | debug("BRAM: Setting bank width to %d.\n", this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 543 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 544 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 545 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 546 | } | ~ 547 | | 548 | | 549 | debug("BRAM: Setting bank height to %d.\n", this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 550 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 551 | write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 552 | write_byte(ofs, crc_value, file_offset, bram_chunk_size); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 553 | | 554 | for (int bram_bank = 0; bram_bank < 4; bram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 555 | { | ~ 556 | debug("BRAM: Setting bank %d.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 557 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558 | write_byte(ofs, crc_value, file_offset, bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 559 | | 560 | for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 561 | { | ~ 562 | vector bram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 563 | int width = this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 564 | if(this->device == "5k" && ((bram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 565 | width = width / 2; | ~~~~~~~~~~~~~~~~~~ 566 | for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 567 | for (int bram_x = 0; bram_x < width; bram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 | bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 569 | | 570 | debug("BRAM: Setting bank offset to %d.\n", offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 571 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 572 | write_byte(ofs, crc_value, file_offset, offset >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 573 | write_byte(ofs, crc_value, file_offset, offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 574 | | 575 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 576 | debug("BRAM: Setting bank width to %d.\n", width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 577 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 578 | write_byte(ofs, crc_value, file_offset, (width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 579 | write_byte(ofs, crc_value, file_offset, (width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 580 | } | ~ 581 | | 582 | | 583 | if (!this->skip_bram_initialization) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 584 | debug("BRAM: Writing bank %d data.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 585 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 586 | write_byte(ofs, crc_value, file_offset, 0x03); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 587 | for (int i = 0; i < int(bram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 588 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 589 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 590 | byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 591 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 592 | } | ~ 593 | | 594 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 595 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 596 | } | ~ 597 | } | ~ 598 | } | ~ 599 | } | ~ 600 | | 601 | debug("Writing CRC value.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 602 | write_byte(ofs, crc_value, file_offset, 0x22); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 603 | uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 604 | write_byte(ofs, crc_value, file_offset, crc_hi); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 605 | write_byte(ofs, crc_value, file_offset, crc_lo); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 606 | | 607 | debug("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~~ 608 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 609 | write_byte(ofs, crc_value, file_offset, 0x06); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 610 | | 611 | debug("Padding byte.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 612 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 613 | } | ~ 614 | | 615 | void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 616 | { | ~ 617 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 618 | info("Parsing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 619 | | 620 | bool got_device = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 621 | this->cram.clear(); | ~~~~~~~~~~~~~~~~~~~ 622 | this->bram.clear(); | ~~~~~~~~~~~~~~~~~~~ 623 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 624 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 625 | | 626 | bool reuse_line = true; | ~~~~~~~~~~~~~~~~~~~~~~~ 627 | string line, command; | ~~~~~~~~~~~~~~~~~~~~~ 628 | | 629 | while (reuse_line || getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 630 | { | ~ 631 | reuse_line = false; | ~~~~~~~~~~~~~~~~~~~ 632 | | 633 | std::istringstream is(line); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 634 | is >> command; | ~~~~~~~~~~~~~~ 635 | | 636 | if (command.empty()) | ~~~~~~~~~~~~~~~~~~~~ 637 | continue; | ~~~~~~~~~ 638 | | 639 | debug("Next command: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 640 | | 641 | if (command == ".comment") | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 642 | { | ~ 643 | this->initblop.clear(); | ~~~~~~~~~~~~~~~~~~~~~~~ 644 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 645 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 646 | | 647 | while (getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 648 | { | ~ 649 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 650 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 651 | break; | ~~~~~~ 652 | } | ~ 653 | | 654 | for (auto ch : line) | ~~~~~~~~~~~~~~~~~~~~ 655 | this->initblop.push_back(ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 656 | this->initblop.push_back(0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 657 | } | ~ 658 | | 659 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 660 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 661 | continue; | ~~~~~~~~~ 662 | } | ~ 663 | | 664 | if (command == ".device") | ~~~~~~~~~~~~~~~~~~~~~~~~~ 665 | { | ~ 666 | if (got_device) | ~~~~~~~~~~~~~~~ 667 | error("More than one .device statement.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 668 | | 669 | is >> this->device; | ~~~~~~~~~~~~~~~~~~~ 670 | | 671 | if (this->device == "384") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 672 | this->cram_width = 182; | ~~~~~~~~~~~~~~~~~~~~~~~ 673 | this->cram_height = 80; | ~~~~~~~~~~~~~~~~~~~~~~~ 674 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 675 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 676 | } else | ~~~~~~ 677 | if (this->device == "1k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | this->cram_width = 332; | ~~~~~~~~~~~~~~~~~~~~~~~ 679 | this->cram_height = 144; | ~~~~~~~~~~~~~~~~~~~~~~~~ 680 | this->bram_width = 64; | ~~~~~~~~~~~~~~~~~~~~~~ 681 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 682 | } else | ~~~~~~ 683 | if (this->device == "8k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 684 | this->cram_width = 872; | ~~~~~~~~~~~~~~~~~~~~~~~ 685 | this->cram_height = 272; | ~~~~~~~~~~~~~~~~~~~~~~~~ 686 | this->bram_width = 128; | ~~~~~~~~~~~~~~~~~~~~~~~ 687 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 688 | } else | ~~~~~~ 689 | if (this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 690 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 691 | this->cram_height = 336; | ~~~~~~~~~~~~~~~~~~~~~~~~ 692 | this->bram_width = 160; | ~~~~~~~~~~~~~~~~~~~~~~~ 693 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 694 | } else | ~~~~~~ 695 | if (this->device == "u4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 696 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 697 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 698 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 699 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 700 | } else | ~~~~~~ 701 | if (this->device == "lm4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 702 | this->cram_width = 656; | ~~~~~~~~~~~~~~~~~~~~~~~ 703 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 704 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 705 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 706 | } else | ~~~~~~ 707 | error("Unsupported chip type '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 708 | | 709 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 710 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 712 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 713 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 714 | this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 715 | } | ~ 716 | | 717 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 718 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 719 | int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 720 | this->bram[i].resize(width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 721 | for (int x = 0; x < width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 722 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 723 | } | ~ 724 | } else { | ~~~~~~~~ 725 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 726 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 727 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 728 | this->cram[i][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 729 | } | ~ 730 | | 731 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 732 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 733 | this->bram[i].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 734 | for (int x = 0; x < this->bram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 735 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 736 | } | ~ 737 | } | ~ 738 | | 739 | | 740 | got_device = true; | ~~~~~~~~~~~~~~~~~~ 741 | continue; | ~~~~~~~~~ 742 | } | ~ 743 | | 744 | if (command == ".warmboot") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 745 | { | ~ 746 | is >> this->warmboot; | ~~~~~~~~~~~~~~~~~~~~~ 747 | | 748 | if (this->warmboot != "disabled" && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 749 | this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 750 | error("Unknown warmboot setting '%s'.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 751 | this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~ 752 | | 753 | continue; | ~~~~~~~~~ 754 | } | ~ 755 | | 756 | // No ".nosleep" section despite sharing the same byte as .warmboot. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 757 | // ".nosleep" is specified when icepack is invoked, which is too late. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 758 | // So we inject the section based on command line argument. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 759 | if (nosleep) | ~~~~~~~~~~~~ 760 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 761 | else | ~~~~ 762 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 763 | | 764 | if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 765 | { | ~ 766 | if (!got_device) | ~~~~~~~~~~~~~~~~ 767 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 768 | | 769 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 770 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 771 | | 772 | CramIndexConverter cic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 773 | | 774 | if (("." + cic.tile_type + "_tile") != command) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 775 | error("Got %s statement for %s tile %d %d.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 776 | command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 777 | | 778 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 779 | { | ~ 780 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 781 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 782 | break; | ~~~~~~ 783 | } | ~ 784 | | 785 | for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 786 | if (line[bit_x] == '1') { | ~~~~~~~~~~~~~~~~~~~~~~~~~ 787 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 788 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 789 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 790 | } | ~ 791 | } | ~ 792 | | 793 | continue; | ~~~~~~~~~ 794 | } | ~ 795 | | 796 | if (command == ".ram_data") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 797 | { | ~ 798 | if (!got_device) | ~~~~~~~~~~~~~~~~ 799 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 800 | | 801 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 802 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 803 | | 804 | BramIndexConverter bic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 805 | | 806 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 807 | { | ~ 808 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 809 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 810 | break; | ~~~~~~ 811 | } | ~ 812 | | 813 | for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 814 | { | ~ 815 | int value = -1; | ~~~~~~~~~~~~~~~ 816 | if ('0' <= line[ch_idx] && line[ch_idx] <= '9') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 817 | value = line[ch_idx] - '0'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 818 | if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 819 | value = line[ch_idx] - 'a' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 820 | if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 821 | value = line[ch_idx] - 'A' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | if (value < 0) | ~~~~~~~~~~~~~~ 823 | error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 824 | | 825 | for (int i = 0; i < 4; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 826 | if ((value & (1 << i)) != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 827 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 828 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 829 | this->bram[bram_bank][bram_x][bram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 830 | } | ~ 831 | } | ~ 832 | } | ~ 833 | | 834 | continue; | ~~~~~~~~~ 835 | } | ~ 836 | | 837 | if (command == ".extra_bit") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 838 | { | ~ 839 | if (!got_device) | ~~~~~~~~~~~~~~~~ 840 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 841 | | 842 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 843 | is >> cram_bank >> cram_x >> cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 844 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 845 | | 846 | continue; | ~~~~~~~~~ 847 | } | ~ 848 | | 849 | if (command == ".sym") | ~~~~~~~~~~~~~~~~~~~~~~ 850 | continue; | ~~~~~~~~~ 851 | | 852 | if (command.substr(0, 1) == ".") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 853 | error("Unknown statement: %s\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 854 | error("Unexpected data line: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 855 | } | ~ 856 | } | ~ 857 | | 858 | void FpgaConfig::write_ascii(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | { | ~ 860 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 861 | info("Writing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 862 | | 863 | ofs << ".comment"; | ~~~~~~~~~~~~~~~~~~ 864 | bool insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 865 | for (auto ch : this->initblop) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 866 | if (ch == 0) { | ~~~~~~~~~~~~~~ 867 | insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~ 868 | } else if (ch == 0xff) { | ~~~~~~~~~~~~~~~~~~~~~~~~ 869 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 870 | } else { | ~~~~~~~~ 871 | if (insert_newline) | ~~~~~~~~~~~~~~~~~~~ 872 | ofs << '\n'; | ~~~~~~~~~~~~ 873 | ofs << ch; | ~~~~~~~~~~ 874 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 875 | } | ~ 876 | } | ~ 877 | | 878 | ofs << stringf("\n.device %s\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 879 | if (this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 880 | ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 881 | | 882 | // As "nosleep" is an icepack command, we do not write out a ".nosleep" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 883 | // section. However, we parse it in read_bits() and notify the user in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 884 | // info. | ~~~~~~~~ 885 | | 886 | typedef std::tuple tile_bit_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 887 | std::set tile_bits; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 888 | | 889 | for (int y = 0; y <= this->chip_height()+1; y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 890 | for (int x = 0; x <= this->chip_width()+1; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 891 | { | ~ 892 | CramIndexConverter cic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 893 | | 894 | if (cic.tile_type == "corner" || cic.tile_type == "unsupported") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 895 | continue; | ~~~~~~~~~ 896 | | 897 | ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 898 | | 899 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 900 | for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 901 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 902 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 903 | tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 904 | if (cram_x > int(this->cram[cram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 906 | } | ~ 907 | if (cram_y > int(this->cram[cram_bank][cram_x].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 908 | error("cram_y %d (bit %d, %d) larger than bank %d size %lu\n", cram_y, bit_x, bit_y, cram_bank, this->cram[cram_bank][cram_x].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 909 | } | ~ 910 | ofs << (this->cram[cram_bank][cram_x][cram_y] ? '1' : '0'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 911 | } | ~ 912 | ofs << '\n'; | ~~~~~~~~~~~~ 913 | } | ~ 914 | | 915 | if (cic.tile_type == "ramb" && !this->bram.empty()) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 916 | { | ~ 917 | BramIndexConverter bic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 918 | ofs << stringf(".ram_data %d %d\n", x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 919 | | 920 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 921 | for (int bit_x = 256-4; bit_x >= 0; bit_x -= 4) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 922 | int value = 0; | ~~~~~~~~~~~~~~ 923 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 924 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 925 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 926 | if (bram_x >= int(this->bram[bram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 927 | error("%d %d bram_x %d higher than loaded bram size %lu\n",bit_x+i, bit_y, bram_x, this->bram[bram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | std::vector >::size_type {aka unsigned int} icepack.cc:927:8: note: in expansion of macro 'error' 927 | error("%d %d bram_x %d higher than loaded bram size %lu\n",bit_x+i, bit_y, bram_x, this->bram[bram_bank].size()); | ^~~~~ icepack.cc:927:62: note: format string is defined here 927 | error("%d %d bram_x %d higher than loaded bram size %lu\n",bit_x+i, bit_y, bram_x, this->bram[bram_bank].size()); | ~~^ | | | long unsigned int | %u icepack.cc:53:41: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'std::vector::size_type' {aka 'unsigned int'} [-Wformat=] 53 | #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 54 | #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | | 56 | string vstringf(const char *fmt, va_list ap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 | { | ~ 58 | string string; | ~~~~~~~~~~~~~~ 59 | char *str = NULL; | ~~~~~~~~~~~~~~~~~ 60 | | 61 | #ifdef _WIN32 | ~~~~~~~~~~~~~ 62 | int sz = 64, rc; | ~~~~~~~~~~~~~~~~ 63 | while (1) { | ~~~~~~~~~~~ 64 | va_list apc; | ~~~~~~~~~~~~ 65 | va_copy(apc, ap); | ~~~~~~~~~~~~~~~~~ 66 | str = (char*)realloc(str, sz); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 67 | rc = vsnprintf(str, sz, fmt, apc); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | va_end(apc); | ~~~~~~~~~~~~ 69 | if (rc >= 0 && rc < sz) | ~~~~~~~~~~~~~~~~~~~~~~~ 70 | break; | ~~~~~~ 71 | sz *= 2; | ~~~~~~~~ 72 | } | ~ 73 | #else | ~~~~~ 74 | if (vasprintf(&str, fmt, ap) < 0) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 75 | str = NULL; | ~~~~~~~~~~~ 76 | #endif | ~~~~~~ 77 | | 78 | if (str != NULL) { | ~~~~~~~~~~~~~~~~~~ 79 | string = str; | ~~~~~~~~~~~~~ 80 | free(str); | ~~~~~~~~~~ 81 | } | ~ 82 | | 83 | return string; | ~~~~~~~~~~~~~~ 84 | } | ~ 85 | | 86 | string stringf(const char *fmt, ...) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 87 | { | ~ 88 | string string; | ~~~~~~~~~~~~~~ 89 | va_list ap; | ~~~~~~~~~~~ 90 | | 91 | va_start(ap, fmt); | ~~~~~~~~~~~~~~~~~~ 92 | string = vstringf(fmt, ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | va_end(ap); | ~~~~~~~~~~~ 94 | | 95 | return string; | ~~~~~~~~~~~~~~ 96 | } | ~ 97 | | 98 | // ================================================================== | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 99 | // FpgaConfig stuff | ~~~~~~~~~~~~~~~~~~~ 100 | | 101 | struct FpgaConfig | ~~~~~~~~~~~~~~~~~ 102 | { | ~ 103 | string device; | ~~~~~~~~~~~~~~ 104 | string freqrange; | ~~~~~~~~~~~~~~~~~ 105 | string nosleep; | ~~~~~~~~~~~~~~~ 106 | string warmboot; | ~~~~~~~~~~~~~~~~ 107 | | 108 | // cram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 109 | int cram_width, cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | vector>> cram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111 | | 112 | // bram[BANK][X][Y] | ~~~~~~~~~~~~~~~~~~~ 113 | int bram_width, bram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 114 | vector>> bram; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 115 | bool skip_bram_initialization; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 116 | | 117 | // data before preamble | ~~~~~~~~~~~~~~~~~~~~~~~ 118 | vector initblop; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 119 | | 120 | // bitstream i/o | ~~~~~~~~~~~~~~~~ 121 | void read_bits(std::istream &ifs); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | void write_bits(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 123 | | 124 | // icebox i/o | ~~~~~~~~~~~~~ 125 | void read_ascii(std::istream &ifs, bool nosleep); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 126 | void write_ascii(std::ostream &ofs) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127 | | 128 | // netpbm i/o | ~~~~~~~~~~~~~ 129 | void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 130 | void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 131 | | 132 | // query chip type metadata | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 133 | int chip_width() const; | ~~~~~~~~~~~~~~~~~~~~~~~ 134 | int chip_height() const; | ~~~~~~~~~~~~~~~~~~~~~~~~ 135 | vector chip_cols() const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136 | | 137 | // query tile metadata | ~~~~~~~~~~~~~~~~~~~~~~ 138 | string tile_type(int x, int y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 | int tile_width(const string &type) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | | 141 | // cram bit manipulation | ~~~~~~~~~~~~~~~~~~~~~~~~ 142 | void cram_clear(); | ~~~~~~~~~~~~~~~~~~ 143 | void cram_fill_tiles(); | ~~~~~~~~~~~~~~~~~~~~~~~ 144 | void cram_checkerboard(int m = 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 145 | }; | ~~ 146 | | 147 | struct CramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 148 | { | ~ 149 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 150 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 151 | | 152 | string tile_type; | ~~~~~~~~~~~~~~~~~ 153 | int tile_width; | ~~~~~~~~~~~~~~~ 154 | int column_width; | ~~~~~~~~~~~~~~~~~ 155 | | 156 | bool left_right_io; | ~~~~~~~~~~~~~~~~~~~ 157 | bool right_half; | ~~~~~~~~~~~~~~~~ 158 | bool top_half; | ~~~~~~~~~~~~~~ 159 | | 160 | int bank_num; | ~~~~~~~~~~~~~ 161 | int bank_tx; | ~~~~~~~~~~~~ 162 | int bank_ty; | ~~~~~~~~~~~~ 163 | int bank_xoff; | ~~~~~~~~~~~~~~ 164 | int bank_yoff; | ~~~~~~~~~~~~~~ 165 | | 166 | CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 167 | void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 168 | }; | ~~ 169 | | 170 | struct BramIndexConverter | ~~~~~~~~~~~~~~~~~~~~~~~~~ 171 | { | ~ 172 | const FpgaConfig *fpga; | ~~~~~~~~~~~~~~~~~~~~~~~ 173 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 174 | | 175 | int bank_num; | ~~~~~~~~~~~~~ 176 | int bank_off; | ~~~~~~~~~~~~~ 177 | | 178 | BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 179 | void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 180 | }; | ~~ 181 | | 182 | static void update_crc16(uint16_t &crc, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 183 | { | ~ 184 | // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 185 | for (int i = 7; i >= 0; i--) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 186 | uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 187 | crc = (crc << 1) ^ xor_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | } | ~ 189 | } | ~ 190 | | 191 | static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 192 | { | ~ 193 | int byte = ifs.get(); | ~~~~~~~~~~~~~~~~~~~~~ 194 | | 195 | if (byte < 0) | ~~~~~~~~~~~~~ 196 | error("Unexpected end of file.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 197 | | 198 | file_offset++; | ~~~~~~~~~~~~~~ 199 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 200 | | 201 | return byte; | ~~~~~~~~~~~~ 202 | } | ~ 203 | | 204 | static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 205 | { | ~ 206 | ofs << byte; | ~~~~~~~~~~~~ 207 | file_offset++; | ~~~~~~~~~~~~~~ 208 | update_crc16(crc_value, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 209 | } | ~ 210 | | 211 | void FpgaConfig::read_bits(std::istream &ifs) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 212 | { | ~ 213 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 214 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 215 | | 216 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | info("Parsing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 218 | | 219 | // skip initial comments until preamble is found | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 220 | | 221 | uint32_t preamble = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 222 | | 223 | while (1) | ~~~~~~~~~ 224 | { | ~ 225 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 226 | preamble = (preamble << 8) | byte; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 227 | if (preamble == 0xffffffff) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 228 | error("No preamble found in bitstream.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 229 | if (preamble == 0x7EAA997E) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230 | info("Found preamble at offset %d.\n", file_offset-4); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 231 | break; | ~~~~~~ 232 | } | ~ 233 | initblop.push_back(byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 234 | } | ~ 235 | | 236 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 237 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 238 | initblop.pop_back(); | ~~~~~~~~~~~~~~~~~~~~ 239 | | 240 | // main parser loop | ~~~~~~~~~~~~~~~~~~~ 241 | | 242 | int current_bank = 0; | ~~~~~~~~~~~~~~~~~~~~~ 243 | int current_width = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 244 | int current_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 245 | int current_offset = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 246 | bool wakeup = false; | ~~~~~~~~~~~~~~~~~~~~ 247 | | 248 | this->cram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 249 | this->cram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 250 | | 251 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 252 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 253 | | 254 | while (!wakeup) | ~~~~~~~~~~~~~~~ 255 | { | ~ 256 | // one command byte. the lower 4 bits of the command byte specify | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | // the length of the command payload. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | | 259 | uint8_t command = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 260 | uint32_t payload = 0; | ~~~~~~~~~~~~~~~~~~~~~ 261 | | 262 | for (int i = 0; i < (command & 0x0f); i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 263 | payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 264 | | 265 | debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 266 | command, 2*(command & 0x0f), payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 267 | | 268 | uint16_t end_token; | ~~~~~~~~~~~~~~~~~~~ 269 | | 270 | switch (command & 0xf0) | ~~~~~~~~~~~~~~~~~~~~~~~ 271 | { | ~ 272 | case 0x00: | ~~~~~~~~~~ 273 | switch (payload) | ~~~~~~~~~~~~~~~~ 274 | { | ~ 275 | case 0x01: | ~~~~~~~~~~ 276 | info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 277 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 278 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 279 | | 280 | this->cram_width = std::max(this->cram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281 | this->cram_height = std::max(this->cram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 282 | | 283 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 284 | this->cram[current_bank].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 285 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 286 | this->cram[current_bank][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 287 | | 288 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 289 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 290 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 291 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 292 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 293 | this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 294 | } | ~ 295 | } | ~ 296 | | 297 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 299 | if (end_token) | ~~~~~~~~~~~~~~ 300 | error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 301 | break; | ~~~~~~ 302 | | 303 | case 0x03: | ~~~~~~~~~~ 304 | info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 305 | current_bank, current_width, current_height, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 306 | current_height*current_width, (current_height*current_width)/8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 307 | | 308 | this->bram_width = std::max(this->bram_width, current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 309 | this->bram_height = std::max(this->bram_height, current_offset + current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 310 | | 311 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 312 | this->bram[current_bank].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 313 | for (int x = 0; x < current_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 314 | this->bram[current_bank][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 315 | | 316 | for (int i = 0; i < (current_height*current_width)/8; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 317 | uint8_t byte = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 318 | for (int j = 0; j < 8; j++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 319 | int x = (i*8 + j) % current_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 320 | int y = (i*8 + j) / current_width + current_offset; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 321 | this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 322 | } | ~ 323 | } | ~ 324 | | 325 | end_token = read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 326 | end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 327 | if (end_token) | ~~~~~~~~~~~~~~ 328 | error("Expected 0x0000 after BRAM data, got 0x%04x\n", end_token); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329 | break; | ~~~~~~ 330 | | 331 | case 0x05: | ~~~~~~~~~~ 332 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 333 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 334 | break; | ~~~~~~ 335 | | 336 | case 0x06: | ~~~~~~~~~~ 337 | info("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~ 338 | wakeup = true; | ~~~~~~~~~~~~~~ 339 | break; | ~~~~~~ 340 | | 341 | default: | ~~~~~~~~ 342 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 343 | } | ~ 344 | break; | ~~~~~~ 345 | | 346 | case 0x10: | ~~~~~~~~~~ 347 | current_bank = payload; | ~~~~~~~~~~~~~~~~~~~~~~~ 348 | debug("Set bank to %d.\n", current_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 349 | break; | ~~~~~~ 350 | | 351 | case 0x20: | ~~~~~~~~~~ 352 | if (crc_value != 0) | ~~~~~~~~~~~~~~~~~~~ 353 | error("CRC Check FAILED.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 354 | info("CRC Check OK.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~ 355 | break; | ~~~~~~ 356 | | 357 | case 0x50: | ~~~~~~~~~~ 358 | if (payload == 0) | ~~~~~~~~~~~~~~~~~ 359 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 360 | else if (payload == 1) | ~~~~~~~~~~~~~~~~~~~~~~ 361 | this->freqrange = "medium"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 362 | else if (payload == 2) | ~~~~~~~~~~~~~~~~~~~~~~ 363 | this->freqrange = "high"; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 364 | else | ~~~~ 365 | error("Unknown freqrange payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 366 | info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 367 | break; | ~~~~~~ 368 | | 369 | case 0x60: | ~~~~~~~~~~ 370 | current_width = payload + 1; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 371 | debug("Setting bank width to %d.\n", current_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 372 | break; | ~~~~~~ 373 | | 374 | case 0x70: | ~~~~~~~~~~ 375 | current_height = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 376 | debug("Setting bank height to %d.\n", current_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 377 | break; | ~~~~~~ 378 | | 379 | case 0x80: | ~~~~~~~~~~ 380 | current_offset = payload; | ~~~~~~~~~~~~~~~~~~~~~~~~~ 381 | debug("Setting bank offset to %d.\n", current_offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 382 | break; | ~~~~~~ 383 | | 384 | case 0x90: | ~~~~~~~~~~ 385 | switch(payload) | ~~~~~~~~~~~~~~~ 386 | { | ~ 387 | case 0: | ~~~~~~~ 388 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 389 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 390 | break; | ~~~~~~ 391 | case 1: | ~~~~~~~ 392 | this->warmboot = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 394 | break; | ~~~~~~ 395 | case 32: | ~~~~~~~~ 396 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 397 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 398 | break; | ~~~~~~ 399 | case 33: | ~~~~~~~~ 400 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 401 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 402 | break; | ~~~~~~ 403 | default: | ~~~~~~~~ 404 | error("Unknown warmboot/nosleep payload 0x%02x\n", payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 405 | } | ~ 406 | info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 407 | break; | ~~~~~~ 408 | | 409 | default: | ~~~~~~~~ 410 | error("Unknown command: 0x%02x 0x%02x\n", command, payload); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 411 | } | ~ 412 | } | ~ 413 | | 414 | if (this->cram_width == 182 && this->cram_height == 80) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 415 | this->device = "384"; | ~~~~~~~~~~~~~~~~~~~~~ 416 | else if (this->cram_width == 332 && this->cram_height == 144) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 417 | this->device = "1k"; | ~~~~~~~~~~~~~~~~~~~~ 418 | else if (this->cram_width == 872 && this->cram_height == 272) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 419 | this->device = "8k"; | ~~~~~~~~~~~~~~~~~~~~ 420 | else if (this->cram_width == 692 && this->cram_height == 336) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 421 | this->device = "5k"; | ~~~~~~~~~~~~~~~~~~~~ 422 | else if (this->cram_width == 692 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 423 | this->device = "u4k"; | ~~~~~~~~~~~~~~~~~~~~~ 424 | else if (this->cram_width == 656 && this->cram_height == 176) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 425 | this->device = "lm4k"; | ~~~~~~~~~~~~~~~~~~~~~~ 426 | else | ~~~~ 427 | error("Failed to detect chip type.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 | | 429 | info("Chip type is '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 430 | } | ~ 431 | | 432 | void FpgaConfig::write_bits(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 433 | { | ~ 434 | int file_offset = 0; | ~~~~~~~~~~~~~~~~~~~~ 435 | uint16_t crc_value = 0; | ~~~~~~~~~~~~~~~~~~~~~~~ 436 | | 437 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 438 | info("Writing bitstream file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 439 | | 440 | for (auto byte : this->initblop) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 441 | ofs << byte; | ~~~~~~~~~~~~ 442 | | 443 | debug("Writing preamble.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 444 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 445 | write_byte(ofs, crc_value, file_offset, 0xAA); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 446 | write_byte(ofs, crc_value, file_offset, 0x99); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 447 | write_byte(ofs, crc_value, file_offset, 0x7E); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 448 | | 449 | debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 450 | write_byte(ofs, crc_value, file_offset, 0x51); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 451 | if (this->freqrange == "low") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 452 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 453 | else if (this->freqrange == "medium") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 454 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 455 | else if (this->freqrange == "high") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 456 | write_byte(ofs, crc_value, file_offset, 0x02); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 457 | else | ~~~~ 458 | error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 459 | | 460 | debug("Resetting CRC.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 461 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 462 | write_byte(ofs, crc_value, file_offset, 0x05); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 463 | crc_value = 0xffff; | ~~~~~~~~~~~~~~~~~~~ 464 | | 465 | { | ~ 466 | uint8_t nosleep_flag; | ~~~~~~~~~~~~~~~~~~~~~ 467 | debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 468 | write_byte(ofs, crc_value, file_offset, 0x92); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 469 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 470 | | 471 | if (this->nosleep == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 | nosleep_flag = 0; | ~~~~~~~~~~~~~~~~~ 473 | else if (this->nosleep == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 474 | nosleep_flag = 1; | ~~~~~~~~~~~~~~~~~ 475 | else | ~~~~ 476 | error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 477 | | 478 | if (this->warmboot == "disabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 479 | write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 480 | else if (this->warmboot == "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 481 | write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 482 | else | ~~~~ 483 | error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 484 | } | ~ 485 | | 486 | debug("CRAM: Setting bank width to %d.\n", this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 487 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 488 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 489 | write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 490 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 491 | debug("CRAM: Setting bank height to %d.\n", this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 492 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 493 | write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 494 | write_byte(ofs, crc_value, file_offset, this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 495 | } | ~ 496 | | 497 | debug("CRAM: Setting bank offset to 0.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 498 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 499 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 500 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 501 | | 502 | for (int cram_bank = 0; cram_bank < 4; cram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 503 | { | ~ 504 | vector cram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 505 | int height = this->cram_height; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 506 | if(this->device == "5k" && ((cram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 507 | height = height / 2 + 8; | ~~~~~~~~~~~~~~~~~~~~~~~~ 508 | for (int cram_y = 0; cram_y < height; cram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 509 | for (int cram_x = 0; cram_x < this->cram_width; cram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 510 | cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 511 | | 512 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 513 | debug("CRAM: Setting bank height to %d.\n", height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 514 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 515 | write_byte(ofs, crc_value, file_offset, height >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 516 | write_byte(ofs, crc_value, file_offset, height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 517 | } | ~ 518 | | 519 | debug("CRAM: Setting bank %d.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 520 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 521 | write_byte(ofs, crc_value, file_offset, cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 522 | | 523 | debug("CRAM: Writing bank %d data.\n", cram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 524 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 525 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 526 | for (int i = 0; i < int(cram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 527 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 528 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 529 | byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 530 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 531 | } | ~ 532 | | 533 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 534 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 535 | } | ~ 536 | | 537 | int bram_chunk_size = 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 538 | | 539 | if (this->bram_width && this->bram_height) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 540 | { | ~ 541 | if(this->device != "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 542 | debug("BRAM: Setting bank width to %d.\n", this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 543 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 544 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 545 | write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 546 | } | ~ 547 | | 548 | | 549 | debug("BRAM: Setting bank height to %d.\n", this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 550 | write_byte(ofs, crc_value, file_offset, 0x72); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 551 | write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 552 | write_byte(ofs, crc_value, file_offset, bram_chunk_size); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 553 | | 554 | for (int bram_bank = 0; bram_bank < 4; bram_bank++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 555 | { | ~ 556 | debug("BRAM: Setting bank %d.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 557 | write_byte(ofs, crc_value, file_offset, 0x11); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 558 | write_byte(ofs, crc_value, file_offset, bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 559 | | 560 | for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 561 | { | ~ 562 | vector bram_bits; | ~~~~~~~~~~~~~~~~~~~~~~~ 563 | int width = this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 564 | if(this->device == "5k" && ((bram_bank % 2) == 1)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 565 | width = width / 2; | ~~~~~~~~~~~~~~~~~~ 566 | for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 567 | for (int bram_x = 0; bram_x < width; bram_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 | bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 569 | | 570 | debug("BRAM: Setting bank offset to %d.\n", offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 571 | write_byte(ofs, crc_value, file_offset, 0x82); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 572 | write_byte(ofs, crc_value, file_offset, offset >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 573 | write_byte(ofs, crc_value, file_offset, offset); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 574 | | 575 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 576 | debug("BRAM: Setting bank width to %d.\n", width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 577 | write_byte(ofs, crc_value, file_offset, 0x62); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 578 | write_byte(ofs, crc_value, file_offset, (width-1) >> 8); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 579 | write_byte(ofs, crc_value, file_offset, (width-1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 580 | } | ~ 581 | | 582 | | 583 | if (!this->skip_bram_initialization) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 584 | debug("BRAM: Writing bank %d data.\n", bram_bank); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 585 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 586 | write_byte(ofs, crc_value, file_offset, 0x03); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 587 | for (int i = 0; i < int(bram_bits.size()); i += 8) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 588 | uint8_t byte = 0; | ~~~~~~~~~~~~~~~~~ 589 | for (int j = 0; j < 8; j++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 590 | byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 591 | write_byte(ofs, crc_value, file_offset, byte); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 592 | } | ~ 593 | | 594 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 595 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 596 | } | ~ 597 | } | ~ 598 | } | ~ 599 | } | ~ 600 | | 601 | debug("Writing CRC value.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 602 | write_byte(ofs, crc_value, file_offset, 0x22); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 603 | uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 604 | write_byte(ofs, crc_value, file_offset, crc_hi); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 605 | write_byte(ofs, crc_value, file_offset, crc_lo); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 606 | | 607 | debug("Wakeup.\n"); | ~~~~~~~~~~~~~~~~~~~ 608 | write_byte(ofs, crc_value, file_offset, 0x01); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 609 | write_byte(ofs, crc_value, file_offset, 0x06); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 610 | | 611 | debug("Padding byte.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~ 612 | write_byte(ofs, crc_value, file_offset, 0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 613 | } | ~ 614 | | 615 | void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 616 | { | ~ 617 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 618 | info("Parsing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 619 | | 620 | bool got_device = false; | ~~~~~~~~~~~~~~~~~~~~~~~~ 621 | this->cram.clear(); | ~~~~~~~~~~~~~~~~~~~ 622 | this->bram.clear(); | ~~~~~~~~~~~~~~~~~~~ 623 | this->freqrange = "low"; | ~~~~~~~~~~~~~~~~~~~~~~~~ 624 | this->warmboot = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 625 | | 626 | bool reuse_line = true; | ~~~~~~~~~~~~~~~~~~~~~~~ 627 | string line, command; | ~~~~~~~~~~~~~~~~~~~~~ 628 | | 629 | while (reuse_line || getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 630 | { | ~ 631 | reuse_line = false; | ~~~~~~~~~~~~~~~~~~~ 632 | | 633 | std::istringstream is(line); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 634 | is >> command; | ~~~~~~~~~~~~~~ 635 | | 636 | if (command.empty()) | ~~~~~~~~~~~~~~~~~~~~ 637 | continue; | ~~~~~~~~~ 638 | | 639 | debug("Next command: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 640 | | 641 | if (command == ".comment") | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 642 | { | ~ 643 | this->initblop.clear(); | ~~~~~~~~~~~~~~~~~~~~~~~ 644 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 645 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 646 | | 647 | while (getline(ifs, line)) | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 648 | { | ~ 649 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 650 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 651 | break; | ~~~~~~ 652 | } | ~ 653 | | 654 | for (auto ch : line) | ~~~~~~~~~~~~~~~~~~~~ 655 | this->initblop.push_back(ch); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 656 | this->initblop.push_back(0); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 657 | } | ~ 658 | | 659 | this->initblop.push_back(0x00); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 660 | this->initblop.push_back(0xff); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 661 | continue; | ~~~~~~~~~ 662 | } | ~ 663 | | 664 | if (command == ".device") | ~~~~~~~~~~~~~~~~~~~~~~~~~ 665 | { | ~ 666 | if (got_device) | ~~~~~~~~~~~~~~~ 667 | error("More than one .device statement.\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 668 | | 669 | is >> this->device; | ~~~~~~~~~~~~~~~~~~~ 670 | | 671 | if (this->device == "384") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 672 | this->cram_width = 182; | ~~~~~~~~~~~~~~~~~~~~~~~ 673 | this->cram_height = 80; | ~~~~~~~~~~~~~~~~~~~~~~~ 674 | this->bram_width = 0; | ~~~~~~~~~~~~~~~~~~~~~ 675 | this->bram_height = 0; | ~~~~~~~~~~~~~~~~~~~~~~ 676 | } else | ~~~~~~ 677 | if (this->device == "1k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 678 | this->cram_width = 332; | ~~~~~~~~~~~~~~~~~~~~~~~ 679 | this->cram_height = 144; | ~~~~~~~~~~~~~~~~~~~~~~~~ 680 | this->bram_width = 64; | ~~~~~~~~~~~~~~~~~~~~~~ 681 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 682 | } else | ~~~~~~ 683 | if (this->device == "8k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 684 | this->cram_width = 872; | ~~~~~~~~~~~~~~~~~~~~~~~ 685 | this->cram_height = 272; | ~~~~~~~~~~~~~~~~~~~~~~~~ 686 | this->bram_width = 128; | ~~~~~~~~~~~~~~~~~~~~~~~ 687 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 688 | } else | ~~~~~~ 689 | if (this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 690 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 691 | this->cram_height = 336; | ~~~~~~~~~~~~~~~~~~~~~~~~ 692 | this->bram_width = 160; | ~~~~~~~~~~~~~~~~~~~~~~~ 693 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 694 | } else | ~~~~~~ 695 | if (this->device == "u4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 696 | this->cram_width = 692; | ~~~~~~~~~~~~~~~~~~~~~~~ 697 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 698 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 699 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 700 | } else | ~~~~~~ 701 | if (this->device == "lm4k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 702 | this->cram_width = 656; | ~~~~~~~~~~~~~~~~~~~~~~~ 703 | this->cram_height = 176; | ~~~~~~~~~~~~~~~~~~~~~~~~ 704 | this->bram_width = 80; | ~~~~~~~~~~~~~~~~~~~~~~ 705 | this->bram_height = 2 * 128; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 706 | } else | ~~~~~~ 707 | error("Unsupported chip type '%s'.\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 708 | | 709 | this->cram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 710 | if(this->device == "5k") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 711 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 712 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 713 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 714 | this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 715 | } | ~ 716 | | 717 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 718 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 719 | int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 720 | this->bram[i].resize(width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 721 | for (int x = 0; x < width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 722 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 723 | } | ~ 724 | } else { | ~~~~~~~~ 725 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 726 | this->cram[i].resize(this->cram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 727 | for (int x = 0; x < this->cram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 728 | this->cram[i][x].resize(this->cram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 729 | } | ~ 730 | | 731 | this->bram.resize(4); | ~~~~~~~~~~~~~~~~~~~~~ 732 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 733 | this->bram[i].resize(this->bram_width); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 734 | for (int x = 0; x < this->bram_width; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 735 | this->bram[i][x].resize(this->bram_height); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 736 | } | ~ 737 | } | ~ 738 | | 739 | | 740 | got_device = true; | ~~~~~~~~~~~~~~~~~~ 741 | continue; | ~~~~~~~~~ 742 | } | ~ 743 | | 744 | if (command == ".warmboot") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 745 | { | ~ 746 | is >> this->warmboot; | ~~~~~~~~~~~~~~~~~~~~~ 747 | | 748 | if (this->warmboot != "disabled" && | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 749 | this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 750 | error("Unknown warmboot setting '%s'.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 751 | this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~ 752 | | 753 | continue; | ~~~~~~~~~ 754 | } | ~ 755 | | 756 | // No ".nosleep" section despite sharing the same byte as .warmboot. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 757 | // ".nosleep" is specified when icepack is invoked, which is too late. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 758 | // So we inject the section based on command line argument. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 759 | if (nosleep) | ~~~~~~~~~~~~ 760 | this->nosleep = "enabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 761 | else | ~~~~ 762 | this->nosleep = "disabled"; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 763 | | 764 | if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 765 | { | ~ 766 | if (!got_device) | ~~~~~~~~~~~~~~~~ 767 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 768 | | 769 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 770 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 771 | | 772 | CramIndexConverter cic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 773 | | 774 | if (("." + cic.tile_type + "_tile") != command) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 775 | error("Got %s statement for %s tile %d %d.\n", | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 776 | command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 777 | | 778 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 779 | { | ~ 780 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 781 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 782 | break; | ~~~~~~ 783 | } | ~ 784 | | 785 | for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 786 | if (line[bit_x] == '1') { | ~~~~~~~~~~~~~~~~~~~~~~~~~ 787 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 788 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 789 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 790 | } | ~ 791 | } | ~ 792 | | 793 | continue; | ~~~~~~~~~ 794 | } | ~ 795 | | 796 | if (command == ".ram_data") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 797 | { | ~ 798 | if (!got_device) | ~~~~~~~~~~~~~~~~ 799 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 800 | | 801 | int tile_x, tile_y; | ~~~~~~~~~~~~~~~~~~~ 802 | is >> tile_x >> tile_y; | ~~~~~~~~~~~~~~~~~~~~~~~ 803 | | 804 | BramIndexConverter bic(this, tile_x, tile_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 805 | | 806 | for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 807 | { | ~ 808 | if (line.substr(0, 1) == ".") { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 809 | reuse_line = true; | ~~~~~~~~~~~~~~~~~~ 810 | break; | ~~~~~~ 811 | } | ~ 812 | | 813 | for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 814 | { | ~ 815 | int value = -1; | ~~~~~~~~~~~~~~~ 816 | if ('0' <= line[ch_idx] && line[ch_idx] <= '9') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 817 | value = line[ch_idx] - '0'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 818 | if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 819 | value = line[ch_idx] - 'a' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 820 | if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 821 | value = line[ch_idx] - 'A' + 10; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | if (value < 0) | ~~~~~~~~~~~~~~ 823 | error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 824 | | 825 | for (int i = 0; i < 4; i++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 826 | if ((value & (1 << i)) != 0) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 827 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 828 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 829 | this->bram[bram_bank][bram_x][bram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 830 | } | ~ 831 | } | ~ 832 | } | ~ 833 | | 834 | continue; | ~~~~~~~~~ 835 | } | ~ 836 | | 837 | if (command == ".extra_bit") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 838 | { | ~ 839 | if (!got_device) | ~~~~~~~~~~~~~~~~ 840 | error("Missing .device statement before %s.\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 841 | | 842 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 843 | is >> cram_bank >> cram_x >> cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 844 | this->cram[cram_bank][cram_x][cram_y] = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 845 | | 846 | continue; | ~~~~~~~~~ 847 | } | ~ 848 | | 849 | if (command == ".sym") | ~~~~~~~~~~~~~~~~~~~~~~ 850 | continue; | ~~~~~~~~~ 851 | | 852 | if (command.substr(0, 1) == ".") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 853 | error("Unknown statement: %s\n", command.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 854 | error("Unexpected data line: %s\n", line.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 855 | } | ~ 856 | } | ~ 857 | | 858 | void FpgaConfig::write_ascii(std::ostream &ofs) const | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | { | ~ 860 | debug("## %s\n", __PRETTY_FUNCTION__); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 861 | info("Writing ascii file..\n"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 862 | | 863 | ofs << ".comment"; | ~~~~~~~~~~~~~~~~~~ 864 | bool insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 865 | for (auto ch : this->initblop) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 866 | if (ch == 0) { | ~~~~~~~~~~~~~~ 867 | insert_newline = true; | ~~~~~~~~~~~~~~~~~~~~~~ 868 | } else if (ch == 0xff) { | ~~~~~~~~~~~~~~~~~~~~~~~~ 869 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 870 | } else { | ~~~~~~~~ 871 | if (insert_newline) | ~~~~~~~~~~~~~~~~~~~ 872 | ofs << '\n'; | ~~~~~~~~~~~~ 873 | ofs << ch; | ~~~~~~~~~~ 874 | insert_newline = false; | ~~~~~~~~~~~~~~~~~~~~~~~ 875 | } | ~ 876 | } | ~ 877 | | 878 | ofs << stringf("\n.device %s\n", this->device.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 879 | if (this->warmboot != "enabled") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 880 | ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 881 | | 882 | // As "nosleep" is an icepack command, we do not write out a ".nosleep" | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 883 | // section. However, we parse it in read_bits() and notify the user in | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 884 | // info. | ~~~~~~~~ 885 | | 886 | typedef std::tuple tile_bit_t; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 887 | std::set tile_bits; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 888 | | 889 | for (int y = 0; y <= this->chip_height()+1; y++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 890 | for (int x = 0; x <= this->chip_width()+1; x++) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 891 | { | ~ 892 | CramIndexConverter cic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 893 | | 894 | if (cic.tile_type == "corner" || cic.tile_type == "unsupported") | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 895 | continue; | ~~~~~~~~~ 896 | | 897 | ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 898 | | 899 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 900 | for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 901 | int cram_bank, cram_x, cram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 902 | cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 903 | tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 904 | if (cram_x > int(this->cram[cram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 905 | error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 906 | } | ~ 907 | if (cram_y > int(this->cram[cram_bank][cram_x].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 908 | error("cram_y %d (bit %d, %d) larger than bank %d size %lu\n", cram_y, bit_x, bit_y, cram_bank, this->cram[cram_bank][cram_x].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 909 | } | ~ 910 | ofs << (this->cram[cram_bank][cram_x][cram_y] ? '1' : '0'); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 911 | } | ~ 912 | ofs << '\n'; | ~~~~~~~~~~~~ 913 | } | ~ 914 | | 915 | if (cic.tile_type == "ramb" && !this->bram.empty()) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 916 | { | ~ 917 | BramIndexConverter bic(this, x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 918 | ofs << stringf(".ram_data %d %d\n", x, y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 919 | | 920 | for (int bit_y = 0; bit_y < 16; bit_y++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 921 | for (int bit_x = 256-4; bit_x >= 0; bit_x -= 4) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 922 | int value = 0; | ~~~~~~~~~~~~~~ 923 | for (int i = 0; i < 4; i++) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 924 | int bram_bank, bram_x, bram_y; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 925 | bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 926 | if (bram_x >= int(this->bram[bram_bank].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 927 | error("%d %d bram_x %d higher than loaded bram size %lu\n",bit_x+i, bit_y, bram_x, this->bram[bram_bank].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 928 | break; | ~~~~~~ 929 | } | ~ 930 | if (bram_y >= int(this->bram[bram_bank][bram_x].size())) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 931 | error("bram_y %d higher than loaded bram size %lu\n", bram_y, this->bram[bram_bank][bram_x].size()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | std::vector::size_type {aka unsigned int} icepack.cc:931:8: note: in expansion of macro 'error' 931 | error("bram_y %d higher than loaded bram size %lu\n", bram_y, this->bram[bram_bank][bram_x].size()); | ^~~~~ icepack.cc:931:56: note: format string is defined here 931 | error("bram_y %d higher than loaded bram size %lu\n", bram_y, this->bram[bram_bank][bram_x].size()); | ~~^ | | | long unsigned int | %u make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' g++ -o icepack icepack.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' ln -sf icepack iceunpack make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o iceutil.o iceutil.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py lp384 > timings-lp384.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py lp1k > timings-lp1k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py lp8k > timings-lp8k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py hx1k > timings-hx1k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py hx8k > timings-hx8k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py up5k > timings-up5k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py -3 > chipdb-384.new mv chipdb-384.new chipdb-384.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' python3 timings.py u4k > timings-u4k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-lp384.o timings-lp384.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-lp8k.o timings-lp8k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-lp1k.o timings-lp1k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py > chipdb-1k.new mv chipdb-1k.new chipdb-1k.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-hx1k.o timings-hx1k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-hx8k.o timings-hx8k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-u4k.o timings-u4k.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o icetime.o icetime.cc make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py -4 > chipdb-lm4k.new mv chipdb-lm4k.new chipdb-lm4k.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py -u > chipdb-u4k.new mv chipdb-u4k.new chipdb-u4k.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py -5 > chipdb-5k.new mv chipdb-5k.new chipdb-5k.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' python3 icebox_chipdb.py -8 > chipdb-8k.new mv chipdb-8k.new chipdb-8k.txt make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic -Wextra -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -c -o timings-up5k.o timings-up5k.cc timings-up5k.cc: In function 'double get_delay_up5k(std::string, std::string, std::string)': timings-up5k.cc:6:8: note: variable tracking size limit exceeded with '-fvar-tracking-assignments', retrying without 6 | double get_delay_up5k(std::string cell_type, std::string in_port, std::string out_port) | ^~~~~~~~~~~~~~ make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' g++ -o icetime icetime.o iceutil.o timings-lp384.o timings-lp1k.o timings-lp8k.o timings-hx1k.o timings-hx8k.o timings-up5k.o timings-u4k.o -lftdi1 -lusb-1.0 -lm make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' + exit 0 Executing(%install): /bin/sh -e /usr/src/tmp/rpm-tmp.72040 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + /bin/chmod -Rf u+rwX -- /usr/src/tmp/icestorm-buildroot + : + /bin/rm -rf -- /usr/src/tmp/icestorm-buildroot + PATH=/usr/libexec/rpm-build:/usr/src/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games + cd icestorm-0.0.0.777.gc495861 + make 'INSTALL=/usr/libexec/rpm-build/install -p' install DESTDIR=/usr/src/tmp/icestorm-buildroot PREFIX=/usr make: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861' for dir in icebox icepack icemulti icepll icebram icetime iceprog; do \ make -C $dir install || exit; \ done make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/share/icebox mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp chipdb-384.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp chipdb-1k.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp chipdb-8k.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp chipdb-5k.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp chipdb-u4k.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp chipdb-lm4k.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ cp icebox.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox.py cp iceboxdb.py /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py cp icebox_chipdb.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_chipdb cp icebox_diff.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_diff cp icebox_explain.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_explain cp icebox_asc2hlc.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_asc2hlc cp icebox_hlc2asc.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_hlc2asc cp icebox_colbuf.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_colbuf cp icebox_html.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_html cp icebox_maps.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_maps cp icebox_vlog.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_vlog cp icebox_stat.py /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_stat sed -i 's+import iceboxdb+import iceboxdb as iceboxdb+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox.py sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_chipdb sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_diff sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_diff sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_explain sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_explain sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_asc2hlc sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_asc2hlc sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_hlc2asc sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_hlc2asc sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_colbuf sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_colbuf sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_html sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_html sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_maps sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_maps sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_vlog sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_vlog sed -i 's+/usr/local/share/icebox+/usr/share/icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_vlog sed -i 's+import icebox+import icebox as icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_stat sed -i 's+from icebox+from icebox+g' /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_stat make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebox' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp icepack /usr/src/tmp/icestorm-buildroot/usr/bin/icepack ln -sf icepack /usr/src/tmp/icestorm-buildroot/usr/bin/iceunpack make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepack' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp icemulti /usr/src/tmp/icestorm-buildroot/usr/bin/icemulti make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icemulti' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp icepll /usr/src/tmp/icestorm-buildroot/usr/bin/icepll make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icepll' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp icebram /usr/src/tmp/icestorm-buildroot/usr/bin/icebram make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icebram' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin mkdir -p /usr/src/tmp/icestorm-buildroot/usr/share/icebox cp icetime /usr/src/tmp/icestorm-buildroot/usr/bin/icetime cp ../icefuzz/timings_*.txt /usr/src/tmp/icestorm-buildroot/usr/share/icebox/ make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/icetime' make[1]: Entering directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' mkdir -p /usr/src/tmp/icestorm-buildroot/usr/bin cp iceprog /usr/src/tmp/icestorm-buildroot/usr/bin/iceprog make[1]: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861/iceprog' make: Leaving directory '/usr/src/RPM/BUILD/icestorm-0.0.0.777.gc495861' + mkdir -p /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages + mv /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages/ + ln -rs /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages/iceboxdb.py /usr/src/tmp/icestorm-buildroot/usr/bin/ + chmod a+x /usr/src/tmp/icestorm-buildroot/usr/bin/icebox.py + /usr/lib/rpm/brp-alt Cleaning files in /usr/src/tmp/icestorm-buildroot (auto) Verifying and fixing files in /usr/src/tmp/icestorm-buildroot (binconfig,pkgconfig,libtool,desktop,gnuconfig) Checking contents of files in /usr/src/tmp/icestorm-buildroot/ (default) Compressing files in /usr/src/tmp/icestorm-buildroot (auto) Adjusting library links in /usr/src/tmp/icestorm-buildroot ./usr/lib: (from :0) Verifying ELF objects in /usr/src/tmp/icestorm-buildroot (arch=normal,fhs=normal,lfs=relaxed,lint=relaxed,rpath=normal,stack=normal,textrel=normal,unresolved=normal) verify-elf: WARNING: ./usr/bin/iceprog: uses non-LFS functions: fopen tmpfile verify-elf: WARNING: ./usr/bin/icetime: uses non-LFS functions: fopen verify-elf: WARNING: ./usr/bin/icepll: uses non-LFS functions: fopen Bytecompiling python3 modules in /usr/src/tmp/icestorm-buildroot using /usr/bin/python3 compile /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages/iceboxdb.py Bytecompiling python3 modules with optimization in /usr/src/tmp/icestorm-buildroot using /usr/bin/python3 -O compile /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages/iceboxdb.py Bytecompiling python3 modules with optimization-2 in /usr/src/tmp/icestorm-buildroot using /usr/bin/python3 -OO compile /usr/src/tmp/icestorm-buildroot/usr/lib/python3/site-packages/iceboxdb.py Hardlinking identical .pyc and .opt-?.pyc files './usr/lib/python3/site-packages/__pycache__/iceboxdb.cpython-39.opt-1.pyc' => './usr/lib/python3/site-packages/__pycache__/iceboxdb.cpython-39.pyc' './usr/lib/python3/site-packages/__pycache__/iceboxdb.cpython-39.opt-2.pyc' => './usr/lib/python3/site-packages/__pycache__/iceboxdb.cpython-39.opt-1.pyc' Processing files: icestorm-0.0.0.777.gc495861-alt1 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.ZIi1Nx find-provides: running scripts (alternatives,debuginfo,lib,pam,perl,pkgconfig,python,python3,shell) python.prov.files: /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py: ASCII text (SKIP) python3.prov.files: /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py: ASCII text (SKIP) Finding Requires (using /usr/lib/rpm/find-requires) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.agbt2A find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks,systemd-services) python.req.files: /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py: ASCII text (SKIP) python3.req.files: /usr/src/tmp/icestorm-buildroot/usr/bin/iceboxdb.py: ASCII text (SKIP) /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The parser module is deprecated and will be removed in future versions of Python import parser, symbol, token, types /usr/lib/rpm/python3.req.py:6: DeprecationWarning: The symbol module is deprecated and will be removed in future versions of Python import parser, symbol, token, types python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox.py: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_asc2hlc: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_chipdb: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_colbuf: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_diff: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_explain: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_hlc2asc: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_html: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_maps: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_stat: skipping sys python3.req: /usr/src/tmp/icestorm-buildroot/usr/bin/icebox_vlog: skipping sys find-requires: FINDPACKAGE-COMMANDS: python3 Provides: python3(iceboxdb) Requires: /lib/ld-linux.so.2, /usr/bin/env, /usr/lib/python3/site-packages, libc.so.6(GLIBC_2.0), libc.so.6(GLIBC_2.1), libc.so.6(GLIBC_2.1.3), libc.so.6(GLIBC_2.3.4), libc.so.6(GLIBC_2.4), libc.so.6(GLIBC_2.7), libc.so.6(GLIBC_2.8), libftdi1.so.2 >= set:kg1x6Lx22DeGigb1uoeCEZjeWaddZFDyCKfeNok, libgcc_s.so.1(GCC_3.0), libm.so.6(GLIBC_2.29), libstdc++.so.6(CXXABI_1.3), libstdc++.so.6(CXXABI_1.3.9), libstdc++.so.6(GLIBCXX_3.4), libstdc++.so.6(GLIBCXX_3.4.11), libstdc++.so.6(GLIBCXX_3.4.14), libstdc++.so.6(GLIBCXX_3.4.20), libstdc++.so.6(GLIBCXX_3.4.21), libstdc++.so.6(GLIBCXX_3.4.9), python3, python3(functools) < 0, python3(getopt) < 0, python3(os) < 0, python3(re) < 0, rtld(GNU_HASH) Requires(rpmlib): rpmlib(SetVersions) Finding debuginfo files (using /usr/lib/rpm/find-debuginfo-files) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.vR6vTx Creating icestorm-debuginfo package Processing files: icestorm-chipdb-0.0.0.777.gc495861-alt1 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.x11q6B find-provides: running scripts (alternatives,debuginfo,lib,pam,perl,pkgconfig,python,python3,shell) Finding Requires (using /usr/lib/rpm/find-requires) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.Yk1gbC find-requires: running scripts (cpp,debuginfo,files,lib,pam,perl,pkgconfig,pkgconfiglib,python,python3,rpmlib,shebang,shell,static,symlinks,systemd-services) Processing files: icestorm-debuginfo-0.0.0.777.gc495861-alt1 Finding Provides (using /usr/lib/rpm/find-provides) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.zTsTGz find-provides: running scripts (debuginfo) Finding Requires (using /usr/lib/rpm/find-requires) Executing: /bin/sh -e /usr/src/tmp/rpm-tmp.ULQ4Py find-requires: running scripts (debuginfo) Requires: icestorm = 0.0.0.777.gc495861-alt1, /usr/lib/debug/lib/ld-linux.so.2.debug, debug(libc.so.6), debug(libftdi1.so.2), debug(libgcc_s.so.1), debug(libm.so.6), debug(libstdc++.so.6) Adding to icestorm-debuginfo a strict dependency on icestorm Wrote: /usr/src/RPM/RPMS/i586/icestorm-0.0.0.777.gc495861-alt1.i586.rpm (w2.lzdio) Wrote: /usr/src/RPM/RPMS/noarch/icestorm-chipdb-0.0.0.777.gc495861-alt1.noarch.rpm (w2T8.xzdio) Wrote: /usr/src/RPM/RPMS/i586/icestorm-debuginfo-0.0.0.777.gc495861-alt1.i586.rpm (w2.lzdio) 331.32user 3.62system 2:44.56elapsed 203%CPU (0avgtext+0avgdata 925360maxresident)k 0inputs+0outputs (0major+1548080minor)pagefaults 0swaps 338.31user 6.40system 2:55.43elapsed 196%CPU (0avgtext+0avgdata 925360maxresident)k 32inputs+0outputs (0major+1959851minor)pagefaults 0swaps --- icestorm-0.0.0.777.gc495861-alt1.i586.rpm.repo 2021-04-17 12:35:15.000000000 +0000 +++ icestorm-0.0.0.777.gc495861-alt1.i586.rpm.hasher 2021-07-19 13:33:09.085989612 +0000 @@ -66,8 +66,8 @@ File: /usr/bin/iceboxdb.py 120777 root:root ../lib/python3/site-packages/iceboxdb.py -File: /usr/bin/icebram 100755 root:root e893dd99c5554b1ec447fd9ecac45fdf -File: /usr/bin/icemulti 100755 root:root b744a182b9fbaf11fae1f46705942d59 -File: /usr/bin/icepack 100755 root:root 6196bd1e1b48992f5253a0cddb66f7a6 -File: /usr/bin/icepll 100755 root:root d7c987f16094a2a70cf4792989379775 -File: /usr/bin/iceprog 100755 root:root 471118bfeb7e212b3beaf9f2e04f0670 -File: /usr/bin/icetime 100755 root:root 0780439a2d04a060a069c8a1027dd43f +File: /usr/bin/icebram 100755 root:root c341fe9350eeafe5ce9d99c987e69318 +File: /usr/bin/icemulti 100755 root:root 0355f29304ba158913279f3320ffbfd3 +File: /usr/bin/icepack 100755 root:root a2a334b5c4e60dbbce3b663c9b6690b1 +File: /usr/bin/icepll 100755 root:root f77fe5485d30e086220bc94b782bd145 +File: /usr/bin/iceprog 100755 root:root 88af8587d2d8a2c68cd2a4f379f41604 +File: /usr/bin/icetime 100755 root:root 8a74add396673d6d5f57e86c7150a019 File: /usr/bin/iceunpack 120777 root:root icepack @@ -77,2 +77,2 @@ File: /usr/lib/python3/site-packages/iceboxdb.py 100644 root:root 4d7f133d51076d4e43b09e216503a785 -RPMIdentity: 11b00e0a38c12c0319928c7ea28b4add +RPMIdentity: 91667a92a0f2c72590ed6eb9569b969f --- icestorm-debuginfo-0.0.0.777.gc495861-alt1.i586.rpm.repo 2021-04-17 12:35:15.000000000 +0000 +++ icestorm-debuginfo-0.0.0.777.gc495861-alt1.i586.rpm.hasher 2021-07-19 13:33:09.267990209 +0000 @@ -1,18 +1,19 @@ -/usr/lib/debug/.build-id/03 40755 root:root -/usr/lib/debug/.build-id/03/b9189a4177214a1fa2a40141d84775f6fa0026 120777 root:root ../../../../bin/icepll -/usr/lib/debug/.build-id/03/b9189a4177214a1fa2a40141d84775f6fa0026.debug 120777 root:root ../../usr/bin/icepll.debug -/usr/lib/debug/.build-id/3e 40755 root:root -/usr/lib/debug/.build-id/3e/26e55adc0ce1032074dc2521c0aa30460829cd 120777 root:root ../../../../bin/icemulti -/usr/lib/debug/.build-id/3e/26e55adc0ce1032074dc2521c0aa30460829cd.debug 120777 root:root ../../usr/bin/icemulti.debug -/usr/lib/debug/.build-id/9c 40755 root:root -/usr/lib/debug/.build-id/9c/464eb4f628226c179f0e1f58dddd9369b99c23 120777 root:root ../../../../bin/icetime -/usr/lib/debug/.build-id/9c/464eb4f628226c179f0e1f58dddd9369b99c23.debug 120777 root:root ../../usr/bin/icetime.debug -/usr/lib/debug/.build-id/a4 40755 root:root -/usr/lib/debug/.build-id/a4/710e23cb5c1663880150e7b63fabea87a6e059 120777 root:root ../../../../bin/iceprog -/usr/lib/debug/.build-id/a4/710e23cb5c1663880150e7b63fabea87a6e059.debug 120777 root:root ../../usr/bin/iceprog.debug -/usr/lib/debug/.build-id/d4 40755 root:root -/usr/lib/debug/.build-id/d4/54d5f945ce5469608b4e7b436b9ac9fa66f37a 120777 root:root ../../../../bin/icebram -/usr/lib/debug/.build-id/d4/54d5f945ce5469608b4e7b436b9ac9fa66f37a.debug 120777 root:root ../../usr/bin/icebram.debug -/usr/lib/debug/.build-id/d4/b88f7684d7a2873333b1d24ea31b3c4ce7c313 120777 root:root ../../../../bin/icepack -/usr/lib/debug/.build-id/d4/b88f7684d7a2873333b1d24ea31b3c4ce7c313.debug 120777 root:root ../../usr/bin/icepack.debug +/usr/lib/debug/.build-id/04 40755 root:root +/usr/lib/debug/.build-id/04/c2ac38c2ff1b5e139ae75efec4ba1b752ebfda 120777 root:root ../../../../bin/iceprog +/usr/lib/debug/.build-id/04/c2ac38c2ff1b5e139ae75efec4ba1b752ebfda.debug 120777 root:root ../../usr/bin/iceprog.debug +/usr/lib/debug/.build-id/4d 40755 root:root +/usr/lib/debug/.build-id/4d/3f1ad1e96966ed3fc281f6ceaa80de0c845c2e 120777 root:root ../../../../bin/icepll +/usr/lib/debug/.build-id/4d/3f1ad1e96966ed3fc281f6ceaa80de0c845c2e.debug 120777 root:root ../../usr/bin/icepll.debug +/usr/lib/debug/.build-id/55 40755 root:root +/usr/lib/debug/.build-id/55/f6790625b13ef60f23a23d837b819ecea78321 120777 root:root ../../../../bin/icepack +/usr/lib/debug/.build-id/55/f6790625b13ef60f23a23d837b819ecea78321.debug 120777 root:root ../../usr/bin/icepack.debug +/usr/lib/debug/.build-id/81 40755 root:root +/usr/lib/debug/.build-id/81/a1f919465e79216038d76e9b4b9e49cc0ff549 120777 root:root ../../../../bin/icetime +/usr/lib/debug/.build-id/81/a1f919465e79216038d76e9b4b9e49cc0ff549.debug 120777 root:root ../../usr/bin/icetime.debug +/usr/lib/debug/.build-id/b8 40755 root:root +/usr/lib/debug/.build-id/b8/d58b27ef4cd83654b8bb7cb76253d7a9fccf68 120777 root:root ../../../../bin/icemulti +/usr/lib/debug/.build-id/b8/d58b27ef4cd83654b8bb7cb76253d7a9fccf68.debug 120777 root:root ../../usr/bin/icemulti.debug +/usr/lib/debug/.build-id/ee 40755 root:root +/usr/lib/debug/.build-id/ee/9c08372e4c6d0497695f70dac97865c9104ad4 120777 root:root ../../../../bin/icebram +/usr/lib/debug/.build-id/ee/9c08372e4c6d0497695f70dac97865c9104ad4.debug 120777 root:root ../../usr/bin/icebram.debug /usr/lib/debug/usr/bin/icebram.debug 100644 root:root @@ -56,25 +57,26 @@ Provides: icestorm-debuginfo = 0.0.0.777.gc495861-alt1:sisyphus+270165.100.1.1 -File: /usr/lib/debug/.build-id/03 40755 root:root -File: /usr/lib/debug/.build-id/03/b9189a4177214a1fa2a40141d84775f6fa0026 120777 root:root ../../../../bin/icepll -File: /usr/lib/debug/.build-id/03/b9189a4177214a1fa2a40141d84775f6fa0026.debug 120777 root:root ../../usr/bin/icepll.debug -File: /usr/lib/debug/.build-id/3e 40755 root:root -File: /usr/lib/debug/.build-id/3e/26e55adc0ce1032074dc2521c0aa30460829cd 120777 root:root ../../../../bin/icemulti -File: /usr/lib/debug/.build-id/3e/26e55adc0ce1032074dc2521c0aa30460829cd.debug 120777 root:root ../../usr/bin/icemulti.debug -File: /usr/lib/debug/.build-id/9c 40755 root:root -File: /usr/lib/debug/.build-id/9c/464eb4f628226c179f0e1f58dddd9369b99c23 120777 root:root ../../../../bin/icetime -File: /usr/lib/debug/.build-id/9c/464eb4f628226c179f0e1f58dddd9369b99c23.debug 120777 root:root ../../usr/bin/icetime.debug -File: /usr/lib/debug/.build-id/a4 40755 root:root -File: /usr/lib/debug/.build-id/a4/710e23cb5c1663880150e7b63fabea87a6e059 120777 root:root ../../../../bin/iceprog -File: /usr/lib/debug/.build-id/a4/710e23cb5c1663880150e7b63fabea87a6e059.debug 120777 root:root ../../usr/bin/iceprog.debug -File: /usr/lib/debug/.build-id/d4 40755 root:root -File: /usr/lib/debug/.build-id/d4/54d5f945ce5469608b4e7b436b9ac9fa66f37a 120777 root:root ../../../../bin/icebram -File: /usr/lib/debug/.build-id/d4/54d5f945ce5469608b4e7b436b9ac9fa66f37a.debug 120777 root:root ../../usr/bin/icebram.debug -File: /usr/lib/debug/.build-id/d4/b88f7684d7a2873333b1d24ea31b3c4ce7c313 120777 root:root ../../../../bin/icepack -File: /usr/lib/debug/.build-id/d4/b88f7684d7a2873333b1d24ea31b3c4ce7c313.debug 120777 root:root ../../usr/bin/icepack.debug -File: /usr/lib/debug/usr/bin/icebram.debug 100644 root:root 2e36e765979df643f33a591996d82312 -File: /usr/lib/debug/usr/bin/icemulti.debug 100644 root:root 2b25dbdc9a8c84900e3526fab0933c8c -File: /usr/lib/debug/usr/bin/icepack.debug 100644 root:root e0ee6d999ee6e973841de839e7ae7c0b -File: /usr/lib/debug/usr/bin/icepll.debug 100644 root:root 0abde6779fb9eba545810999ed684029 -File: /usr/lib/debug/usr/bin/iceprog.debug 100644 root:root 8c24f89384fbc46edc67d6e890f482fb -File: /usr/lib/debug/usr/bin/icetime.debug 100644 root:root 9c7e84f3ef24b4ada5cc5e64a7d3b9be +File: /usr/lib/debug/.build-id/04 40755 root:root +File: /usr/lib/debug/.build-id/04/c2ac38c2ff1b5e139ae75efec4ba1b752ebfda 120777 root:root ../../../../bin/iceprog +File: /usr/lib/debug/.build-id/04/c2ac38c2ff1b5e139ae75efec4ba1b752ebfda.debug 120777 root:root ../../usr/bin/iceprog.debug +File: /usr/lib/debug/.build-id/4d 40755 root:root +File: /usr/lib/debug/.build-id/4d/3f1ad1e96966ed3fc281f6ceaa80de0c845c2e 120777 root:root ../../../../bin/icepll +File: /usr/lib/debug/.build-id/4d/3f1ad1e96966ed3fc281f6ceaa80de0c845c2e.debug 120777 root:root ../../usr/bin/icepll.debug +File: /usr/lib/debug/.build-id/55 40755 root:root +File: /usr/lib/debug/.build-id/55/f6790625b13ef60f23a23d837b819ecea78321 120777 root:root ../../../../bin/icepack +File: /usr/lib/debug/.build-id/55/f6790625b13ef60f23a23d837b819ecea78321.debug 120777 root:root ../../usr/bin/icepack.debug +File: /usr/lib/debug/.build-id/81 40755 root:root +File: /usr/lib/debug/.build-id/81/a1f919465e79216038d76e9b4b9e49cc0ff549 120777 root:root ../../../../bin/icetime +File: /usr/lib/debug/.build-id/81/a1f919465e79216038d76e9b4b9e49cc0ff549.debug 120777 root:root ../../usr/bin/icetime.debug +File: /usr/lib/debug/.build-id/b8 40755 root:root +File: /usr/lib/debug/.build-id/b8/d58b27ef4cd83654b8bb7cb76253d7a9fccf68 120777 root:root ../../../../bin/icemulti +File: /usr/lib/debug/.build-id/b8/d58b27ef4cd83654b8bb7cb76253d7a9fccf68.debug 120777 root:root ../../usr/bin/icemulti.debug +File: /usr/lib/debug/.build-id/ee 40755 root:root +File: /usr/lib/debug/.build-id/ee/9c08372e4c6d0497695f70dac97865c9104ad4 120777 root:root ../../../../bin/icebram +File: /usr/lib/debug/.build-id/ee/9c08372e4c6d0497695f70dac97865c9104ad4.debug 120777 root:root ../../usr/bin/icebram.debug +File: /usr/lib/debug/usr/bin/icebram.debug 100644 root:root 0542c77e723c339d20195e615e3df737 +File: /usr/lib/debug/usr/bin/icemulti.debug 100644 root:root ef8559260826a0d932de645327adfd49 +File: /usr/lib/debug/usr/bin/icepack.debug 100644 root:root 105ac225abd2cffe7ed497acffb4772c +File: /usr/lib/debug/usr/bin/icepll.debug 100644 root:root 6f1ed5864e0289d6120057f3163202a6 +File: /usr/lib/debug/usr/bin/iceprog.debug 100644 root:root 10777ada3bdb5e4d0b40912a79180b24 +File: /usr/lib/debug/usr/bin/icetime.debug 100644 root:root 49005dc41bf56022f75058366f932a7c File: /usr/lib/debug/usr/bin/iceunpack.debug 120777 root:root icepack.debug @@ -103,2 +105,2 @@ File: /usr/src/debug/icestorm-0.0.0.777.gc495861/icetime/timings-up5k.cc 100644 root:root 684077bbcf959a35c787d23efaca3db0 -RPMIdentity: 6bcaf8f065ef67ee2f09bdd1d109f983 +RPMIdentity: bec0d8e19b5d3562878d1ef4a1a0bae7