mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
SigSpec refactoring: cleanup of old SigSpec usage in fsm_* commands
This commit is contained in:
parent
65a939cb27
commit
4a6d234ec7
|
@ -43,11 +43,9 @@ static bool find_states(RTLIL::SigSpec sig, const RTLIL::SigSpec &dff_out, RTLIL
|
||||||
|
|
||||||
assign_map.apply(sig);
|
assign_map.apply(sig);
|
||||||
if (sig.is_fully_const()) {
|
if (sig.is_fully_const()) {
|
||||||
sig.optimize();
|
if (states.count(sig.as_const()) == 0) {
|
||||||
assert(sig.chunks().size() == 1);
|
|
||||||
if (states.count(sig.chunks()[0].data) == 0) {
|
|
||||||
log(" found state code: %s\n", log_signal(sig));
|
log(" found state code: %s\n", log_signal(sig));
|
||||||
states[sig.chunks()[0].data] = -1;
|
states[sig.as_const()] = -1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,30 +89,19 @@ static bool find_states(RTLIL::SigSpec sig, const RTLIL::SigSpec &dff_out, RTLIL
|
||||||
static RTLIL::Const sig2const(ConstEval &ce, RTLIL::SigSpec sig, RTLIL::State noconst_state, RTLIL::SigSpec dont_care = RTLIL::SigSpec())
|
static RTLIL::Const sig2const(ConstEval &ce, RTLIL::SigSpec sig, RTLIL::State noconst_state, RTLIL::SigSpec dont_care = RTLIL::SigSpec())
|
||||||
{
|
{
|
||||||
if (dont_care.size() > 0) {
|
if (dont_care.size() > 0) {
|
||||||
sig.expand();
|
for (int i = 0; i < SIZE(sig); i++)
|
||||||
for (auto &chunk : sig.chunks_rw()) {
|
if (dont_care.extract(sig[i]).size() > 0)
|
||||||
assert(chunk.width == 1);
|
sig[i] = noconst_state;
|
||||||
if (dont_care.extract(chunk).size() > 0)
|
|
||||||
chunk.wire = NULL, chunk.data = RTLIL::Const(noconst_state);
|
|
||||||
}
|
|
||||||
sig.optimize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ce.assign_map.apply(sig);
|
ce.assign_map.apply(sig);
|
||||||
ce.values_map.apply(sig);
|
ce.values_map.apply(sig);
|
||||||
|
|
||||||
sig.expand();
|
for (int i = 0; i < SIZE(sig); i++)
|
||||||
for (auto &chunk : sig.chunks_rw()) {
|
if (sig[i].wire != NULL)
|
||||||
assert(chunk.width == 1);
|
sig[i] = noconst_state;
|
||||||
if (chunk.wire != NULL)
|
|
||||||
chunk.wire = NULL, chunk.data = RTLIL::Const(noconst_state);
|
|
||||||
}
|
|
||||||
sig.optimize();
|
|
||||||
|
|
||||||
if (sig.size() == 0)
|
return sig.as_const();
|
||||||
return RTLIL::Const();
|
|
||||||
assert(sig.chunks().size() == 1 && sig.chunks()[0].wire == NULL);
|
|
||||||
return sig.chunks()[0].data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void find_transitions(ConstEval &ce, ConstEval &ce_nostop, FsmData &fsm_data, std::map<RTLIL::Const, int> &states, int state_in, RTLIL::SigSpec ctrl_in, RTLIL::SigSpec ctrl_out, RTLIL::SigSpec dff_in, RTLIL::SigSpec dont_care)
|
static void find_transitions(ConstEval &ce, ConstEval &ce_nostop, FsmData &fsm_data, std::map<RTLIL::Const, int> &states, int state_in, RTLIL::SigSpec ctrl_in, RTLIL::SigSpec ctrl_out, RTLIL::SigSpec dff_in, RTLIL::SigSpec dont_care)
|
||||||
|
|
|
@ -33,18 +33,14 @@ struct FsmOpt
|
||||||
|
|
||||||
bool signal_is_unused(RTLIL::SigSpec sig)
|
bool signal_is_unused(RTLIL::SigSpec sig)
|
||||||
{
|
{
|
||||||
assert(sig.size() == 1);
|
RTLIL::SigBit bit = sig.to_single_sigbit();
|
||||||
sig.optimize();
|
|
||||||
|
|
||||||
RTLIL::Wire *wire = sig.chunks()[0].wire;
|
if (bit.wire == NULL || bit.wire->attributes.count("\\unused_bits") == 0)
|
||||||
int bit = sig.chunks()[0].offset;
|
|
||||||
|
|
||||||
if (!wire || wire->attributes.count("\\unused_bits") == 0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
char *str = strdup(wire->attributes["\\unused_bits"].decode_string().c_str());
|
char *str = strdup(bit.wire->attributes["\\unused_bits"].decode_string().c_str());
|
||||||
for (char *tok = strtok(str, " "); tok != NULL; tok = strtok(NULL, " ")) {
|
for (char *tok = strtok(str, " "); tok != NULL; tok = strtok(NULL, " ")) {
|
||||||
if (tok[0] && bit == atoi(tok)) {
|
if (tok[0] && bit.offset == atoi(tok)) {
|
||||||
free(str);
|
free(str);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,26 +142,24 @@ struct FsmData
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" Input signals:\n");
|
log(" Input signals:\n");
|
||||||
RTLIL::SigSpec sig_in = cell->connections["\\CTRL_IN"];
|
RTLIL::SigSpec sig_in = cell->connections["\\CTRL_IN"];
|
||||||
sig_in.expand();
|
for (int i = 0; i < SIZE(sig_in); i++)
|
||||||
for (size_t i = 0; i < sig_in.chunks().size(); i++)
|
log(" %3zd: %s\n", i, log_signal(sig_in[i]));
|
||||||
log(" %3zd: %s\n", i, log_signal(sig_in.chunks()[i]));
|
|
||||||
|
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" Output signals:\n");
|
log(" Output signals:\n");
|
||||||
RTLIL::SigSpec sig_out = cell->connections["\\CTRL_OUT"];
|
RTLIL::SigSpec sig_out = cell->connections["\\CTRL_OUT"];
|
||||||
sig_out.expand();
|
for (int i = 0; i < SIZE(sig_out); i++)
|
||||||
for (size_t i = 0; i < sig_out.chunks().size(); i++)
|
log(" %3zd: %s\n", i, log_signal(sig_out[i]));
|
||||||
log(" %3zd: %s\n", i, log_signal(sig_out.chunks()[i]));
|
|
||||||
|
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" State encoding:\n");
|
log(" State encoding:\n");
|
||||||
for (size_t i = 0; i < state_table.size(); i++)
|
for (int i = 0; i < SIZE(state_table); i++)
|
||||||
log(" %3zd: %10s%s\n", i, log_signal(state_table[i], false),
|
log(" %3zd: %10s%s\n", i, log_signal(state_table[i], false),
|
||||||
int(i) == reset_state ? " <RESET STATE>" : "");
|
int(i) == reset_state ? " <RESET STATE>" : "");
|
||||||
|
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" Transition Table (state_in, ctrl_in, state_out, ctrl_out):\n");
|
log(" Transition Table (state_in, ctrl_in, state_out, ctrl_out):\n");
|
||||||
for (size_t i = 0; i < transition_table.size(); i++) {
|
for (int i = 0; i < SIZE(transition_table); i++) {
|
||||||
transition_t &tr = transition_table[i];
|
transition_t &tr = transition_table[i];
|
||||||
log(" %5zd: %5d %s -> %5d %s\n", i, tr.state_in, log_signal(tr.ctrl_in), tr.state_out, log_signal(tr.ctrl_out));
|
log(" %5zd: %5d %s -> %5d %s\n", i, tr.state_in, log_signal(tr.ctrl_in), tr.state_out, log_signal(tr.ctrl_out));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue