3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-03 13:07:58 +00:00

proc_mux: default to case src when action src is missing

This commit is contained in:
Emil J. Tywoniak 2025-11-02 12:41:55 +01:00
parent 0c8e008ce7
commit 26e293d71f

View file

@ -32,7 +32,8 @@ using SnippetSourceMap = dict<std::pair<int, const RTLIL::CaseRule*>, const Cons
struct SnippetSourceMapBuilder {
SnippetSourceMap map;
void insert(int snippet, const RTLIL::CaseRule* cs, const RTLIL::SyncAction& action) {
map[std::make_pair(snippet, cs)] = &action.src;
if (action.src.size())
map[std::make_pair(snippet, cs)] = &action.src;
}
};
@ -42,6 +43,11 @@ struct SnippetSourceMapper {
auto src_it = map.find(std::make_pair(snippet, cs));
if (src_it != map.end()) {
sources.insert(src_it->second->decode_string());
} else {
auto cs_src = cs->get_src_attribute();
if (cs_src.size()) {
sources.insert(cs_src);
}
}
}
@ -168,7 +174,7 @@ struct SnippetSwCache
}
};
void apply_attrs(RTLIL::Cell *cell, const RTLIL::SwitchRule *sw, const RTLIL::CaseRule *cs)
void apply_attrs(RTLIL::Cell *cell, const RTLIL::CaseRule *cs)
{
Const old_src;
if (cell->attributes.count(ID::src)) {
@ -220,7 +226,7 @@ struct MuxGenCtx {
{
// create compare cell
RTLIL::Cell *eq_cell = mod->addCell(stringf("%s_CMP%d", sstr.str(), cmp_wire->width), ifxmode ? ID($eqx) : ID($eq));
apply_attrs(eq_cell, sw, cs);
apply_attrs(eq_cell, cs);
eq_cell->parameters[ID::A_SIGNED] = RTLIL::Const(0);
eq_cell->parameters[ID::B_SIGNED] = RTLIL::Const(0);
@ -246,7 +252,7 @@ struct MuxGenCtx {
// reduce cmp vector to one logic signal
RTLIL::Cell *any_cell = mod->addCell(sstr.str() + "_ANY", ID($reduce_or));
apply_attrs(any_cell, sw, cs);
apply_attrs(any_cell, cs);
any_cell->parameters[ID::A_SIGNED] = RTLIL::Const(0);
any_cell->parameters[ID::A_WIDTH] = RTLIL::Const(cmp_wire->width);
@ -280,7 +286,6 @@ struct MuxGenCtx {
// create the multiplexer itself
RTLIL::Cell *mux_cell = mod->addCell(sstr.str(), ID($mux));
apply_attrs(mux_cell, sw, cs);
mux_cell->parameters[ID::WIDTH] = RTLIL::Const(when_signal.size());
mux_cell->setPort(ID::A, else_signal);