aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/bitstream.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ice40/bitstream.cc')
-rw-r--r--ice40/bitstream.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index fa8e444d..ba4a0e8d 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -382,14 +382,15 @@ void write_asc(const Design &design, std::ostream &out)
std::string init = get_param_str_or_def(
cell.second,
std::string("INIT_") + get_hexdigit(w));
+ assert(init != "");
for (int i = 0; i < init.size(); i++) {
bool val = (init.at((init.size() - 1) - i) == '1');
bits.at(i) = val;
}
- for (int i = 0; i < bits.size(); i += 4) {
+ for (int i = bits.size()-4; i >= 0; i -= 4) {
int c = bits.at(i) + (bits.at(i + 1) << 1) +
(bits.at(i + 2) << 2) + (bits.at(i + 3) << 3);
- out << get_hexdigit(c);
+ out << char(std::tolower(get_hexdigit(c)));
}
out << std::endl;
}