Sun May 10 12:54:48 UTC 2020 I: starting to build fpga-icestorm/buster/i386 on jenkins on '2020-05-10 12:54' Sun May 10 12:54:48 UTC 2020 I: The jenkins build log is/was available at https://jenkins.debian.net/userContent/reproducible/debian/build_service/i386_14/8042/console.log Sun May 10 12:54:48 UTC 2020 I: Downloading source for buster/fpga-icestorm=0~20181109git9671b76-1 --2020-05-10 12:54:48-- http://deb.debian.org/debian/pool/main/f/fpga-icestorm/fpga-icestorm_0~20181109git9671b76-1.dsc Connecting to 78.137.99.97:3128... connected. Proxy request sent, awaiting response... 200 OK Length: 2404 (2.3K) Saving to: ‘fpga-icestorm_0~20181109git9671b76-1.dsc’ 0K .. 100% 15.6M=0s 2020-05-10 12:54:49 (15.6 MB/s) - ‘fpga-icestorm_0~20181109git9671b76-1.dsc’ saved [2404/2404] Sun May 10 12:54:49 UTC 2020 I: fpga-icestorm_0~20181109git9671b76-1.dsc -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Format: 3.0 (quilt) Source: fpga-icestorm Binary: fpga-icestorm-chipdb, fpga-icestorm Architecture: any all Version: 0~20181109git9671b76-1 Maintainer: Debian Electronics Team Uploaders: Ruben Undheim Homepage: http://www.clifford.at/icestorm/ Standards-Version: 4.2.1 Vcs-Browser: https://salsa.debian.org/electronics-team/fpga-icestorm Vcs-Git: https://salsa.debian.org/electronics-team/fpga-icestorm.git Testsuite: autopkgtest Build-Depends: debhelper (>= 11), libftdi-dev, python3, txt2man, pkg-config Package-List: fpga-icestorm deb electronics optional arch=any fpga-icestorm-chipdb deb electronics optional arch=all Checksums-Sha1: 30c33d8a08e6a4fe050dbee8bc639bc45c6925a7 421980 fpga-icestorm_0~20181109git9671b76.orig.tar.xz cf8340ae472d114f189823e277e428ddc6a09aa3 9280 fpga-icestorm_0~20181109git9671b76-1.debian.tar.xz Checksums-Sha256: b3bf5667d873a0ec3cd6ee950caf9394bc890357e2b9a4b453df2ee9c4cf0e49 421980 fpga-icestorm_0~20181109git9671b76.orig.tar.xz 571bd712cb64ea5becfd75f9d94bcbdfda04d249bd9e743f5f6f8bcbd023dfc4 9280 fpga-icestorm_0~20181109git9671b76-1.debian.tar.xz Files: 0389037d18b5a3a506e5b5dfc6767107 421980 fpga-icestorm_0~20181109git9671b76.orig.tar.xz c03ed6f52ec9a514070617da27d210a0 9280 fpga-icestorm_0~20181109git9671b76-1.debian.tar.xz Dgit: 90ffc6a593201e4f772252727b8cafce2a7cbff9 debian archive/debian/0_20181109git9671b76-1 https://git.dgit.debian.org/fpga-icestorm -----BEGIN PGP SIGNATURE----- iQJMBAEBCgA2FiEETeTfPeKePuppVOXOGnb1/BKWi3kFAlwbanoYHHJ1YmVuLnVu ZGhlaW1AZ21haWwuY29tAAoJEBp29fwSlot5b4UQAIwNGzrh4eRBoZke8RL0+O1G 7ob/nMLs/EDomwo/zivcbKVWR9NwNBGvK5Frah/Qsw/JI6dt3uHnZGlPwLbAB6vp LVbqDpYmXBloi4xMUP54HU+RS9WB8YFfKqlT+uWhQlHqK6ygug7PfDD4+u5gvgRJ 5EInK6f51HfAJZVSl7XnK4laO40Ch48ag60/4hYHxQ9JmoxN/cmGtgFABiVm/xia KqPRcWKZCdRBplF/GPExGoYQmcxNZmQnUZbewZLQ4ICVGaVMiuVa9uqtEWoRxIUw ENI0BiDG+7peQ74UXjlbC6QpsZiBEIuxwxGjmep01K1VZc+WJ4/VtWEeTVk/9zGs rihASlwR+3TuI1vVusFhCpuA7iXSvFni4zUslOA+TMGUlU8Sh7znAykVsKSjqmUi kYfBL69UUWBXIXxYzZreL+crZnXNNNWrs4rgGOyCcIPU899lxmYg6FCYddXL2MHP wzFNRcI0FzTWVvmjJZDfPwUeOPMUQQuWcgvRJY9KmRQ4rWzZHd8NOXs1wMWYehBY a6ulvyIsgY8DqmIBLvgzWgznFjgu96GjwFQtWsyHBrS8t91fFNfFOdGZH3nrpaXi Nevn/OO1PrE/X3vrt4o3OiZ62BvSyV8u0vKh+RbDQ0lcsK0aDCIxY6rCtUq5wodf UPHwzlNAzYC8VLJckZFZ =lkAC -----END PGP SIGNATURE----- Sun May 10 12:54:49 UTC 2020 I: Checking whether the package is not for us Sun May 10 12:54:49 UTC 2020 I: Starting 1st build on remote node profitbricks-build6-i386.debian.net. Sun May 10 12:54:49 UTC 2020 I: Preparing to do remote build '1' on profitbricks-build6-i386.debian.net. Sun May 10 12:57:17 UTC 2020 I: Deleting $TMPDIR on profitbricks-build6-i386.debian.net. I: pbuilder: network access will be disabled during build I: Current time: Sat Jun 12 07:17:50 -12 2021 I: pbuilder-time-stamp: 1623525470 I: Building the build Environment I: extracting base tarball [/var/cache/pbuilder/buster-reproducible-base.tgz] I: copying local configuration I: mounting /proc filesystem I: mounting /sys filesystem I: creating /{dev,run}/shm I: mounting /dev/pts filesystem I: redirecting /dev/ptmx to /dev/pts/ptmx I: policy-rc.d already exists I: using eatmydata during job I: Copying source file I: copying [fpga-icestorm_0~20181109git9671b76-1.dsc] I: copying [./fpga-icestorm_0~20181109git9671b76.orig.tar.xz] I: copying [./fpga-icestorm_0~20181109git9671b76-1.debian.tar.xz] I: Extracting source gpgv: unknown type of key resource 'trustedkeys.kbx' gpgv: keyblock resource '/root/.gnupg/trustedkeys.kbx': General error gpgv: Signature made Wed Dec 19 22:10:02 2018 -12 gpgv: using RSA key 4DE4DF3DE29E3EEA6954E5CE1A76F5FC12968B79 gpgv: issuer "ruben.undheim@gmail.com" gpgv: Can't check signature: No public key dpkg-source: warning: failed to verify signature on ./fpga-icestorm_0~20181109git9671b76-1.dsc dpkg-source: info: extracting fpga-icestorm in fpga-icestorm-0~20181109git9671b76 dpkg-source: info: unpacking fpga-icestorm_0~20181109git9671b76.orig.tar.xz dpkg-source: info: unpacking fpga-icestorm_0~20181109git9671b76-1.debian.tar.xz dpkg-source: info: using patch list from debian/patches/series dpkg-source: info: applying 0001-Install-the-python-programs-and-the-iceboxdb-module-.patch dpkg-source: info: applying 0002-Fix-MD-and-O0-passed-as-CFLAGS-and-CXXFLAGS.patch dpkg-source: info: applying 0003-Install-timing-data-also-in-fpga-icestorm-chipdb.patch I: using fakeroot in build. I: Installing the build-deps -> Attempting to satisfy build-dependencies -> Creating pbuilder-satisfydepends-dummy package Package: pbuilder-satisfydepends-dummy Version: 0.invalid.0 Architecture: i386 Maintainer: Debian Pbuilder Team Description: Dummy package to satisfy dependencies with aptitude - created by pbuilder This package was created automatically by pbuilder to satisfy the build-dependencies of the package being currently built. Depends: debhelper (>= 11), libftdi-dev, python3, txt2man, pkg-config dpkg-deb: building package 'pbuilder-satisfydepends-dummy' in '/tmp/satisfydepends-aptitude/pbuilder-satisfydepends-dummy.deb'. Selecting previously unselected package pbuilder-satisfydepends-dummy. (Reading database ... 19234 files and directories currently installed.) Preparing to unpack .../pbuilder-satisfydepends-dummy.deb ... Unpacking pbuilder-satisfydepends-dummy (0.invalid.0) ... dpkg: pbuilder-satisfydepends-dummy: dependency problems, but configuring anyway as you requested: pbuilder-satisfydepends-dummy depends on debhelper (>= 11); however: Package debhelper is not installed. pbuilder-satisfydepends-dummy depends on libftdi-dev; however: Package libftdi-dev is not installed. pbuilder-satisfydepends-dummy depends on python3; however: Package python3 is not installed. pbuilder-satisfydepends-dummy depends on txt2man; however: Package txt2man is not installed. pbuilder-satisfydepends-dummy depends on pkg-config; however: Package pkg-config is not installed. Setting up pbuilder-satisfydepends-dummy (0.invalid.0) ... Reading package lists... Building dependency tree... Reading state information... Initializing package states... Writing extended state information... Building tag database... pbuilder-satisfydepends-dummy is already installed at the requested version (0.invalid.0) pbuilder-satisfydepends-dummy is already installed at the requested version (0.invalid.0) The following NEW packages will be installed: autoconf{a} automake{a} autopoint{a} autotools-dev{a} bsdmainutils{a} debhelper{a} dh-autoreconf{a} dh-strip-nondeterminism{a} dwz{a} file{a} gawk{a} gettext{a} gettext-base{a} groff-base{a} intltool-debian{a} libarchive-zip-perl{a} libbsd0{a} libcroco3{a} libelf1{a} libexpat1{a} libfile-stripnondeterminism-perl{a} libftdi-dev{a} libftdi1{a} libglib2.0-0{a} libicu63{a} libmagic-mgc{a} libmagic1{a} libmpdec2{a} libncurses6{a} libpipeline1{a} libpython3-stdlib{a} libpython3.7-minimal{a} libpython3.7-stdlib{a} libreadline7{a} libsigsegv2{a} libssl1.1{a} libtool{a} libuchardet0{a} libusb-0.1-4{a} libusb-dev{a} libxml2{a} m4{a} man-db{a} mime-support{a} pkg-config{a} po-debconf{a} python3{a} python3-minimal{a} python3.7{a} python3.7-minimal{a} readline-common{a} sensible-utils{a} txt2man{a} The following packages are RECOMMENDED but will NOT be installed: curl libarchive-cpio-perl libglib2.0-data libgpm2 libltdl-dev libmail-sendmail-perl lynx shared-mime-info wget xdg-user-dirs 0 packages upgraded, 53 newly installed, 0 to remove and 0 not upgraded. Need to get 26.9 MB of archives. After unpacking 104 MB will be used. Writing extended state information... Get: 1 http://deb.debian.org/debian buster/main i386 libbsd0 i386 0.9.1-2 [104 kB] Get: 2 http://deb.debian.org/debian buster/main i386 bsdmainutils i386 11.1.2+b1 [193 kB] Get: 3 http://deb.debian.org/debian buster/main i386 libuchardet0 i386 0.0.6-3 [65.2 kB] Get: 4 http://deb.debian.org/debian buster/main i386 groff-base i386 1.22.4-3 [935 kB] Get: 5 http://deb.debian.org/debian buster/main i386 libpipeline1 i386 1.5.1-2 [33.3 kB] Get: 6 http://deb.debian.org/debian buster/main i386 man-db i386 2.8.5-2 [1284 kB] Get: 7 http://deb.debian.org/debian buster/main i386 readline-common all 7.0-5 [70.6 kB] Get: 8 http://deb.debian.org/debian buster/main i386 libreadline7 i386 7.0-5 [156 kB] Get: 9 http://deb.debian.org/debian buster/main i386 libsigsegv2 i386 2.12-2 [33.2 kB] Get: 10 http://deb.debian.org/debian buster/main i386 gawk i386 1:4.2.1+dfsg-1 [668 kB] Get: 11 http://deb.debian.org/debian buster/main i386 libssl1.1 i386 1.1.1d-0+deb10u3 [1537 kB] Get: 12 http://deb.debian.org/debian buster/main i386 libpython3.7-minimal i386 3.7.3-2+deb10u1 [590 kB] Get: 13 http://deb.debian.org/debian buster/main i386 libexpat1 i386 2.2.6-2+deb10u1 [104 kB] Get: 14 http://deb.debian.org/debian buster/main i386 python3.7-minimal i386 3.7.3-2+deb10u1 [1745 kB] Get: 15 http://deb.debian.org/debian buster/main i386 python3-minimal i386 3.7.3-1 [36.6 kB] Get: 16 http://deb.debian.org/debian buster/main i386 mime-support all 3.62 [37.2 kB] Get: 17 http://deb.debian.org/debian buster/main i386 libmpdec2 i386 2.4.2-2 [83.2 kB] Get: 18 http://deb.debian.org/debian buster/main i386 libpython3.7-stdlib i386 3.7.3-2+deb10u1 [1750 kB] Get: 19 http://deb.debian.org/debian buster/main i386 python3.7 i386 3.7.3-2+deb10u1 [330 kB] Get: 20 http://deb.debian.org/debian buster/main i386 libpython3-stdlib i386 3.7.3-1 [20.0 kB] Get: 21 http://deb.debian.org/debian buster/main i386 python3 i386 3.7.3-1 [61.5 kB] Get: 22 http://deb.debian.org/debian buster/main i386 sensible-utils all 0.0.12 [15.8 kB] Get: 23 http://deb.debian.org/debian buster/main i386 libmagic-mgc i386 1:5.35-4+deb10u1 [242 kB] Get: 24 http://deb.debian.org/debian buster/main i386 libmagic1 i386 1:5.35-4+deb10u1 [124 kB] Get: 25 http://deb.debian.org/debian buster/main i386 file i386 1:5.35-4+deb10u1 [66.3 kB] Get: 26 http://deb.debian.org/debian buster/main i386 gettext-base i386 0.19.8.1-9 [124 kB] Get: 27 http://deb.debian.org/debian buster/main i386 m4 i386 1.4.18-2 [205 kB] Get: 28 http://deb.debian.org/debian buster/main i386 autoconf all 2.69-11 [341 kB] Get: 29 http://deb.debian.org/debian buster/main i386 autotools-dev all 20180224.1 [77.0 kB] Get: 30 http://deb.debian.org/debian buster/main i386 automake all 1:1.16.1-4 [771 kB] Get: 31 http://deb.debian.org/debian buster/main i386 autopoint all 0.19.8.1-9 [434 kB] Get: 32 http://deb.debian.org/debian buster/main i386 libtool all 2.4.6-9 [547 kB] Get: 33 http://deb.debian.org/debian buster/main i386 dh-autoreconf all 19 [16.9 kB] Get: 34 http://deb.debian.org/debian buster/main i386 libarchive-zip-perl all 1.64-1 [96.8 kB] Get: 35 http://deb.debian.org/debian buster/main i386 libfile-stripnondeterminism-perl all 1.1.2-1 [19.8 kB] Get: 36 http://deb.debian.org/debian buster/main i386 dh-strip-nondeterminism all 1.1.2-1 [13.0 kB] Get: 37 http://deb.debian.org/debian buster/main i386 libelf1 i386 0.176-1.1 [166 kB] Get: 38 http://deb.debian.org/debian buster/main i386 dwz i386 0.12-3 [81.4 kB] Get: 39 http://deb.debian.org/debian buster/main i386 libglib2.0-0 i386 2.58.3-2+deb10u2 [1334 kB] Get: 40 http://deb.debian.org/debian buster/main i386 libicu63 i386 63.1-6+deb10u1 [8451 kB] Get: 41 http://deb.debian.org/debian buster/main i386 libxml2 i386 2.9.4+dfsg1-7+b3 [721 kB] Get: 42 http://deb.debian.org/debian buster/main i386 libcroco3 i386 0.6.12-3 [151 kB] Get: 43 http://deb.debian.org/debian buster/main i386 libncurses6 i386 6.1+20181013-2+deb10u2 [109 kB] Get: 44 http://deb.debian.org/debian buster/main i386 gettext i386 0.19.8.1-9 [1314 kB] Get: 45 http://deb.debian.org/debian buster/main i386 intltool-debian all 0.35.0+20060710.5 [26.8 kB] Get: 46 http://deb.debian.org/debian buster/main i386 po-debconf all 1.0.21 [248 kB] Get: 47 http://deb.debian.org/debian buster/main i386 debhelper all 12.1.1 [1016 kB] Get: 48 http://deb.debian.org/debian buster/main i386 libusb-0.1-4 i386 2:0.1.12-32 [24.0 kB] Get: 49 http://deb.debian.org/debian buster/main i386 libftdi1 i386 0.20-4 [19.5 kB] Get: 50 http://deb.debian.org/debian buster/main i386 libusb-dev i386 2:0.1.12-32 [39.1 kB] Get: 51 http://deb.debian.org/debian buster/main i386 libftdi-dev i386 0.20-4 [174 kB] Get: 52 http://deb.debian.org/debian buster/main i386 pkg-config i386 0.29-6 [64.7 kB] Get: 53 http://deb.debian.org/debian buster/main i386 txt2man all 1.6.0-5 [29.7 kB] Fetched 26.9 MB in 0s (78.2 MB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libbsd0:i386. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 19234 files and directories currently installed.) Preparing to unpack .../0-libbsd0_0.9.1-2_i386.deb ... Unpacking libbsd0:i386 (0.9.1-2) ... Selecting previously unselected package bsdmainutils. Preparing to unpack .../1-bsdmainutils_11.1.2+b1_i386.deb ... Unpacking bsdmainutils (11.1.2+b1) ... Selecting previously unselected package libuchardet0:i386. Preparing to unpack .../2-libuchardet0_0.0.6-3_i386.deb ... Unpacking libuchardet0:i386 (0.0.6-3) ... Selecting previously unselected package groff-base. Preparing to unpack .../3-groff-base_1.22.4-3_i386.deb ... Unpacking groff-base (1.22.4-3) ... Selecting previously unselected package libpipeline1:i386. Preparing to unpack .../4-libpipeline1_1.5.1-2_i386.deb ... Unpacking libpipeline1:i386 (1.5.1-2) ... Selecting previously unselected package man-db. Preparing to unpack .../5-man-db_2.8.5-2_i386.deb ... Unpacking man-db (2.8.5-2) ... Selecting previously unselected package readline-common. Preparing to unpack .../6-readline-common_7.0-5_all.deb ... Unpacking readline-common (7.0-5) ... Selecting previously unselected package libreadline7:i386. Preparing to unpack .../7-libreadline7_7.0-5_i386.deb ... Unpacking libreadline7:i386 (7.0-5) ... Selecting previously unselected package libsigsegv2:i386. Preparing to unpack .../8-libsigsegv2_2.12-2_i386.deb ... Unpacking libsigsegv2:i386 (2.12-2) ... Setting up readline-common (7.0-5) ... Setting up libreadline7:i386 (7.0-5) ... Setting up libsigsegv2:i386 (2.12-2) ... Selecting previously unselected package gawk. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 19901 files and directories currently installed.) Preparing to unpack .../gawk_1%3a4.2.1+dfsg-1_i386.deb ... Unpacking gawk (1:4.2.1+dfsg-1) ... Selecting previously unselected package libssl1.1:i386. Preparing to unpack .../libssl1.1_1.1.1d-0+deb10u3_i386.deb ... Unpacking libssl1.1:i386 (1.1.1d-0+deb10u3) ... Selecting previously unselected package libpython3.7-minimal:i386. Preparing to unpack .../libpython3.7-minimal_3.7.3-2+deb10u1_i386.deb ... Unpacking libpython3.7-minimal:i386 (3.7.3-2+deb10u1) ... Selecting previously unselected package libexpat1:i386. Preparing to unpack .../libexpat1_2.2.6-2+deb10u1_i386.deb ... Unpacking libexpat1:i386 (2.2.6-2+deb10u1) ... Selecting previously unselected package python3.7-minimal. Preparing to unpack .../python3.7-minimal_3.7.3-2+deb10u1_i386.deb ... Unpacking python3.7-minimal (3.7.3-2+deb10u1) ... Setting up libssl1.1:i386 (1.1.1d-0+deb10u3) ... Setting up libpython3.7-minimal:i386 (3.7.3-2+deb10u1) ... Setting up libexpat1:i386 (2.2.6-2+deb10u1) ... Setting up python3.7-minimal (3.7.3-2+deb10u1) ... Selecting previously unselected package python3-minimal. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 20331 files and directories currently installed.) Preparing to unpack .../0-python3-minimal_3.7.3-1_i386.deb ... Unpacking python3-minimal (3.7.3-1) ... Selecting previously unselected package mime-support. Preparing to unpack .../1-mime-support_3.62_all.deb ... Unpacking mime-support (3.62) ... Selecting previously unselected package libmpdec2:i386. Preparing to unpack .../2-libmpdec2_2.4.2-2_i386.deb ... Unpacking libmpdec2:i386 (2.4.2-2) ... Selecting previously unselected package libpython3.7-stdlib:i386. Preparing to unpack .../3-libpython3.7-stdlib_3.7.3-2+deb10u1_i386.deb ... Unpacking libpython3.7-stdlib:i386 (3.7.3-2+deb10u1) ... Selecting previously unselected package python3.7. Preparing to unpack .../4-python3.7_3.7.3-2+deb10u1_i386.deb ... Unpacking python3.7 (3.7.3-2+deb10u1) ... Selecting previously unselected package libpython3-stdlib:i386. Preparing to unpack .../5-libpython3-stdlib_3.7.3-1_i386.deb ... Unpacking libpython3-stdlib:i386 (3.7.3-1) ... Setting up python3-minimal (3.7.3-1) ... Selecting previously unselected package python3. (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 20768 files and directories currently installed.) Preparing to unpack .../00-python3_3.7.3-1_i386.deb ... Unpacking python3 (3.7.3-1) ... Selecting previously unselected package sensible-utils. Preparing to unpack .../01-sensible-utils_0.0.12_all.deb ... Unpacking sensible-utils (0.0.12) ... Selecting previously unselected package libmagic-mgc. Preparing to unpack .../02-libmagic-mgc_1%3a5.35-4+deb10u1_i386.deb ... Unpacking libmagic-mgc (1:5.35-4+deb10u1) ... Selecting previously unselected package libmagic1:i386. Preparing to unpack .../03-libmagic1_1%3a5.35-4+deb10u1_i386.deb ... Unpacking libmagic1:i386 (1:5.35-4+deb10u1) ... Selecting previously unselected package file. Preparing to unpack .../04-file_1%3a5.35-4+deb10u1_i386.deb ... Unpacking file (1:5.35-4+deb10u1) ... Selecting previously unselected package gettext-base. Preparing to unpack .../05-gettext-base_0.19.8.1-9_i386.deb ... Unpacking gettext-base (0.19.8.1-9) ... Selecting previously unselected package m4. Preparing to unpack .../06-m4_1.4.18-2_i386.deb ... Unpacking m4 (1.4.18-2) ... Selecting previously unselected package autoconf. Preparing to unpack .../07-autoconf_2.69-11_all.deb ... Unpacking autoconf (2.69-11) ... Selecting previously unselected package autotools-dev. Preparing to unpack .../08-autotools-dev_20180224.1_all.deb ... Unpacking autotools-dev (20180224.1) ... Selecting previously unselected package automake. Preparing to unpack .../09-automake_1%3a1.16.1-4_all.deb ... Unpacking automake (1:1.16.1-4) ... Selecting previously unselected package autopoint. Preparing to unpack .../10-autopoint_0.19.8.1-9_all.deb ... Unpacking autopoint (0.19.8.1-9) ... Selecting previously unselected package libtool. Preparing to unpack .../11-libtool_2.4.6-9_all.deb ... Unpacking libtool (2.4.6-9) ... Selecting previously unselected package dh-autoreconf. Preparing to unpack .../12-dh-autoreconf_19_all.deb ... Unpacking dh-autoreconf (19) ... Selecting previously unselected package libarchive-zip-perl. Preparing to unpack .../13-libarchive-zip-perl_1.64-1_all.deb ... Unpacking libarchive-zip-perl (1.64-1) ... Selecting previously unselected package libfile-stripnondeterminism-perl. Preparing to unpack .../14-libfile-stripnondeterminism-perl_1.1.2-1_all.deb ... Unpacking libfile-stripnondeterminism-perl (1.1.2-1) ... Selecting previously unselected package dh-strip-nondeterminism. Preparing to unpack .../15-dh-strip-nondeterminism_1.1.2-1_all.deb ... Unpacking dh-strip-nondeterminism (1.1.2-1) ... Selecting previously unselected package libelf1:i386. Preparing to unpack .../16-libelf1_0.176-1.1_i386.deb ... Unpacking libelf1:i386 (0.176-1.1) ... Selecting previously unselected package dwz. Preparing to unpack .../17-dwz_0.12-3_i386.deb ... Unpacking dwz (0.12-3) ... Selecting previously unselected package libglib2.0-0:i386. Preparing to unpack .../18-libglib2.0-0_2.58.3-2+deb10u2_i386.deb ... Unpacking libglib2.0-0:i386 (2.58.3-2+deb10u2) ... Selecting previously unselected package libicu63:i386. Preparing to unpack .../19-libicu63_63.1-6+deb10u1_i386.deb ... Unpacking libicu63:i386 (63.1-6+deb10u1) ... Selecting previously unselected package libxml2:i386. Preparing to unpack .../20-libxml2_2.9.4+dfsg1-7+b3_i386.deb ... Unpacking libxml2:i386 (2.9.4+dfsg1-7+b3) ... Selecting previously unselected package libcroco3:i386. Preparing to unpack .../21-libcroco3_0.6.12-3_i386.deb ... Unpacking libcroco3:i386 (0.6.12-3) ... Selecting previously unselected package libncurses6:i386. Preparing to unpack .../22-libncurses6_6.1+20181013-2+deb10u2_i386.deb ... Unpacking libncurses6:i386 (6.1+20181013-2+deb10u2) ... Selecting previously unselected package gettext. Preparing to unpack .../23-gettext_0.19.8.1-9_i386.deb ... Unpacking gettext (0.19.8.1-9) ... Selecting previously unselected package intltool-debian. Preparing to unpack .../24-intltool-debian_0.35.0+20060710.5_all.deb ... Unpacking intltool-debian (0.35.0+20060710.5) ... Selecting previously unselected package po-debconf. Preparing to unpack .../25-po-debconf_1.0.21_all.deb ... Unpacking po-debconf (1.0.21) ... Selecting previously unselected package debhelper. Preparing to unpack .../26-debhelper_12.1.1_all.deb ... Unpacking debhelper (12.1.1) ... Selecting previously unselected package libusb-0.1-4:i386. Preparing to unpack .../27-libusb-0.1-4_2%3a0.1.12-32_i386.deb ... Unpacking libusb-0.1-4:i386 (2:0.1.12-32) ... Selecting previously unselected package libftdi1:i386. Preparing to unpack .../28-libftdi1_0.20-4_i386.deb ... Unpacking libftdi1:i386 (0.20-4) ... Selecting previously unselected package libusb-dev. Preparing to unpack .../29-libusb-dev_2%3a0.1.12-32_i386.deb ... Unpacking libusb-dev (2:0.1.12-32) ... Selecting previously unselected package libftdi-dev. Preparing to unpack .../30-libftdi-dev_0.20-4_i386.deb ... Unpacking libftdi-dev (0.20-4) ... Selecting previously unselected package pkg-config. Preparing to unpack .../31-pkg-config_0.29-6_i386.deb ... Unpacking pkg-config (0.29-6) ... Selecting previously unselected package txt2man. Preparing to unpack .../32-txt2man_1.6.0-5_all.deb ... Unpacking txt2man (1.6.0-5) ... Setting up libpipeline1:i386 (1.5.1-2) ... Setting up mime-support (3.62) ... Setting up libmagic-mgc (1:5.35-4+deb10u1) ... Setting up gawk (1:4.2.1+dfsg-1) ... Setting up libarchive-zip-perl (1.64-1) ... Setting up libglib2.0-0:i386 (2.58.3-2+deb10u2) ... No schema files found: doing nothing. Setting up libmagic1:i386 (1:5.35-4+deb10u1) ... Setting up gettext-base (0.19.8.1-9) ... Setting up m4 (1.4.18-2) ... Setting up file (1:5.35-4+deb10u1) ... Setting up libicu63:i386 (63.1-6+deb10u1) ... Setting up libusb-0.1-4:i386 (2:0.1.12-32) ... Setting up autotools-dev (20180224.1) ... Setting up libncurses6:i386 (6.1+20181013-2+deb10u2) ... Setting up autopoint (0.19.8.1-9) ... Setting up pkg-config (0.29-6) ... Setting up autoconf (2.69-11) ... Setting up sensible-utils (0.0.12) ... Setting up libuchardet0:i386 (0.0.6-3) ... Setting up libmpdec2:i386 (2.4.2-2) ... Setting up libbsd0:i386 (0.9.1-2) ... Setting up libelf1:i386 (0.176-1.1) ... Setting up libxml2:i386 (2.9.4+dfsg1-7+b3) ... Setting up automake (1:1.16.1-4) ... update-alternatives: using /usr/bin/automake-1.16 to provide /usr/bin/automake (automake) in auto mode Setting up libfile-stripnondeterminism-perl (1.1.2-1) ... Setting up libpython3.7-stdlib:i386 (3.7.3-2+deb10u1) ... Setting up txt2man (1.6.0-5) ... Setting up libtool (2.4.6-9) ... Setting up libftdi1:i386 (0.20-4) ... Setting up libusb-dev (2:0.1.12-32) ... Setting up bsdmainutils (11.1.2+b1) ... update-alternatives: using /usr/bin/bsd-write to provide /usr/bin/write (write) in auto mode update-alternatives: using /usr/bin/bsd-from to provide /usr/bin/from (from) in auto mode Setting up libcroco3:i386 (0.6.12-3) ... Setting up dwz (0.12-3) ... Setting up groff-base (1.22.4-3) ... Setting up libpython3-stdlib:i386 (3.7.3-1) ... Setting up python3.7 (3.7.3-2+deb10u1) ... Setting up gettext (0.19.8.1-9) ... Setting up libftdi-dev (0.20-4) ... Setting up python3 (3.7.3-1) ... Setting up man-db (2.8.5-2) ... Not building database; man-db/auto-update is not 'true'. Setting up intltool-debian (0.35.0+20060710.5) ... Setting up po-debconf (1.0.21) ... Setting up debhelper (12.1.1) ... Setting up dh-autoreconf (19) ... Setting up dh-strip-nondeterminism (1.1.2-1) ... Processing triggers for libc-bin (2.28-10) ... Reading package lists... Building dependency tree... Reading state information... Reading extended state information... Initializing package states... Writing extended state information... Building tag database... -> Finished parsing the build-deps Reading package lists... Building dependency tree... Reading state information... fakeroot is already the newest version (1.23-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. I: Building the package I: Running cd /build/fpga-icestorm-0~20181109git9671b76/ && env PATH="/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" HOME="/nonexistent/first-build" dpkg-buildpackage -us -uc -b dpkg-buildpackage: info: source package fpga-icestorm dpkg-buildpackage: info: source version 0~20181109git9671b76-1 dpkg-buildpackage: info: source distribution unstable dpkg-buildpackage: info: source changed by Ruben Undheim dpkg-source --before-build . dpkg-buildpackage: info: host architecture i386 fakeroot debian/rules clean dh clean debian/rules override_dh_auto_clean make[1]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' dh_auto_clean make -j18 clean make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' for dir in icebox icepack iceprog icemulti icepll icetime icebram; do \ make -C $dir clean || exit; \ done make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' rm -f chipdb-1k.txt chipdb-8k.txt chipdb-384.txt chipdb-5k.txt chipdb-lm4k.txt rm -f icebox.pyc iceboxdb.pyc make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' rm -f icepack rm -f iceunpack rm -f icepack.exe rm -f *.o *.d make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' rm -f iceprog rm -f iceprog.exe rm -f *.o *.d make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' rm -f icemulti rm -f icemulti.exe rm -f *.o *.d make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' rm -f icepll rm -f icepll.exe rm -f *.o *.d make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' rm -f icetime icetime.exe timings.inc *.o *.d rm -rf test[0-9]* make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' rm -f icebram rm -f icebram.exe rm -f demo.* demo_*.* rm -f *.o *.d make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' rm -f debian/man/*.1 rm -f -r icebox/__pycache__ make[1]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' dh_clean debian/rules build dh build dh_update_autotools_config dh_autoreconf dh_auto_configure dh_auto_build make -j18 "INSTALL=install --strip-program=true" make[1]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' make -C icebox all make -C icepack all make -C iceprog all make -C icemulti all make -C icepll all make -C icetime all make -C icebram all make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' python3 icebox_chipdb.py -3 > chipdb-384.new make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o icepack.o icepack.cc make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o icemulti.o icemulti.cc python3 icebox_chipdb.py > chipdb-1k.new make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o icepll.o icepll.cc python3 icebox_chipdb.py -8 > chipdb-8k.new python3 icebox_chipdb.py -5 > chipdb-5k.new python3 icebox_chipdb.py -4 > chipdb-lm4k.new make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o icebram.o icebram.cc make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' python3 timings.py > timings.inc.new g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -Wdate-time -D_FORTIFY_SOURCE=2 -c -o iceutil.o iceutil.cc cc -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c99 -I/usr/local/include -O2 -Wall -std=c99 -I/usr/local/include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o iceprog.o iceprog.c mv timings.inc.new timings.inc g++ -g -O2 -ffile-prefix-map=/build/fpga-icestorm-0~20181109git9671b76=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -std=c++11 -I/usr/local/include -O2 -Wall -std=c++11 -I/usr/local/include -DPREFIX='"/usr/local"' -DCHIPDB_SUBDIR='"icebox"' -Wdate-time -D_FORTIFY_SOURCE=2 -c -o icetime.o icetime.cc g++ -o icepll -Wl,-z,relro -Wl,-z,now -Wl,--as-needed icepll.o -lm -lstdc++ make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' cc -o iceprog -Wl,-z,relro -Wl,-z,now -Wl,--as-needed iceprog.o -L/usr/local/lib -lm -lftdi make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' 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=] #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ string vstringf(const char *fmt, va_list ap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ char *str = NULL; ~~~~~~~~~~~~~~~~~ #ifdef _WIN32 ~~~~~~~~~~~~~ int sz = 64, rc; ~~~~~~~~~~~~~~~~ while (1) { ~~~~~~~~~~~ va_list apc; ~~~~~~~~~~~~ va_copy(apc, ap); ~~~~~~~~~~~~~~~~~ str = (char*)realloc(str, sz); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rc = vsnprintf(str, sz, fmt, apc); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(apc); ~~~~~~~~~~~~ if (rc >= 0 && rc < sz) ~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ sz *= 2; ~~~~~~~~ } ~ #else ~~~~~ if (vasprintf(&str, fmt, ap) < 0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ str = NULL; ~~~~~~~~~~~ #endif ~~~~~~ if (str != NULL) { ~~~~~~~~~~~~~~~~~~ string = str; ~~~~~~~~~~~~~ free(str); ~~~~~~~~~~ } ~ return string; ~~~~~~~~~~~~~~ } ~ string stringf(const char *fmt, ...) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ va_list ap; ~~~~~~~~~~~ va_start(ap, fmt); ~~~~~~~~~~~~~~~~~~ string = vstringf(fmt, ap); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(ap); ~~~~~~~~~~~ return string; ~~~~~~~~~~~~~~ } ~ // ================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // FpgaConfig stuff ~~~~~~~~~~~~~~~~~~~ struct FpgaConfig ~~~~~~~~~~~~~~~~~ { ~ string device; ~~~~~~~~~~~~~~ string freqrange; ~~~~~~~~~~~~~~~~~ string nosleep; ~~~~~~~~~~~~~~~ string warmboot; ~~~~~~~~~~~~~~~~ // cram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int cram_width, cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> cram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // bram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int bram_width, bram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> bram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // data before preamble ~~~~~~~~~~~~~~~~~~~~~~~ vector initblop; ~~~~~~~~~~~~~~~~~~~~~~~~~ // bitstream i/o ~~~~~~~~~~~~~~~~ void read_bits(std::istream &ifs); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bits(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // icebox i/o ~~~~~~~~~~~~~ void read_ascii(std::istream &ifs, bool nosleep); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_ascii(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // netpbm i/o ~~~~~~~~~~~~~ void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query chip type metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~ int chip_width() const; ~~~~~~~~~~~~~~~~~~~~~~~ int chip_height() const; ~~~~~~~~~~~~~~~~~~~~~~~~ vector chip_cols() const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query tile metadata ~~~~~~~~~~~~~~~~~~~~~~ string tile_type(int x, int y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_width(const string &type) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // cram bit manipulation ~~~~~~~~~~~~~~~~~~~~~~~~ void cram_clear(); ~~~~~~~~~~~~~~~~~~ void cram_fill_tiles(); ~~~~~~~~~~~~~~~~~~~~~~~ void cram_checkerboard(int m = 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct CramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ string tile_type; ~~~~~~~~~~~~~~~~~ int tile_width; ~~~~~~~~~~~~~~~ int column_width; ~~~~~~~~~~~~~~~~~ bool left_right_io; ~~~~~~~~~~~~~~~~~~~ bool right_half; ~~~~~~~~~~~~~~~~ bool top_half; ~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_tx; ~~~~~~~~~~~~ int bank_ty; ~~~~~~~~~~~~ int bank_xoff; ~~~~~~~~~~~~~~ int bank_yoff; ~~~~~~~~~~~~~~ CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct BramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_off; ~~~~~~~~~~~~~ BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ static void update_crc16(uint16_t &crc, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 7; i >= 0; i--) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc = (crc << 1) ^ xor_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int byte = ifs.get(); ~~~~~~~~~~~~~~~~~~~~~ if (byte < 0) ~~~~~~~~~~~~~ error("Unexpected end of file.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return byte; ~~~~~~~~~~~~ } ~ static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ ofs << byte; ~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_bits(std::istream &ifs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // skip initial comments until preamble is found ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t preamble = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (1) ~~~~~~~~~ { ~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ preamble = (preamble << 8) | byte; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0xffffffff) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("No preamble found in bitstream.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0x7EAA997E) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Found preamble at offset %d.\n", file_offset-4); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ initblop.push_back(byte); ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ // main parser loop ~~~~~~~~~~~~~~~~~~~ int current_bank = 0; ~~~~~~~~~~~~~~~~~~~~~ int current_width = 0; ~~~~~~~~~~~~~~~~~~~~~~ int current_height = 0; ~~~~~~~~~~~~~~~~~~~~~~~ int current_offset = 0; ~~~~~~~~~~~~~~~~~~~~~~~ bool wakeup = false; ~~~~~~~~~~~~~~~~~~~~ this->cram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (!wakeup) ~~~~~~~~~~~~~~~ { ~ // one command byte. the lower 4 bits of the command byte specify ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // the length of the command payload. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t command = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t payload = 0; ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (command & 0x0f); i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command, 2*(command & 0x0f), payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t end_token; ~~~~~~~~~~~~~~~~~~~ switch (command & 0xf0) ~~~~~~~~~~~~~~~~~~~~~~~ { ~ case 0x00: ~~~~~~~~~~ switch (payload) ~~~~~~~~~~~~~~~~ { ~ case 0x01: ~~~~~~~~~~ info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = std::max(this->cram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = std::max(this->cram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x03: ~~~~~~~~~~ info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = std::max(this->bram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = std::max(this->bram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after BRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x05: ~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x06: ~~~~~~~~~~ info("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~ wakeup = true; ~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ break; ~~~~~~ case 0x10: ~~~~~~~~~~ current_bank = payload; ~~~~~~~~~~~~~~~~~~~~~~~ debug("Set bank to %d.\n", current_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x20: ~~~~~~~~~~ if (crc_value != 0) ~~~~~~~~~~~~~~~~~~~ error("CRC Check FAILED.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("CRC Check OK.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x50: ~~~~~~~~~~ if (payload == 0) ~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 1) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "medium"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 2) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "high"; ~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x60: ~~~~~~~~~~ current_width = payload + 1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank width to %d.\n", current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x70: ~~~~~~~~~~ current_height = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank height to %d.\n", current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x80: ~~~~~~~~~~ current_offset = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank offset to %d.\n", current_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x90: ~~~~~~~~~~ switch(payload) ~~~~~~~~~~~~~~~ { ~ case 0: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 1: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 32: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 33: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown warmboot/nosleep payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ if (this->cram_width == 182 && this->cram_height == 80) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "384"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 332 && this->cram_height == 144) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "1k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 872 && this->cram_height == 272) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "8k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 336) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "5k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "u4k"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 656 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "lm4k"; ~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Failed to detect chip type.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Chip type is '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::write_bits(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto byte : this->initblop) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << byte; ~~~~~~~~~~~~ debug("Writing preamble.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0xAA); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x99); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x51); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->freqrange == "low") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "medium") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "high") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x02); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x05); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ { ~ uint8_t nosleep_flag; ~~~~~~~~~~~~~~~~~~~~~ debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x92); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->nosleep == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 0; ~~~~~~~~~~~~~~~~~ else if (this->nosleep == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 1; ~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->warmboot == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank width to %d.\n", this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank offset to 0.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_bank = 0; cram_bank < 4; cram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector cram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int height = this->cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((cram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ height = height / 2 + 8; ~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_y = 0; cram_y < height; cram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_x = 0; cram_x < this->cram_width; cram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank %d.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Writing bank %d data.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(cram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ int bram_chunk_size = 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->bram_width && this->bram_height) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Setting bank height to %d.\n", this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_bank = 0; bram_bank < 4; bram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("BRAM: Setting bank %d.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector bram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int width = this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((bram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ width = width / 2; ~~~~~~~~~~~~~~~~~~ for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_x = 0; bram_x < width; bram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank offset to %d.\n", offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Writing bank %d data.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x03); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(bram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ debug("Writing CRC value.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x22); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_hi); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_lo); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x06); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Padding byte.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool got_device = false; ~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.clear(); ~~~~~~~~~~~~~~~~~~~ this->bram.clear(); ~~~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool reuse_line = true; ~~~~~~~~~~~~~~~~~~~~~~~ string line, command; ~~~~~~~~~~~~~~~~~~~~~ while (reuse_line || getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ reuse_line = false; ~~~~~~~~~~~~~~~~~~~ std::istringstream is(line); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> command; ~~~~~~~~~~~~~~ if (command.empty()) ~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ debug("Next command: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".comment") ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ this->initblop.clear(); ~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while (getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (auto ch : line) ~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(ch); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".device") ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (got_device) ~~~~~~~~~~~~~~~ error("More than one .device statement.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> this->device; ~~~~~~~~~~~~~~~~~~~ if (this->device == "384") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 182; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 80; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "1k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 332; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 144; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 64; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "8k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 872; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 272; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 128; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 336; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 160; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "u4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "lm4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 656; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ error("Unsupported chip type '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } else { ~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->bram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ got_device = true; ~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".warmboot") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ is >> this->warmboot; ~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "disabled" && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown warmboot setting '%s'.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ // No ".nosleep" section despite sharing the same byte as .warmboot. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ".nosleep" is specified when icepack is invoked, which is too late. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // So we inject the section based on command line argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (nosleep) ~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ CramIndexConverter cic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (("." + cic.tile_type + "_tile") != command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Got %s statement for %s tile %d %d.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (line[bit_x] == '1') { ~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".ram_data") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ BramIndexConverter bic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int value = -1; ~~~~~~~~~~~~~~~ if ('0' <= line[ch_idx] && line[ch_idx] <= '9') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - '0'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'a' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'A' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (value < 0) ~~~~~~~~~~~~~~ error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ((value & (1 << i)) != 0) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[bram_bank][bram_x][bram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".extra_bit") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> cram_bank >> cram_x >> cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".sym") ~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ if (command.substr(0, 1) == ".") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown statement: %s\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unexpected data line: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ void FpgaConfig::write_ascii(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << ".comment"; ~~~~~~~~~~~~~~~~~~ bool insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto ch : this->initblop) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (ch == 0) { ~~~~~~~~~~~~~~ insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~ } else if (ch == 0xff) { ~~~~~~~~~~~~~~~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } else { ~~~~~~~~ if (insert_newline) ~~~~~~~~~~~~~~~~~~~ ofs << '\n'; ~~~~~~~~~~~~ ofs << ch; ~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ ofs << stringf("\n.device %s\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // As "nosleep" is an icepack command, we do not write out a ".nosleep" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // section. However, we parse it in read_bits() and notify the user in ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // info. ~~~~~~~~ typedef std::tuple tile_bit_t; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ std::set tile_bits; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int y = 0; y <= this->chip_height()+1; y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x <= this->chip_width()+1; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ CramIndexConverter cic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cic.tile_type == "corner" || cic.tile_type == "unsupported") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cram_x > int(this->cram[cram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:902:6: note: in expansion of macro 'error' 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: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=] #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ string vstringf(const char *fmt, va_list ap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ char *str = NULL; ~~~~~~~~~~~~~~~~~ #ifdef _WIN32 ~~~~~~~~~~~~~ int sz = 64, rc; ~~~~~~~~~~~~~~~~ while (1) { ~~~~~~~~~~~ va_list apc; ~~~~~~~~~~~~ va_copy(apc, ap); ~~~~~~~~~~~~~~~~~ str = (char*)realloc(str, sz); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rc = vsnprintf(str, sz, fmt, apc); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(apc); ~~~~~~~~~~~~ if (rc >= 0 && rc < sz) ~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ sz *= 2; ~~~~~~~~ } ~ #else ~~~~~ if (vasprintf(&str, fmt, ap) < 0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ str = NULL; ~~~~~~~~~~~ #endif ~~~~~~ if (str != NULL) { ~~~~~~~~~~~~~~~~~~ string = str; ~~~~~~~~~~~~~ free(str); ~~~~~~~~~~ } ~ return string; ~~~~~~~~~~~~~~ } ~ string stringf(const char *fmt, ...) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ va_list ap; ~~~~~~~~~~~ va_start(ap, fmt); ~~~~~~~~~~~~~~~~~~ string = vstringf(fmt, ap); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(ap); ~~~~~~~~~~~ return string; ~~~~~~~~~~~~~~ } ~ // ================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // FpgaConfig stuff ~~~~~~~~~~~~~~~~~~~ struct FpgaConfig ~~~~~~~~~~~~~~~~~ { ~ string device; ~~~~~~~~~~~~~~ string freqrange; ~~~~~~~~~~~~~~~~~ string nosleep; ~~~~~~~~~~~~~~~ string warmboot; ~~~~~~~~~~~~~~~~ // cram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int cram_width, cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> cram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // bram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int bram_width, bram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> bram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // data before preamble ~~~~~~~~~~~~~~~~~~~~~~~ vector initblop; ~~~~~~~~~~~~~~~~~~~~~~~~~ // bitstream i/o ~~~~~~~~~~~~~~~~ void read_bits(std::istream &ifs); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bits(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // icebox i/o ~~~~~~~~~~~~~ void read_ascii(std::istream &ifs, bool nosleep); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_ascii(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // netpbm i/o ~~~~~~~~~~~~~ void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query chip type metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~ int chip_width() const; ~~~~~~~~~~~~~~~~~~~~~~~ int chip_height() const; ~~~~~~~~~~~~~~~~~~~~~~~~ vector chip_cols() const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query tile metadata ~~~~~~~~~~~~~~~~~~~~~~ string tile_type(int x, int y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_width(const string &type) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // cram bit manipulation ~~~~~~~~~~~~~~~~~~~~~~~~ void cram_clear(); ~~~~~~~~~~~~~~~~~~ void cram_fill_tiles(); ~~~~~~~~~~~~~~~~~~~~~~~ void cram_checkerboard(int m = 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct CramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ string tile_type; ~~~~~~~~~~~~~~~~~ int tile_width; ~~~~~~~~~~~~~~~ int column_width; ~~~~~~~~~~~~~~~~~ bool left_right_io; ~~~~~~~~~~~~~~~~~~~ bool right_half; ~~~~~~~~~~~~~~~~ bool top_half; ~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_tx; ~~~~~~~~~~~~ int bank_ty; ~~~~~~~~~~~~ int bank_xoff; ~~~~~~~~~~~~~~ int bank_yoff; ~~~~~~~~~~~~~~ CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct BramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_off; ~~~~~~~~~~~~~ BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ static void update_crc16(uint16_t &crc, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 7; i >= 0; i--) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc = (crc << 1) ^ xor_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int byte = ifs.get(); ~~~~~~~~~~~~~~~~~~~~~ if (byte < 0) ~~~~~~~~~~~~~ error("Unexpected end of file.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return byte; ~~~~~~~~~~~~ } ~ static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ ofs << byte; ~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_bits(std::istream &ifs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // skip initial comments until preamble is found ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t preamble = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (1) ~~~~~~~~~ { ~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ preamble = (preamble << 8) | byte; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0xffffffff) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("No preamble found in bitstream.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0x7EAA997E) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Found preamble at offset %d.\n", file_offset-4); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ initblop.push_back(byte); ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ // main parser loop ~~~~~~~~~~~~~~~~~~~ int current_bank = 0; ~~~~~~~~~~~~~~~~~~~~~ int current_width = 0; ~~~~~~~~~~~~~~~~~~~~~~ int current_height = 0; ~~~~~~~~~~~~~~~~~~~~~~~ int current_offset = 0; ~~~~~~~~~~~~~~~~~~~~~~~ bool wakeup = false; ~~~~~~~~~~~~~~~~~~~~ this->cram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (!wakeup) ~~~~~~~~~~~~~~~ { ~ // one command byte. the lower 4 bits of the command byte specify ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // the length of the command payload. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t command = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t payload = 0; ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (command & 0x0f); i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command, 2*(command & 0x0f), payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t end_token; ~~~~~~~~~~~~~~~~~~~ switch (command & 0xf0) ~~~~~~~~~~~~~~~~~~~~~~~ { ~ case 0x00: ~~~~~~~~~~ switch (payload) ~~~~~~~~~~~~~~~~ { ~ case 0x01: ~~~~~~~~~~ info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = std::max(this->cram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = std::max(this->cram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x03: ~~~~~~~~~~ info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = std::max(this->bram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = std::max(this->bram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after BRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x05: ~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x06: ~~~~~~~~~~ info("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~ wakeup = true; ~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ break; ~~~~~~ case 0x10: ~~~~~~~~~~ current_bank = payload; ~~~~~~~~~~~~~~~~~~~~~~~ debug("Set bank to %d.\n", current_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x20: ~~~~~~~~~~ if (crc_value != 0) ~~~~~~~~~~~~~~~~~~~ error("CRC Check FAILED.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("CRC Check OK.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x50: ~~~~~~~~~~ if (payload == 0) ~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 1) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "medium"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 2) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "high"; ~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x60: ~~~~~~~~~~ current_width = payload + 1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank width to %d.\n", current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x70: ~~~~~~~~~~ current_height = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank height to %d.\n", current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x80: ~~~~~~~~~~ current_offset = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank offset to %d.\n", current_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x90: ~~~~~~~~~~ switch(payload) ~~~~~~~~~~~~~~~ { ~ case 0: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 1: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 32: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 33: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown warmboot/nosleep payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ if (this->cram_width == 182 && this->cram_height == 80) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "384"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 332 && this->cram_height == 144) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "1k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 872 && this->cram_height == 272) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "8k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 336) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "5k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "u4k"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 656 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "lm4k"; ~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Failed to detect chip type.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Chip type is '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::write_bits(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto byte : this->initblop) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << byte; ~~~~~~~~~~~~ debug("Writing preamble.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0xAA); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x99); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x51); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->freqrange == "low") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "medium") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "high") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x02); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x05); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ { ~ uint8_t nosleep_flag; ~~~~~~~~~~~~~~~~~~~~~ debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x92); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->nosleep == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 0; ~~~~~~~~~~~~~~~~~ else if (this->nosleep == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 1; ~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->warmboot == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank width to %d.\n", this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank offset to 0.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_bank = 0; cram_bank < 4; cram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector cram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int height = this->cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((cram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ height = height / 2 + 8; ~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_y = 0; cram_y < height; cram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_x = 0; cram_x < this->cram_width; cram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank %d.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Writing bank %d data.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(cram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ int bram_chunk_size = 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->bram_width && this->bram_height) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Setting bank height to %d.\n", this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_bank = 0; bram_bank < 4; bram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("BRAM: Setting bank %d.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector bram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int width = this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((bram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ width = width / 2; ~~~~~~~~~~~~~~~~~~ for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_x = 0; bram_x < width; bram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank offset to %d.\n", offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Writing bank %d data.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x03); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(bram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ debug("Writing CRC value.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x22); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_hi); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_lo); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x06); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Padding byte.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool got_device = false; ~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.clear(); ~~~~~~~~~~~~~~~~~~~ this->bram.clear(); ~~~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool reuse_line = true; ~~~~~~~~~~~~~~~~~~~~~~~ string line, command; ~~~~~~~~~~~~~~~~~~~~~ while (reuse_line || getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ reuse_line = false; ~~~~~~~~~~~~~~~~~~~ std::istringstream is(line); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> command; ~~~~~~~~~~~~~~ if (command.empty()) ~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ debug("Next command: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".comment") ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ this->initblop.clear(); ~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while (getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (auto ch : line) ~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(ch); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".device") ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (got_device) ~~~~~~~~~~~~~~~ error("More than one .device statement.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> this->device; ~~~~~~~~~~~~~~~~~~~ if (this->device == "384") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 182; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 80; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "1k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 332; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 144; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 64; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "8k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 872; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 272; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 128; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 336; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 160; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "u4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "lm4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 656; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ error("Unsupported chip type '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } else { ~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->bram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ got_device = true; ~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".warmboot") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ is >> this->warmboot; ~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "disabled" && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown warmboot setting '%s'.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ // No ".nosleep" section despite sharing the same byte as .warmboot. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ".nosleep" is specified when icepack is invoked, which is too late. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // So we inject the section based on command line argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (nosleep) ~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ CramIndexConverter cic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (("." + cic.tile_type + "_tile") != command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Got %s statement for %s tile %d %d.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (line[bit_x] == '1') { ~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".ram_data") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ BramIndexConverter bic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int value = -1; ~~~~~~~~~~~~~~~ if ('0' <= line[ch_idx] && line[ch_idx] <= '9') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - '0'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'a' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'A' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (value < 0) ~~~~~~~~~~~~~~ error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ((value & (1 << i)) != 0) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[bram_bank][bram_x][bram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".extra_bit") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> cram_bank >> cram_x >> cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".sym") ~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ if (command.substr(0, 1) == ".") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown statement: %s\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unexpected data line: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ void FpgaConfig::write_ascii(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << ".comment"; ~~~~~~~~~~~~~~~~~~ bool insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto ch : this->initblop) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (ch == 0) { ~~~~~~~~~~~~~~ insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~ } else if (ch == 0xff) { ~~~~~~~~~~~~~~~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } else { ~~~~~~~~ if (insert_newline) ~~~~~~~~~~~~~~~~~~~ ofs << '\n'; ~~~~~~~~~~~~ ofs << ch; ~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ ofs << stringf("\n.device %s\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // As "nosleep" is an icepack command, we do not write out a ".nosleep" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // section. However, we parse it in read_bits() and notify the user in ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // info. ~~~~~~~~ typedef std::tuple tile_bit_t; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ std::set tile_bits; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int y = 0; y <= this->chip_height()+1; y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x <= this->chip_width()+1; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ CramIndexConverter cic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cic.tile_type == "corner" || cic.tile_type == "unsupported") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cram_x > int(this->cram[cram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ if (cram_y > int(this->cram[cram_bank][cram_x].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:905:6: note: in expansion of macro 'error' 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: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=] #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ string vstringf(const char *fmt, va_list ap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ char *str = NULL; ~~~~~~~~~~~~~~~~~ #ifdef _WIN32 ~~~~~~~~~~~~~ int sz = 64, rc; ~~~~~~~~~~~~~~~~ while (1) { ~~~~~~~~~~~ va_list apc; ~~~~~~~~~~~~ va_copy(apc, ap); ~~~~~~~~~~~~~~~~~ str = (char*)realloc(str, sz); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rc = vsnprintf(str, sz, fmt, apc); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(apc); ~~~~~~~~~~~~ if (rc >= 0 && rc < sz) ~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ sz *= 2; ~~~~~~~~ } ~ #else ~~~~~ if (vasprintf(&str, fmt, ap) < 0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ str = NULL; ~~~~~~~~~~~ #endif ~~~~~~ if (str != NULL) { ~~~~~~~~~~~~~~~~~~ string = str; ~~~~~~~~~~~~~ free(str); ~~~~~~~~~~ } ~ return string; ~~~~~~~~~~~~~~ } ~ string stringf(const char *fmt, ...) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ va_list ap; ~~~~~~~~~~~ va_start(ap, fmt); ~~~~~~~~~~~~~~~~~~ string = vstringf(fmt, ap); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(ap); ~~~~~~~~~~~ return string; ~~~~~~~~~~~~~~ } ~ // ================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // FpgaConfig stuff ~~~~~~~~~~~~~~~~~~~ struct FpgaConfig ~~~~~~~~~~~~~~~~~ { ~ string device; ~~~~~~~~~~~~~~ string freqrange; ~~~~~~~~~~~~~~~~~ string nosleep; ~~~~~~~~~~~~~~~ string warmboot; ~~~~~~~~~~~~~~~~ // cram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int cram_width, cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> cram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // bram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int bram_width, bram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> bram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // data before preamble ~~~~~~~~~~~~~~~~~~~~~~~ vector initblop; ~~~~~~~~~~~~~~~~~~~~~~~~~ // bitstream i/o ~~~~~~~~~~~~~~~~ void read_bits(std::istream &ifs); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bits(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // icebox i/o ~~~~~~~~~~~~~ void read_ascii(std::istream &ifs, bool nosleep); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_ascii(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // netpbm i/o ~~~~~~~~~~~~~ void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query chip type metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~ int chip_width() const; ~~~~~~~~~~~~~~~~~~~~~~~ int chip_height() const; ~~~~~~~~~~~~~~~~~~~~~~~~ vector chip_cols() const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query tile metadata ~~~~~~~~~~~~~~~~~~~~~~ string tile_type(int x, int y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_width(const string &type) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // cram bit manipulation ~~~~~~~~~~~~~~~~~~~~~~~~ void cram_clear(); ~~~~~~~~~~~~~~~~~~ void cram_fill_tiles(); ~~~~~~~~~~~~~~~~~~~~~~~ void cram_checkerboard(int m = 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct CramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ string tile_type; ~~~~~~~~~~~~~~~~~ int tile_width; ~~~~~~~~~~~~~~~ int column_width; ~~~~~~~~~~~~~~~~~ bool left_right_io; ~~~~~~~~~~~~~~~~~~~ bool right_half; ~~~~~~~~~~~~~~~~ bool top_half; ~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_tx; ~~~~~~~~~~~~ int bank_ty; ~~~~~~~~~~~~ int bank_xoff; ~~~~~~~~~~~~~~ int bank_yoff; ~~~~~~~~~~~~~~ CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct BramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_off; ~~~~~~~~~~~~~ BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ static void update_crc16(uint16_t &crc, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 7; i >= 0; i--) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc = (crc << 1) ^ xor_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int byte = ifs.get(); ~~~~~~~~~~~~~~~~~~~~~ if (byte < 0) ~~~~~~~~~~~~~ error("Unexpected end of file.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return byte; ~~~~~~~~~~~~ } ~ static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ ofs << byte; ~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_bits(std::istream &ifs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // skip initial comments until preamble is found ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t preamble = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (1) ~~~~~~~~~ { ~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ preamble = (preamble << 8) | byte; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0xffffffff) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("No preamble found in bitstream.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0x7EAA997E) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Found preamble at offset %d.\n", file_offset-4); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ initblop.push_back(byte); ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ // main parser loop ~~~~~~~~~~~~~~~~~~~ int current_bank = 0; ~~~~~~~~~~~~~~~~~~~~~ int current_width = 0; ~~~~~~~~~~~~~~~~~~~~~~ int current_height = 0; ~~~~~~~~~~~~~~~~~~~~~~~ int current_offset = 0; ~~~~~~~~~~~~~~~~~~~~~~~ bool wakeup = false; ~~~~~~~~~~~~~~~~~~~~ this->cram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (!wakeup) ~~~~~~~~~~~~~~~ { ~ // one command byte. the lower 4 bits of the command byte specify ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // the length of the command payload. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t command = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t payload = 0; ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (command & 0x0f); i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command, 2*(command & 0x0f), payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t end_token; ~~~~~~~~~~~~~~~~~~~ switch (command & 0xf0) ~~~~~~~~~~~~~~~~~~~~~~~ { ~ case 0x00: ~~~~~~~~~~ switch (payload) ~~~~~~~~~~~~~~~~ { ~ case 0x01: ~~~~~~~~~~ info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = std::max(this->cram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = std::max(this->cram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x03: ~~~~~~~~~~ info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = std::max(this->bram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = std::max(this->bram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after BRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x05: ~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x06: ~~~~~~~~~~ info("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~ wakeup = true; ~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ break; ~~~~~~ case 0x10: ~~~~~~~~~~ current_bank = payload; ~~~~~~~~~~~~~~~~~~~~~~~ debug("Set bank to %d.\n", current_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x20: ~~~~~~~~~~ if (crc_value != 0) ~~~~~~~~~~~~~~~~~~~ error("CRC Check FAILED.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("CRC Check OK.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x50: ~~~~~~~~~~ if (payload == 0) ~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 1) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "medium"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 2) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "high"; ~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x60: ~~~~~~~~~~ current_width = payload + 1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank width to %d.\n", current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x70: ~~~~~~~~~~ current_height = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank height to %d.\n", current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x80: ~~~~~~~~~~ current_offset = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank offset to %d.\n", current_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x90: ~~~~~~~~~~ switch(payload) ~~~~~~~~~~~~~~~ { ~ case 0: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 1: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 32: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 33: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown warmboot/nosleep payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ if (this->cram_width == 182 && this->cram_height == 80) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "384"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 332 && this->cram_height == 144) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "1k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 872 && this->cram_height == 272) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "8k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 336) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "5k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "u4k"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 656 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "lm4k"; ~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Failed to detect chip type.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Chip type is '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::write_bits(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto byte : this->initblop) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << byte; ~~~~~~~~~~~~ debug("Writing preamble.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0xAA); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x99); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x51); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->freqrange == "low") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "medium") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "high") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x02); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x05); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ { ~ uint8_t nosleep_flag; ~~~~~~~~~~~~~~~~~~~~~ debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x92); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->nosleep == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 0; ~~~~~~~~~~~~~~~~~ else if (this->nosleep == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 1; ~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->warmboot == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank width to %d.\n", this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank offset to 0.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_bank = 0; cram_bank < 4; cram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector cram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int height = this->cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((cram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ height = height / 2 + 8; ~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_y = 0; cram_y < height; cram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_x = 0; cram_x < this->cram_width; cram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank %d.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Writing bank %d data.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(cram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ int bram_chunk_size = 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->bram_width && this->bram_height) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Setting bank height to %d.\n", this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_bank = 0; bram_bank < 4; bram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("BRAM: Setting bank %d.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector bram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int width = this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((bram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ width = width / 2; ~~~~~~~~~~~~~~~~~~ for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_x = 0; bram_x < width; bram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank offset to %d.\n", offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Writing bank %d data.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x03); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(bram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ debug("Writing CRC value.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x22); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_hi); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_lo); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x06); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Padding byte.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool got_device = false; ~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.clear(); ~~~~~~~~~~~~~~~~~~~ this->bram.clear(); ~~~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool reuse_line = true; ~~~~~~~~~~~~~~~~~~~~~~~ string line, command; ~~~~~~~~~~~~~~~~~~~~~ while (reuse_line || getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ reuse_line = false; ~~~~~~~~~~~~~~~~~~~ std::istringstream is(line); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> command; ~~~~~~~~~~~~~~ if (command.empty()) ~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ debug("Next command: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".comment") ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ this->initblop.clear(); ~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while (getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (auto ch : line) ~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(ch); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".device") ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (got_device) ~~~~~~~~~~~~~~~ error("More than one .device statement.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> this->device; ~~~~~~~~~~~~~~~~~~~ if (this->device == "384") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 182; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 80; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "1k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 332; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 144; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 64; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "8k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 872; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 272; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 128; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 336; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 160; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "u4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "lm4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 656; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ error("Unsupported chip type '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } else { ~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->bram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ got_device = true; ~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".warmboot") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ is >> this->warmboot; ~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "disabled" && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown warmboot setting '%s'.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ // No ".nosleep" section despite sharing the same byte as .warmboot. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ".nosleep" is specified when icepack is invoked, which is too late. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // So we inject the section based on command line argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (nosleep) ~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ CramIndexConverter cic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (("." + cic.tile_type + "_tile") != command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Got %s statement for %s tile %d %d.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (line[bit_x] == '1') { ~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".ram_data") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ BramIndexConverter bic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int value = -1; ~~~~~~~~~~~~~~~ if ('0' <= line[ch_idx] && line[ch_idx] <= '9') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - '0'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'a' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'A' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (value < 0) ~~~~~~~~~~~~~~ error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ((value & (1 << i)) != 0) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[bram_bank][bram_x][bram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".extra_bit") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> cram_bank >> cram_x >> cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".sym") ~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ if (command.substr(0, 1) == ".") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown statement: %s\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unexpected data line: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ void FpgaConfig::write_ascii(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << ".comment"; ~~~~~~~~~~~~~~~~~~ bool insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto ch : this->initblop) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (ch == 0) { ~~~~~~~~~~~~~~ insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~ } else if (ch == 0xff) { ~~~~~~~~~~~~~~~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } else { ~~~~~~~~ if (insert_newline) ~~~~~~~~~~~~~~~~~~~ ofs << '\n'; ~~~~~~~~~~~~ ofs << ch; ~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ ofs << stringf("\n.device %s\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // As "nosleep" is an icepack command, we do not write out a ".nosleep" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // section. However, we parse it in read_bits() and notify the user in ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // info. ~~~~~~~~ typedef std::tuple tile_bit_t; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ std::set tile_bits; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int y = 0; y <= this->chip_height()+1; y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x <= this->chip_width()+1; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ CramIndexConverter cic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cic.tile_type == "corner" || cic.tile_type == "unsupported") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cram_x > int(this->cram[cram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ if (cram_y > int(this->cram[cram_bank][cram_x].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ ofs << (this->cram[cram_bank][cram_x][cram_y] ? '1' : '0'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ ofs << '\n'; ~~~~~~~~~~~~ } ~ if (cic.tile_type == "ramb") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ BramIndexConverter bic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".ram_data %d %d\n", x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 256-4; bit_x >= 0; bit_x -= 4) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int value = 0; ~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (bram_x >= int(this->bram[bram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:924:8: note: in expansion of macro 'error' 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: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=] #define error(...) do { fprintf(stderr, "Error: " __VA_ARGS__); exit(1); } while (0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #define panic(fmt, ...) do { fprintf(stderr, "Internal Error at %s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); abort(); } while (0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ string vstringf(const char *fmt, va_list ap) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ char *str = NULL; ~~~~~~~~~~~~~~~~~ #ifdef _WIN32 ~~~~~~~~~~~~~ int sz = 64, rc; ~~~~~~~~~~~~~~~~ while (1) { ~~~~~~~~~~~ va_list apc; ~~~~~~~~~~~~ va_copy(apc, ap); ~~~~~~~~~~~~~~~~~ str = (char*)realloc(str, sz); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ rc = vsnprintf(str, sz, fmt, apc); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(apc); ~~~~~~~~~~~~ if (rc >= 0 && rc < sz) ~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ sz *= 2; ~~~~~~~~ } ~ #else ~~~~~ if (vasprintf(&str, fmt, ap) < 0) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ str = NULL; ~~~~~~~~~~~ #endif ~~~~~~ if (str != NULL) { ~~~~~~~~~~~~~~~~~~ string = str; ~~~~~~~~~~~~~ free(str); ~~~~~~~~~~ } ~ return string; ~~~~~~~~~~~~~~ } ~ string stringf(const char *fmt, ...) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ string string; ~~~~~~~~~~~~~~ va_list ap; ~~~~~~~~~~~ va_start(ap, fmt); ~~~~~~~~~~~~~~~~~~ string = vstringf(fmt, ap); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ va_end(ap); ~~~~~~~~~~~ return string; ~~~~~~~~~~~~~~ } ~ // ================================================================== ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // FpgaConfig stuff ~~~~~~~~~~~~~~~~~~~ struct FpgaConfig ~~~~~~~~~~~~~~~~~ { ~ string device; ~~~~~~~~~~~~~~ string freqrange; ~~~~~~~~~~~~~~~~~ string nosleep; ~~~~~~~~~~~~~~~ string warmboot; ~~~~~~~~~~~~~~~~ // cram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int cram_width, cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> cram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // bram[BANK][X][Y] ~~~~~~~~~~~~~~~~~~~ int bram_width, bram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vector>> bram; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // data before preamble ~~~~~~~~~~~~~~~~~~~~~~~ vector initblop; ~~~~~~~~~~~~~~~~~~~~~~~~~ // bitstream i/o ~~~~~~~~~~~~~~~~ void read_bits(std::istream &ifs); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bits(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // icebox i/o ~~~~~~~~~~~~~ void read_ascii(std::istream &ifs, bool nosleep); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_ascii(std::ostream &ofs) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // netpbm i/o ~~~~~~~~~~~~~ void write_cram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void write_bram_pbm(std::ostream &ofs, int bank_num = -1) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query chip type metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~ int chip_width() const; ~~~~~~~~~~~~~~~~~~~~~~~ int chip_height() const; ~~~~~~~~~~~~~~~~~~~~~~~~ vector chip_cols() const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // query tile metadata ~~~~~~~~~~~~~~~~~~~~~~ string tile_type(int x, int y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_width(const string &type) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // cram bit manipulation ~~~~~~~~~~~~~~~~~~~~~~~~ void cram_clear(); ~~~~~~~~~~~~~~~~~~ void cram_fill_tiles(); ~~~~~~~~~~~~~~~~~~~~~~~ void cram_checkerboard(int m = 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct CramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ string tile_type; ~~~~~~~~~~~~~~~~~ int tile_width; ~~~~~~~~~~~~~~~ int column_width; ~~~~~~~~~~~~~~~~~ bool left_right_io; ~~~~~~~~~~~~~~~~~~~ bool right_half; ~~~~~~~~~~~~~~~~ bool top_half; ~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_tx; ~~~~~~~~~~~~ int bank_ty; ~~~~~~~~~~~~ int bank_xoff; ~~~~~~~~~~~~~~ int bank_yoff; ~~~~~~~~~~~~~~ CramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_cram_index(int bit_x, int bit_y, int &cram_bank, int &cram_x, int &cram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ struct BramIndexConverter ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ const FpgaConfig *fpga; ~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ int bank_num; ~~~~~~~~~~~~~ int bank_off; ~~~~~~~~~~~~~ BramIndexConverter(const FpgaConfig *fpga, int tile_x, int tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void get_bram_index(int bit_x, int bit_y, int &bram_bank, int &bram_x, int &bram_y) const; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }; ~~ static void update_crc16(uint16_t &crc, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ // CRC-16-CCITT, Initialize to 0xFFFF, No zero padding ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 7; i >= 0; i--) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t xor_value = ((crc >> 15) ^ ((byte >> i) & 1)) ? 0x1021 : 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc = (crc << 1) ^ xor_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ static uint8_t read_byte(std::istream &ifs, uint16_t &crc_value, int &file_offset) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int byte = ifs.get(); ~~~~~~~~~~~~~~~~~~~~~ if (byte < 0) ~~~~~~~~~~~~~ error("Unexpected end of file.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ return byte; ~~~~~~~~~~~~ } ~ static void write_byte(std::ostream &ofs, uint16_t &crc_value, int &file_offset, uint8_t byte) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ ofs << byte; ~~~~~~~~~~~~ file_offset++; ~~~~~~~~~~~~~~ update_crc16(crc_value, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_bits(std::istream &ifs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // skip initial comments until preamble is found ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t preamble = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (1) ~~~~~~~~~ { ~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ preamble = (preamble << 8) | byte; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0xffffffff) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("No preamble found in bitstream.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (preamble == 0x7EAA997E) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Found preamble at offset %d.\n", file_offset-4); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ initblop.push_back(byte); ~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ initblop.pop_back(); ~~~~~~~~~~~~~~~~~~~~ // main parser loop ~~~~~~~~~~~~~~~~~~~ int current_bank = 0; ~~~~~~~~~~~~~~~~~~~~~ int current_width = 0; ~~~~~~~~~~~~~~~~~~~~~~ int current_height = 0; ~~~~~~~~~~~~~~~~~~~~~~~ int current_offset = 0; ~~~~~~~~~~~~~~~~~~~~~~~ bool wakeup = false; ~~~~~~~~~~~~~~~~~~~~ this->cram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ while (!wakeup) ~~~~~~~~~~~~~~~ { ~ // one command byte. the lower 4 bits of the command byte specify ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // the length of the command payload. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t command = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint32_t payload = 0; ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (command & 0x0f); i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ payload = (payload << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Next command at offset %d: 0x%02x 0x%0*x\n", file_offset - 1 - (command & 0x0f), ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command, 2*(command & 0x0f), payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint16_t end_token; ~~~~~~~~~~~~~~~~~~~ switch (command & 0xf0) ~~~~~~~~~~~~~~~~~~~~~~~ { ~ case 0x00: ~~~~~~~~~~ switch (payload) ~~~~~~~~~~~~~~~~ { ~ case 0x01: ~~~~~~~~~~ info("CRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = std::max(this->cram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = std::max(this->cram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after CRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x03: ~~~~~~~~~~ info("BRAM Data [%d]: %d x %d bits = %d bits = %d bytes\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_bank, current_width, current_height, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ current_height*current_width, (current_height*current_width)/8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = std::max(this->bram_width, current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = std::max(this->bram_height, current_offset + current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < current_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < (current_height*current_width)/8; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int x = (i*8 + j) % current_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int y = (i*8 + j) / current_width + current_offset; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[current_bank][x][y] = ((byte << j) & 0x80) != 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ end_token = read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ end_token = (end_token << 8) | read_byte(ifs, crc_value, file_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (end_token) ~~~~~~~~~~~~~~ error("Expeded 0x0000 after BRAM data, got 0x%04x\n", end_token); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x05: ~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x06: ~~~~~~~~~~ info("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~ wakeup = true; ~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ break; ~~~~~~ case 0x10: ~~~~~~~~~~ current_bank = payload; ~~~~~~~~~~~~~~~~~~~~~~~ debug("Set bank to %d.\n", current_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x20: ~~~~~~~~~~ if (crc_value != 0) ~~~~~~~~~~~~~~~~~~~ error("CRC Check FAILED.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("CRC Check OK.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x50: ~~~~~~~~~~ if (payload == 0) ~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 1) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "medium"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (payload == 2) ~~~~~~~~~~~~~~~~~~~~~~ this->freqrange = "high"; ~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x60: ~~~~~~~~~~ current_width = payload + 1; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank width to %d.\n", current_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x70: ~~~~~~~~~~ current_height = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank height to %d.\n", current_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x80: ~~~~~~~~~~ current_offset = payload; ~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting bank offset to %d.\n", current_offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 0x90: ~~~~~~~~~~ switch(payload) ~~~~~~~~~~~~~~~ { ~ case 0: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 1: ~~~~~~~ this->warmboot = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 32: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ case 33: ~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown warmboot/nosleep payload 0x%02x\n", payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ info("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ default: ~~~~~~~~ error("Unknown command: 0x%02x 0x%02x\n", command, payload); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ if (this->cram_width == 182 && this->cram_height == 80) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "384"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 332 && this->cram_height == 144) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "1k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 872 && this->cram_height == 272) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "8k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 336) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "5k"; ~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 692 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "u4k"; ~~~~~~~~~~~~~~~~~~~~~ else if (this->cram_width == 656 && this->cram_height == 176) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->device = "lm4k"; ~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Failed to detect chip type.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Chip type is '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::write_bits(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int file_offset = 0; ~~~~~~~~~~~~~~~~~~~~ uint16_t crc_value = 0; ~~~~~~~~~~~~~~~~~~~~~~~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing bitstream file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto byte : this->initblop) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << byte; ~~~~~~~~~~~~ debug("Writing preamble.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0xAA); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x99); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x7E); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Setting freqrange to '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x51); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->freqrange == "low") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "medium") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->freqrange == "high") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x02); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown freqrange '%s'.\n", this->freqrange.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Resetting CRC.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x05); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc_value = 0xffff; ~~~~~~~~~~~~~~~~~~~ { ~ uint8_t nosleep_flag; ~~~~~~~~~~~~~~~~~~~~~ debug("Setting warmboot to '%s', nosleep to '%s'.\n", this->warmboot.c_str(), this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x92); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->nosleep == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 0; ~~~~~~~~~~~~~~~~~ else if (this->nosleep == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nosleep_flag = 1; ~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown nosleep setting '%s'.\n", this->nosleep.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot == "disabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else if (this->warmboot == "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x20 | nosleep_flag); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ error("Unknown warmboot setting '%s'.\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank width to %d.\n", this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->cram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank offset to 0.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_bank = 0; cram_bank < 4; cram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector cram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int height = this->cram_height; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((cram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ height = height / 2 + 8; ~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_y = 0; cram_y < height; cram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int cram_x = 0; cram_x < this->cram_width; cram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cram_bits.push_back(this->cram[cram_bank][cram_x][cram_y]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Setting bank height to %d.\n", height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("CRAM: Setting bank %d.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("CRAM: Writing bank %d data.\n", cram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(cram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (cram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ int bram_chunk_size = 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->bram_width && this->bram_height) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if(this->device != "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (this->bram_width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Setting bank height to %d.\n", this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x72); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_chunk_size); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_bank = 0; bram_bank < 4; bram_bank++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("BRAM: Setting bank %d.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x11); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int offset = 0; offset < this->bram_height; offset += bram_chunk_size) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ vector bram_bits; ~~~~~~~~~~~~~~~~~~~~~~~ int width = this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k" && ((bram_bank % 2) == 1)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ width = width / 2; ~~~~~~~~~~~~~~~~~~ for (int bram_y = 0; bram_y < bram_chunk_size; bram_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bram_x = 0; bram_x < width; bram_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bram_bits.push_back(this->bram[bram_bank][bram_x][bram_y+offset]); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank offset to %d.\n", offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x82); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, offset); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("BRAM: Setting bank width to %d.\n", width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x62); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1) >> 8); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, (width-1)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ debug("BRAM: Writing bank %d data.\n", bram_bank); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x03); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < int(bram_bits.size()); i += 8) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t byte = 0; ~~~~~~~~~~~~~~~~~ for (int j = 0; j < 8; j++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ byte = (byte << 1) | (bram_bits[i+j] ? 1 : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, byte); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ debug("Writing CRC value.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x22); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ uint8_t crc_hi = crc_value >> 8, crc_lo = crc_value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_hi); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, crc_lo); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Wakeup.\n"); ~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x01); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x06); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ debug("Padding byte.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~ write_byte(ofs, crc_value, file_offset, 0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ void FpgaConfig::read_ascii(std::istream &ifs, bool nosleep) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Parsing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool got_device = false; ~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.clear(); ~~~~~~~~~~~~~~~~~~~ this->bram.clear(); ~~~~~~~~~~~~~~~~~~~ this->freqrange = "low"; ~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool reuse_line = true; ~~~~~~~~~~~~~~~~~~~~~~~ string line, command; ~~~~~~~~~~~~~~~~~~~~~ while (reuse_line || getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ reuse_line = false; ~~~~~~~~~~~~~~~~~~~ std::istringstream is(line); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> command; ~~~~~~~~~~~~~~ if (command.empty()) ~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ debug("Next command: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".comment") ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ this->initblop.clear(); ~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ while (getline(ifs, line)) ~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (auto ch : line) ~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(ch); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->initblop.push_back(0x00); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->initblop.push_back(0xff); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".device") ~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (got_device) ~~~~~~~~~~~~~~~ error("More than one .device statement.\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> this->device; ~~~~~~~~~~~~~~~~~~~ if (this->device == "384") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 182; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 80; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 0; ~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 0; ~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "1k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 332; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 144; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 64; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "8k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 872; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 272; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 128; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 336; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 160; ~~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "u4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 692; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ if (this->device == "lm4k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram_width = 656; ~~~~~~~~~~~~~~~~~~~~~~~ this->cram_height = 176; ~~~~~~~~~~~~~~~~~~~~~~~~ this->bram_width = 80; ~~~~~~~~~~~~~~~~~~~~~~ this->bram_height = 2 * 128; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } else ~~~~~~ error("Unsupported chip type '%s'.\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ if(this->device == "5k") { ~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(((i % 2) == 1) ? (this->cram_height / 2 + 8) : this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int width = ((i % 2) == 1) ? (this->bram_width / 2) : this->bram_width; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } else { ~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i].resize(this->cram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->cram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[i][x].resize(this->cram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ this->bram.resize(4); ~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i].resize(this->bram_width); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x < this->bram_width; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[i][x].resize(this->bram_height); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ got_device = true; ~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".warmboot") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ is >> this->warmboot; ~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "disabled" && ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown warmboot setting '%s'.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ // No ".nosleep" section despite sharing the same byte as .warmboot. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ".nosleep" is specified when icepack is invoked, which is too late. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // So we inject the section based on command line argument. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (nosleep) ~~~~~~~~~~~~ this->nosleep = "enabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~ else ~~~~ this->nosleep = "disabled"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ CramIndexConverter cic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (("." + cic.tile_type + "_tile") != command) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Got %s statement for %s tile %d %d.\n", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ command.c_str(), cic.tile_type.c_str(), tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 0; bit_x < int(line.size()) && bit_x < cic.tile_width; bit_x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (line[bit_x] == '1') { ~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".ram_data") ~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int tile_x, tile_y; ~~~~~~~~~~~~~~~~~~~ is >> tile_x >> tile_y; ~~~~~~~~~~~~~~~~~~~~~~~ BramIndexConverter bic(this, tile_x, tile_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16 && getline(ifs, line); bit_y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (line.substr(0, 1) == ".") { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ reuse_line = true; ~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ for (int bit_x = 256-4, ch_idx = 0; ch_idx < int(line.size()) && bit_x >= 0; bit_x -= 4, ch_idx++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ int value = -1; ~~~~~~~~~~~~~~~ if ('0' <= line[ch_idx] && line[ch_idx] <= '9') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - '0'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('a' <= line[ch_idx] && line[ch_idx] <= 'f') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'a' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ('A' <= line[ch_idx] && line[ch_idx] <= 'F') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ value = line[ch_idx] - 'A' + 10; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (value < 0) ~~~~~~~~~~~~~~ error("Not a hex character: '%c' (in line '%s')\n", line[ch_idx], line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ((value & (1 << i)) != 0) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->bram[bram_bank][bram_x][bram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ } ~ continue; ~~~~~~~~~ } ~ if (command == ".extra_bit") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ if (!got_device) ~~~~~~~~~~~~~~~~ error("Missing .device statement before %s.\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ is >> cram_bank >> cram_x >> cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ this->cram[cram_bank][cram_x][cram_y] = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ } ~ if (command == ".sym") ~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ if (command.substr(0, 1) == ".") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unknown statement: %s\n", command.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("Unexpected data line: %s\n", line.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ void FpgaConfig::write_ascii(std::ostream &ofs) const ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ debug("## %s\n", __PRETTY_FUNCTION__); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ info("Writing ascii file..\n"); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << ".comment"; ~~~~~~~~~~~~~~~~~~ bool insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (auto ch : this->initblop) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (ch == 0) { ~~~~~~~~~~~~~~ insert_newline = true; ~~~~~~~~~~~~~~~~~~~~~~ } else if (ch == 0xff) { ~~~~~~~~~~~~~~~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } else { ~~~~~~~~ if (insert_newline) ~~~~~~~~~~~~~~~~~~~ ofs << '\n'; ~~~~~~~~~~~~ ofs << ch; ~~~~~~~~~~ insert_newline = false; ~~~~~~~~~~~~~~~~~~~~~~~ } ~ } ~ ofs << stringf("\n.device %s\n", this->device.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (this->warmboot != "enabled") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".warmboot %s\n", this->warmboot.c_str()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // As "nosleep" is an icepack command, we do not write out a ".nosleep" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // section. However, we parse it in read_bits() and notify the user in ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // info. ~~~~~~~~ typedef std::tuple tile_bit_t; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ std::set tile_bits; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int y = 0; y <= this->chip_height()+1; y++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int x = 0; x <= this->chip_width()+1; x++) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ CramIndexConverter cic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cic.tile_type == "corner" || cic.tile_type == "unsupported") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ continue; ~~~~~~~~~ ofs << stringf(".%s_tile %d %d\n", cic.tile_type.c_str(), x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 0; bit_x < cic.tile_width; bit_x++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int cram_bank, cram_x, cram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cic.get_cram_index(bit_x, bit_y, cram_bank, cram_x, cram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tile_bits.insert(tile_bit_t(cram_bank, cram_x, cram_y)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (cram_x > int(this->cram[cram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("cram_x %d (bit %d, %d) larger than bank size %lu\n", cram_x, bit_x, bit_y, this->cram[cram_bank].size()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ if (cram_y > int(this->cram[cram_bank][cram_x].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ ofs << (this->cram[cram_bank][cram_x][cram_y] ? '1' : '0'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ } ~ ofs << '\n'; ~~~~~~~~~~~~ } ~ if (cic.tile_type == "ramb") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { ~ BramIndexConverter bic(this, x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ofs << stringf(".ram_data %d %d\n", x, y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_y = 0; bit_y < 16; bit_y++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for (int bit_x = 256-4; bit_x >= 0; bit_x -= 4) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int value = 0; ~~~~~~~~~~~~~~ for (int i = 0; i < 4; i++) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int bram_bank, bram_x, bram_y; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bic.get_bram_index(bit_x+i, bit_y, bram_bank, bram_x, bram_y); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if (bram_x >= int(this->bram[bram_bank].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ break; ~~~~~~ } ~ if (bram_y >= int(this->bram[bram_bank][bram_x].size())) { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error("bram_y %d higher than loaded bram size %lu\n", bram_y, this->bram[bram_bank][bram_x].size()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ icepack.cc:928:8: note: in expansion of macro 'error' error("bram_y %d higher than loaded bram size %lu\n", bram_y, this->bram[bram_bank][bram_x].size()); ^~~~~ g++ -o icemulti -Wl,-z,relro -Wl,-z,now -Wl,--as-needed icemulti.o -lm -lstdc++ make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' g++ -o icebram -Wl,-z,relro -Wl,-z,now -Wl,--as-needed icebram.o -lm -lstdc++ make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' mv chipdb-384.new chipdb-384.txt g++ -o icepack -Wl,-z,relro -Wl,-z,now -Wl,--as-needed icepack.o -lm -lstdc++ ln -sf icepack iceunpack make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' mv chipdb-1k.new chipdb-1k.txt mv chipdb-lm4k.new chipdb-lm4k.txt mv chipdb-5k.new chipdb-5k.txt mv chipdb-8k.new chipdb-8k.txt make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' In file included from icetime.cc:742: timings.inc: In function 'double get_delay_up5k(std::__cxx11::string, std::__cxx11::string, std::__cxx11::string)': timings.inc:1803:8: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without double get_delay_up5k(std::string cell_type, std::string in_port, std::string out_port) ^~~~~~~~~~~~~~ g++ -o icetime -Wl,-z,relro -Wl,-z,now -Wl,--as-needed icetime.o iceutil.o -lm -lstdc++ make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' make[1]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' dh_auto_test create-stamp debian/debhelper-build-stamp fakeroot debian/rules binary dh binary dh_testroot dh_prep debian/rules override_dh_auto_install make[1]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' PREFIX=/usr dh_auto_install make -j18 install DESTDIR=/build/fpga-icestorm-0\~20181109git9671b76/debian/tmp AM_UPDATE_INFO_DIR=no "INSTALL=install --strip-program=true" make[2]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' for dir in icebox icepack iceprog icemulti icepll icetime icebram; do \ make -C $dir install || exit; \ done make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python cp chipdb-384.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ cp chipdb-1k.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ cp chipdb-8k.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ cp chipdb-5k.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ cp chipdb-lm4k.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ cp icebox.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox.py cp iceboxdb.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/iceboxdb.py cp icebox_chipdb.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_chipdb cp icebox_diff.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_diff cp icebox_explain.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_explain cp icebox_asc2hlc.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_asc2hlc cp icebox_hlc2asc.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_hlc2asc cp icebox_colbuf.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_colbuf cp icebox_html.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_html cp icebox_maps.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_maps cp icebox_vlog.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_vlog cp icebox_stat.py /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/python/icebox_stat make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebox' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin cp icepack /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/icepack ln -sf icepack /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/iceunpack make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepack' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin cp iceprog /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/iceprog make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/iceprog' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin cp icemulti /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/icemulti make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icemulti' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin cp icepll /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/icepll make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icepll' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/icebox cp icetime /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/icetime cp ../icefuzz/timings_*.txt /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/share/fpga-icestorm/chipdb/ make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icetime' make[3]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' mkdir -p /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin cp icebram /build/fpga-icestorm-0~20181109git9671b76/debian/tmp/usr/bin/icebram make[3]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76/icebram' make[2]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' make[1]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' dh_install dh_installdocs dh_installchangelogs debian/rules override_dh_installman make[1]: Entering directory '/build/fpga-icestorm-0~20181109git9671b76' cd debian/man ; CHANGELOG_DATE="20 December 2018" ./genmanpages.sh dh_installman make[1]: Leaving directory '/build/fpga-icestorm-0~20181109git9671b76' dh_perl dh_link dh_strip_nondeterminism dh_compress dh_fixperms dh_missing dh_strip dh_makeshlibs dh_shlibdeps dh_installdeb dh_gencontrol dh_md5sums dh_builddeb dpkg-deb: building package 'fpga-icestorm-chipdb' in '../fpga-icestorm-chipdb_0~20181109git9671b76-1_all.deb'. dpkg-deb: building package 'fpga-icestorm-dbgsym' in '../fpga-icestorm-dbgsym_0~20181109git9671b76-1_i386.deb'. dpkg-deb: building package 'fpga-icestorm' in '../fpga-icestorm_0~20181109git9671b76-1_i386.deb'. dpkg-genbuildinfo --build=binary dpkg-genchanges --build=binary >../fpga-icestorm_0~20181109git9671b76-1_i386.changes dpkg-genchanges: info: binary-only upload (no source code included) dpkg-source --after-build . dpkg-buildpackage: info: binary-only upload (no source included) I: copying local configuration I: unmounting dev/ptmx filesystem I: unmounting dev/pts filesystem I: unmounting dev/shm filesystem I: unmounting proc filesystem I: unmounting sys filesystem I: cleaning the build env I: removing directory /srv/workspace/pbuilder/24223 and its subdirectories I: Current time: Sat Jun 12 07:20:17 -12 2021 I: pbuilder-time-stamp: 1623525617 Sun May 10 12:57:18 UTC 2020 I: 1st build successful. Starting 2nd build on remote node profitbricks-build12-i386.debian.net. Sun May 10 12:57:18 UTC 2020 I: Preparing to do remote build '2' on profitbricks-build12-i386.debian.net. Sun May 10 13:07:18 UTC 2020 I: Deleting $TMPDIR on profitbricks-build12-i386.debian.net. Sun May 10 13:07:19 UTC 2020 I: fpga-icestorm_0~20181109git9671b76-1_i386.changes: Format: 1.8 Date: Thu, 20 Dec 2018 11:09:19 +0100 Source: fpga-icestorm Binary: fpga-icestorm fpga-icestorm-chipdb fpga-icestorm-dbgsym Architecture: all i386 Version: 0~20181109git9671b76-1 Distribution: unstable Urgency: medium Maintainer: Debian Electronics Team Changed-By: Ruben Undheim Description: fpga-icestorm - Tools to handle the bitstream format of Lattice iCE40 FPGAs fpga-icestorm-chipdb - Chip database files for fpga-icestorm Changes: fpga-icestorm (0~20181109git9671b76-1) unstable; urgency=medium . * New upstream GIT HEAD * debian/patches: Refreshed patches Checksums-Sha1: ceffeb18d5b68cb86004b75f44ba6b377ea9338e 6829396 fpga-icestorm-chipdb_0~20181109git9671b76-1_all.deb 505139fe7a45cc794aac9580653591417440c862 2795264 fpga-icestorm-dbgsym_0~20181109git9671b76-1_i386.deb 4d9155cef82ef1b2a9196ef307580b014e3b6c20 5707 fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo 93d2944dfcbdb04010e16b7611a464fd56978f43 406236 fpga-icestorm_0~20181109git9671b76-1_i386.deb Checksums-Sha256: 90f6a6077291d895ebff3f92a72649f5a43bbc9681ce2b7a3d5b8d6e3e970327 6829396 fpga-icestorm-chipdb_0~20181109git9671b76-1_all.deb 6b0f9e83da9304cf466b118d627ea81014155f716a6333ab82f86f64b43bb8ed 2795264 fpga-icestorm-dbgsym_0~20181109git9671b76-1_i386.deb 954b1b8f59056c254efc762d22b5a21016a1f53271296f8b58585aac6966abf6 5707 fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo aa339a4eb11c04846ed04ee598ff30801ccb0f946de439eb673c123bea0c02f0 406236 fpga-icestorm_0~20181109git9671b76-1_i386.deb Files: eb0eb0008352857a53a2ad8f9e9bdccb 6829396 electronics optional fpga-icestorm-chipdb_0~20181109git9671b76-1_all.deb 1f9007d448d327c6f08c791486197f9a 2795264 debug optional fpga-icestorm-dbgsym_0~20181109git9671b76-1_i386.deb 2faf61c2af9052a59d9df868fffeb188 5707 electronics optional fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo 3fccf314cf1fac1d2d0bbe48756e83ba 406236 electronics optional fpga-icestorm_0~20181109git9671b76-1_i386.deb Sun May 10 13:07:20 UTC 2020 I: diffoscope 143 will be used to compare the two builds: # Profiling output for: /usr/bin/diffoscope --html /srv/reproducible-results/rbuild-debian/tmp.WFlqo2B9bG/fpga-icestorm_0~20181109git9671b76-1.diffoscope.html --text /srv/reproducible-results/rbuild-debian/tmp.WFlqo2B9bG/fpga-icestorm_0~20181109git9671b76-1.diffoscope.txt --json /srv/reproducible-results/rbuild-debian/tmp.WFlqo2B9bG/fpga-icestorm_0~20181109git9671b76-1.diffoscope.json --profile=- /srv/reproducible-results/rbuild-debian/tmp.WFlqo2B9bG/b1/fpga-icestorm_0~20181109git9671b76-1_i386.changes /srv/reproducible-results/rbuild-debian/tmp.WFlqo2B9bG/b2/fpga-icestorm_0~20181109git9671b76-1_i386.changes ## command (total time: 0.000s) 0.000s 1 call cmp (internal) ## has_same_content_as (total time: 0.000s) 0.000s 1 call abc.DotChangesFile ## main (total time: 0.619s) 0.619s 2 calls outputs 0.000s 1 call cleanup ## recognizes (total time: 0.144s) 0.144s 10 calls diffoscope.comparators.binary.FilesystemFile Sun May 10 13:07:23 UTC 2020 I: diffoscope 143 found no differences in the changes files, and a .buildinfo file also exists. Sun May 10 13:07:23 UTC 2020 I: fpga-icestorm from buster built successfully and reproducibly on i386. Sun May 10 13:07:25 UTC 2020 I: Submitting .buildinfo files to external archives: Sun May 10 13:07:25 UTC 2020 I: Submitting 8.0K b1/fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo.asc Sun May 10 13:07:26 UTC 2020 I: Submitting 8.0K b2/fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo.asc Sun May 10 13:07:27 UTC 2020 I: Done submitting .buildinfo files to http://buildinfo.debian.net/api/submit. Sun May 10 13:07:27 UTC 2020 I: Done submitting .buildinfo files. Sun May 10 13:07:27 UTC 2020 I: Removing signed fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo.asc files: removed './b1/fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo.asc' removed './b2/fpga-icestorm_0~20181109git9671b76-1_i386.buildinfo.asc'