ice40: Fix BRAM initialisation

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-16 12:17:36 +02:00
parent c0a2627179
commit f079e0d204
2 changed files with 4 additions and 4 deletions

View File

@ -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;
}

View File

@ -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");