3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-07 09:55:20 +00:00

pmux2shift: Refactor to use FfInitVals.

This commit is contained in:
Marcelina Kościelnicka 2020-07-19 02:19:38 +02:00
parent 4d9105ccb0
commit 31d6107521

View file

@ -19,6 +19,7 @@
#include "kernel/yosys.h" #include "kernel/yosys.h"
#include "kernel/sigtools.h" #include "kernel/sigtools.h"
#include "kernel/ffinit.h"
USING_YOSYS_NAMESPACE USING_YOSYS_NAMESPACE
PRIVATE_NAMESPACE_BEGIN PRIVATE_NAMESPACE_BEGIN
@ -30,7 +31,7 @@ struct OnehotDatabase
bool verbose = false; bool verbose = false;
bool initialized = false; bool initialized = false;
pool<SigBit> init_ones; FfInitVals initvals;
dict<SigSpec, pool<SigSpec>> sig_sources_db; dict<SigSpec, pool<SigSpec>> sig_sources_db;
dict<SigSpec, bool> sig_onehot_cache; dict<SigSpec, bool> sig_onehot_cache;
pool<SigSpec> recursion_guard; pool<SigSpec> recursion_guard;
@ -44,19 +45,7 @@ struct OnehotDatabase
log_assert(!initialized); log_assert(!initialized);
initialized = true; initialized = true;
for (auto wire : module->wires()) initvals.set(&sigmap, module);
{
auto it = wire->attributes.find(ID::init);
if (it == wire->attributes.end())
continue;
auto &val = it->second;
int width = std::max(GetSize(wire), GetSize(val));
for (int i = 0; i < width; i++)
if (val[i] == State::S1)
init_ones.insert(sigmap(SigBit(wire, i)));
}
for (auto cell : module->cells()) for (auto cell : module->cells())
{ {
@ -119,7 +108,7 @@ struct OnehotDatabase
bool found_init_ones = false; bool found_init_ones = false;
for (auto bit : sig) { for (auto bit : sig) {
if (init_ones.count(bit)) { if (initvals(bit) == State::S1) {
if (found_init_ones) { if (found_init_ones) {
if (verbose) if (verbose)
log("%*s - non-onehot init value\n", indent, ""); log("%*s - non-onehot init value\n", indent, "");