From f079e0d204117b53a91da2805d31136607a5ca0e Mon Sep 17 00:00:00 2001 From: David Shah Date: Sat, 16 Jun 2018 12:17:36 +0200 Subject: ice40: Fix BRAM initialisation Signed-off-by: David Shah --- ice40/bitstream.cc | 5 +++-- ice40/pack.cc | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ice40') 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; } diff --git a/ice40/pack.cc b/ice40/pack.cc index f4c024da..b9a9fe6d 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -129,8 +129,7 @@ static void pack_ram(Design *design) ci->name.str() + "_RAM"); packed_cells.insert(ci->name); new_cells.push_back(packed); - packed->params["READ_MODE"] = ci->params.at("READ_MODE"); - packed->params["WRITE_MODE"] = ci->params.at("WRITE_MODE"); + std::copy(ci->params.begin(), ci->params.end(), std::inserter(packed->params, packed->params.begin())); packed->params["NEG_CLK_W"] = std::to_string(ci->type == "SB_RAM40_4KNW" || ci->type == "SB_RAM40_4KNRNW"); -- cgit v1.2.3