diff options
author | Clifford Wolf <clifford@clifford.at> | 2015-07-31 10:40:09 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2015-07-31 10:40:09 +0200 |
commit | 8d6d5c30d9f39ce5b15d1bd3f3a528b38f2f9f9c (patch) | |
tree | 8bfd4d9dba657a0c461220838fbf919f45d236b3 /passes/memory | |
parent | 3860c9a9f23104bd54e0000b74624e45c77a8ab3 (diff) | |
download | yosys-8d6d5c30d9f39ce5b15d1bd3f3a528b38f2f9f9c.tar.gz yosys-8d6d5c30d9f39ce5b15d1bd3f3a528b38f2f9f9c.tar.bz2 yosys-8d6d5c30d9f39ce5b15d1bd3f3a528b38f2f9f9c.zip |
Added WORDS parameter to $meminit
Diffstat (limited to 'passes/memory')
-rw-r--r-- | passes/memory/memory_unpack.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/passes/memory/memory_unpack.cc b/passes/memory/memory_unpack.cc index c07c4b60c..07ec4564c 100644 --- a/passes/memory/memory_unpack.cc +++ b/passes/memory/memory_unpack.cc @@ -77,6 +77,10 @@ void handle_memory(RTLIL::Module *module, RTLIL::Cell *memory) } Const initval = memory->parameters.at("\\INIT"); + RTLIL::Cell *last_init_cell = nullptr; + SigSpec last_init_data; + int last_init_addr; + for (int i = 0; i < GetSize(initval) && i/mem->width < (1 << abits); i += mem->width) { Const val = initval.extract(i, mem->width, State::Sx); for (auto bit : val.bits) @@ -84,15 +88,29 @@ void handle_memory(RTLIL::Module *module, RTLIL::Cell *memory) goto found_non_undef_initval; continue; found_non_undef_initval: - RTLIL::Cell *cell = module->addCell(NEW_ID, "$meminit"); - cell->parameters["\\MEMID"] = mem_name.str(); - cell->parameters["\\ABITS"] = memory->parameters.at("\\ABITS"); - cell->parameters["\\WIDTH"] = memory->parameters.at("\\WIDTH"); - cell->parameters["\\PRIORITY"] = i/mem->width; - cell->setPort("\\ADDR", SigSpec(i/mem->width, abits)); - cell->setPort("\\DATA", val); + if (last_init_cell && last_init_addr+1 == i/mem->width) { + last_init_cell->parameters["\\WORDS"] = last_init_cell->parameters["\\WORDS"].as_int() + 1; + last_init_data.append(val); + last_init_addr++; + } else { + if (last_init_cell) + last_init_cell->setPort("\\DATA", last_init_data); + RTLIL::Cell *cell = module->addCell(NEW_ID, "$meminit"); + cell->parameters["\\MEMID"] = mem_name.str(); + cell->parameters["\\ABITS"] = memory->parameters.at("\\ABITS"); + cell->parameters["\\WIDTH"] = memory->parameters.at("\\WIDTH"); + cell->parameters["\\WORDS"] = 1; + cell->parameters["\\PRIORITY"] = i/mem->width; + cell->setPort("\\ADDR", SigSpec(i/mem->width, abits)); + last_init_cell = cell; + last_init_addr = i/mem->width; + last_init_data = val; + } } + if (last_init_cell) + last_init_cell->setPort("\\DATA", last_init_data); + module->remove(memory); } |