diff options
author | Claire Wolf <clifford@clifford.at> | 2020-05-14 18:45:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 18:45:13 +0200 |
commit | f02e20907e5d0f343c83ed1a762a39299105167e (patch) | |
tree | 6ef468b7dd97fbe7eb4af4794ac3cc2e5670b3a8 /frontends/verific/verific.cc | |
parent | 140e9a8e06284fcee0ed91661a794b960b5ec5ec (diff) | |
parent | 173aa27ca5ef6e7c0a9277e8da7765adcd63bfe9 (diff) | |
download | yosys-f02e20907e5d0f343c83ed1a762a39299105167e.tar.gz yosys-f02e20907e5d0f343c83ed1a762a39299105167e.tar.bz2 yosys-f02e20907e5d0f343c83ed1a762a39299105167e.zip |
Merge pull request #2052 from YosysHQ/claire/verific_memfix
Add support for non-power-of-two mem chunks in verific importer
Diffstat (limited to 'frontends/verific/verific.cc')
-rw-r--r-- | frontends/verific/verific.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/frontends/verific/verific.cc b/frontends/verific/verific.cc index fe4bda68e..5f8a78e48 100644 --- a/frontends/verific/verific.cc +++ b/frontends/verific/verific.cc @@ -1265,7 +1265,7 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::se int numchunks = int(inst->OutputSize()) / memory->width; int chunksbits = ceil_log2(numchunks); - if ((numchunks * memory->width) != int(inst->OutputSize()) || (numchunks & (numchunks - 1)) != 0) + if ((numchunks * memory->width) != int(inst->OutputSize())) log_error("Import of asymmetric memories of this type is not supported yet: %s %s\n", inst->Name(), inst->GetInput()->Name()); for (int i = 0; i < numchunks; i++) @@ -1273,6 +1273,11 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::se RTLIL::SigSpec addr = {operatorInput1(inst), RTLIL::Const(i, chunksbits)}; RTLIL::SigSpec data = operatorOutput(inst).extract(i * memory->width, memory->width); + if ((numchunks & (numchunks - 1)) != 0) { + addr = module->Mul(NEW_ID, operatorInput1(inst), RTLIL::Const(numchunks)); + addr = module->Add(NEW_ID, addr, RTLIL::Const(i)); + } + RTLIL::Cell *cell = module->addCell(numchunks == 1 ? inst_name : RTLIL::IdString(stringf("%s_%d", inst_name.c_str(), i)), ID($memrd)); cell->parameters[ID::MEMID] = memory->name.str(); @@ -1295,7 +1300,7 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::se int numchunks = int(inst->Input2Size()) / memory->width; int chunksbits = ceil_log2(numchunks); - if ((numchunks * memory->width) != int(inst->Input2Size()) || (numchunks & (numchunks - 1)) != 0) + if ((numchunks * memory->width) != int(inst->Input2Size())) log_error("Import of asymmetric memories of this type is not supported yet: %s %s\n", inst->Name(), inst->GetOutput()->Name()); for (int i = 0; i < numchunks; i++) @@ -1303,6 +1308,11 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::se RTLIL::SigSpec addr = {operatorInput1(inst), RTLIL::Const(i, chunksbits)}; RTLIL::SigSpec data = operatorInput2(inst).extract(i * memory->width, memory->width); + if ((numchunks & (numchunks - 1)) != 0) { + addr = module->Mul(NEW_ID, operatorInput1(inst), RTLIL::Const(numchunks)); + addr = module->Add(NEW_ID, addr, RTLIL::Const(i)); + } + RTLIL::Cell *cell = module->addCell(numchunks == 1 ? inst_name : RTLIL::IdString(stringf("%s_%d", inst_name.c_str(), i)), ID($memwr)); cell->parameters[ID::MEMID] = memory->name.str(); |