aboutsummaryrefslogtreecommitdiffstats
path: root/passes
diff options
context:
space:
mode:
authorMiodrag Milanović <mmicko@gmail.com>2022-05-09 09:28:09 +0200
committerGitHub <noreply@github.com>2022-05-09 09:28:09 +0200
commit58b23954e89a75e726d98716d5029f148c804073 (patch)
tree7462e655ef0c7e5321b494ca17096c3aeffaf899 /passes
parent600079e281d1dcf295c1c97616109b5ea5f3d34d (diff)
parentd8adbff72f6648589d7699857ee8c65a80315033 (diff)
downloadyosys-58b23954e89a75e726d98716d5029f148c804073.tar.gz
yosys-58b23954e89a75e726d98716d5029f148c804073.tar.bz2
yosys-58b23954e89a75e726d98716d5029f148c804073.zip
Merge pull request #3299 from YosysHQ/mmicko/sim_memory
sim pass: support for memories
Diffstat (limited to 'passes')
-rw-r--r--passes/sat/sim.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/passes/sat/sim.cc b/passes/sat/sim.cc
index 7b52b85cd..d085fab2d 100644
--- a/passes/sat/sim.cc
+++ b/passes/sat/sim.cc
@@ -157,6 +157,7 @@ struct SimInstance
dict<Wire*, pair<int, Const>> signal_database;
dict<Wire*, fstHandle> fst_handles;
+ dict<IdString, dict<int,fstHandle>> fst_memories;
SimInstance(SimShared *shared, std::string scope, Module *module, Cell *instance = nullptr, SimInstance *parent = nullptr) :
shared(shared), scope(scope), module(module), instance(instance), parent(parent), sigmap(module)
@@ -243,7 +244,10 @@ struct SimInstance
if (cell->is_mem_cell())
{
- mem_cells[cell] = cell->parameters.at(ID::MEMID).decode_string();
+ std::string name = cell->parameters.at(ID::MEMID).decode_string();
+ mem_cells[cell] = name;
+ if (shared->fst)
+ fst_memories[name] = shared->fst->getMemoryHandles(scope + "." + RTLIL::unescape_id(name));
}
if (cell->type.in(ID($assert), ID($cover), ID($assume))) {
formal_database.insert(cell);
@@ -336,7 +340,7 @@ struct SimInstance
int offset = (addr.as_int() - state.mem->start_offset) * state.mem->width;
for (int i = 0; i < GetSize(data); i++)
- if (0 <= i+offset && i+offset < GetSize(data))
+ if (0 <= i+offset && i+offset < state.mem->size * state.mem->width)
state.data.bits[i+offset] = data.bits[i];
}
@@ -799,6 +803,18 @@ struct SimInstance
did_something |= true;
}
}
+ for (auto cell : module->cells())
+ {
+ if (cell->is_mem_cell()) {
+ std::string memid = cell->parameters.at(ID::MEMID).decode_string();
+ for (auto &data : fst_memories[memid])
+ {
+ std::string v = shared->fst->valueOf(data.second);
+ set_memory_state(memid, Const(data.first), Const::from_string(v));
+ }
+ }
+ }
+
for (auto child : children)
did_something |= child.second->setInitState();
return did_something;