@@ -616,20 +616,22 @@ void verilog_synthesist::assignment_rec(
616616 exprt new_rhs (rhs), new_value;
617617 assignment_rec (lhs, new_rhs, new_value); // start of recursion
618618
619- // These can explode if the symbol is assigned more than once
620- // and also used more than once, e.g., in a multi-dimensional array.
621- // We add a fresh symbol for anything that is not trivial
622- // to prevent that.
623- if (new_value.id ()!=ID_symbol &&
624- new_value.id ()!=ID_constant)
619+ if (new_value.is_not_nil ())
625620 {
626- replace_by_wire (new_value, symbol);
627- }
621+ // These can explode if the symbol is assigned more than once
622+ // and also used more than once, e.g., in a multi-dimensional array.
623+ // We add a fresh symbol for anything that is not trivial
624+ // to prevent that.
625+ if (new_value.id () != ID_symbol && new_value.id () != ID_constant)
626+ {
627+ replace_by_wire (new_value, symbol);
628+ }
628629
629- if (blocking)
630- value_map->current .assign (symbol.name , new_value);
630+ if (blocking)
631+ value_map->current .assign (symbol.name , new_value);
631632
632- value_map->final .assign (symbol.name , new_value);
633+ value_map->final .assign (symbol.name , new_value);
634+ }
633635 }
634636}
635637
@@ -926,6 +928,8 @@ void verilog_synthesist::replace_by_wire(
926928 exprt &what,
927929 const symbolt &base)
928930{
931+ PRECONDITION (what.is_not_nil ());
932+
929933 symbolt new_symbol;
930934
931935 do
@@ -935,7 +939,7 @@ void verilog_synthesist::replace_by_wire(
935939 new_symbol.base_name =id2string (base.base_name )+" _aux" +std::to_string (c);
936940 }
937941 while (symbol_table.symbols .find (new_symbol.name )!=symbol_table.symbols .end ());
938-
942+
939943 new_symbol.type =what.type ();
940944 new_symbol.module =base.module ;
941945 new_symbol.mode =base.mode ;
@@ -3358,7 +3362,9 @@ void verilog_synthesist::synth_assignments(
33583362
33593363 // see if wire is used to define itself
33603364 if (!symbol.is_state_var )
3365+ {
33613366 post_process_wire (symbol.name , new_value);
3367+ }
33623368
33633369 auto lhs = symbol_expr (symbol, curr_or_next);
33643370
@@ -3430,6 +3436,9 @@ void verilog_synthesist::synth_assignments(transt &trans)
34303436 symbolt &symbol=symbol_table_lookup (it);
34313437 assignmentt &assignment=assignments[symbol.name ];
34323438
3439+ DATA_INVARIANT (
3440+ assignment.next .value .is_not_nil (), " must have assignment value" );
3441+
34333442 synth_assignments (symbol, CURRENT,
34343443 assignment.next .value ,
34353444 trans.invar ());
0 commit comments