@@ -32,7 +32,8 @@ using SnippetSourceMap = dict<std::pair<int, const RTLIL::CaseRule*>, const Cons
3232struct SnippetSourceMapBuilder {
3333 SnippetSourceMap map;
3434 void insert (int snippet, const RTLIL::CaseRule* cs, const RTLIL::SyncAction& action) {
35- map[std::make_pair (snippet, cs)] = &action.src ;
35+ if (action.src .size ())
36+ map[std::make_pair (snippet, cs)] = &action.src ;
3637 }
3738
3839};
@@ -42,6 +43,11 @@ struct SnippetSourceMapper {
4243 auto src_it = map.find (std::make_pair (snippet, cs));
4344 if (src_it != map.end ()) {
4445 sources.insert (src_it->second ->decode_string ());
46+ } else {
47+ auto cs_src = cs->get_src_attribute ();
48+ if (cs_src.size ()) {
49+ sources.insert (cs_src);
50+ }
4551 }
4652 }
4753
@@ -168,7 +174,7 @@ struct SnippetSwCache
168174 }
169175};
170176
171- void apply_attrs (RTLIL::Cell *cell, const RTLIL::SwitchRule *sw, const RTLIL:: CaseRule *cs)
177+ void apply_attrs (RTLIL::Cell *cell, const RTLIL::CaseRule *cs)
172178{
173179 Const old_src;
174180 if (cell->attributes .count (ID::src)) {
@@ -220,7 +226,7 @@ struct MuxGenCtx {
220226 {
221227 // create compare cell
222228 RTLIL::Cell *eq_cell = mod->addCell (stringf (" %s_CMP%d" , sstr.str (), cmp_wire->width ), ifxmode ? ID ($eqx) : ID ($eq));
223- apply_attrs (eq_cell, sw, cs);
229+ apply_attrs (eq_cell, cs);
224230
225231 eq_cell->parameters [ID::A_SIGNED] = RTLIL::Const (0 );
226232 eq_cell->parameters [ID::B_SIGNED] = RTLIL::Const (0 );
@@ -246,7 +252,7 @@ struct MuxGenCtx {
246252
247253 // reduce cmp vector to one logic signal
248254 RTLIL::Cell *any_cell = mod->addCell (sstr.str () + " _ANY" , ID ($reduce_or));
249- apply_attrs (any_cell, sw, cs);
255+ apply_attrs (any_cell, cs);
250256
251257 any_cell->parameters [ID::A_SIGNED] = RTLIL::Const (0 );
252258 any_cell->parameters [ID::A_WIDTH] = RTLIL::Const (cmp_wire->width );
@@ -280,7 +286,6 @@ struct MuxGenCtx {
280286
281287 // create the multiplexer itself
282288 RTLIL::Cell *mux_cell = mod->addCell (sstr.str (), ID ($mux));
283- apply_attrs (mux_cell, sw, cs);
284289
285290 mux_cell->parameters [ID::WIDTH] = RTLIL::Const (when_signal.size ());
286291 mux_cell->setPort (ID::A, else_signal);
0 commit comments