@@ -573,9 +573,8 @@ exprt verilog_synthesist::expand_function_call(const function_call_exprt &call)
573573 for (unsigned i=0 ; i<parameters.size (); i++)
574574 {
575575 const symbolt &a_symbol=ns.lookup (parameters[i].get_identifier ());
576- verilog_blocking_assignt assignment;
577- assignment.lhs () = a_symbol.symbol_expr ().with_source_location (call);
578- assignment.rhs ()=actuals[i];
576+ verilog_blocking_assignt assignment{
577+ a_symbol.symbol_expr ().with_source_location (call), actuals[i]};
579578 assignment.add_source_location ()=call.source_location ();
580579 synth_statement (assignment);
581580 }
@@ -2266,33 +2265,60 @@ Function: verilog_synthesist::synth_assign
22662265
22672266\*******************************************************************/
22682267
2269- void verilog_synthesist::synth_assign (
2270- const verilog_statementt &statement,
2271- bool blocking)
2268+ void verilog_synthesist::synth_assign (const verilog_assignt &statement)
22722269{
2273- if (statement.operands ().size ()!=2 )
2274- {
2275- throw errort ().with_location (statement.source_location ())
2276- << " assign statement expected to have two operands" ;
2277- }
2278-
22792270 if (construct == constructt::OTHER)
22802271 {
22812272 throw errort ().with_location (statement.source_location ())
22822273 << " unexpected assignment statement" ;
22832274 }
22842275
2285- const exprt &lhs = to_binary_expr ( statement). op0 ();
2286- exprt rhs = to_binary_expr ( statement). op1 ();
2276+ const exprt &lhs = statement. lhs ();
2277+ exprt rhs = statement. rhs ();
22872278
22882279 rhs = synth_expr (rhs, symbol_statet::CURRENT);
22892280
2281+ irep_idt compound_id = irep_idt{};
2282+
2283+ if (statement.id () == ID_verilog_blocking_assign_plus)
2284+ compound_id = ID_plus;
2285+ else if (statement.id () == ID_verilog_blocking_assign_minus)
2286+ compound_id = ID_minus;
2287+ else if (statement.id () == ID_verilog_blocking_assign_mult)
2288+ compound_id = ID_mult;
2289+ else if (statement.id () == ID_verilog_blocking_assign_div)
2290+ compound_id = ID_div;
2291+ else if (statement.id () == ID_verilog_blocking_assign_mod)
2292+ compound_id = ID_mod;
2293+ else if (statement.id () == ID_verilog_blocking_assign_bitand)
2294+ compound_id = ID_bitand;
2295+ else if (statement.id () == ID_verilog_blocking_assign_bitor)
2296+ compound_id = ID_bitor;
2297+ else if (statement.id () == ID_verilog_blocking_assign_bitxor)
2298+ compound_id = ID_bitxor;
2299+ else if (statement.id () == ID_verilog_blocking_assign_lshr)
2300+ compound_id = ID_lshr;
2301+ else if (statement.id () == ID_verilog_blocking_assign_lshl)
2302+ compound_id = ID_shl;
2303+ else if (statement.id () == ID_verilog_blocking_assign_ashr)
2304+ compound_id = ID_ashr;
2305+ else if (statement.id () == ID_verilog_blocking_assign_ashl)
2306+ compound_id = ID_shl;
2307+
2308+ if (compound_id != irep_idt{})
2309+ {
2310+ auto lhs_synth = synth_expr (lhs, symbol_statet::CURRENT);
2311+ rhs = binary_exprt{std::move (lhs_synth), compound_id, rhs, rhs.type ()};
2312+ }
2313+
22902314 // Can the rhs be simplified to a constant, for propagation?
22912315 auto rhs_simplified = simplify_expr (rhs, ns);
22922316
22932317 if (rhs_simplified.is_constant ())
22942318 rhs = rhs_simplified;
22952319
2320+ bool blocking = statement.id () != ID_verilog_non_blocking_assign;
2321+
22962322 assignment_rec (lhs, rhs, blocking);
22972323}
22982324
@@ -2961,19 +2987,19 @@ void verilog_synthesist::synth_prepostincdec(const verilog_statementt &statement
29612987 // stupid implementation
29622988 exprt one = from_integer (1 , op.type ());
29632989
2964- bool increment=
2965- statement.id ()==ID_preincrement ||
2966- statement.id ()==ID_postincrement;
2967-
2968- verilog_blocking_assignt assignment;
2969- assignment.lhs () = op;
2990+ bool increment =
2991+ statement.id () == ID_preincrement || statement.id () == ID_postincrement;
2992+
2993+ exprt rhs;
29702994
29712995 if (increment)
2972- assignment. rhs () = plus_exprt (op, one);
2996+ rhs = plus_exprt (op, one);
29732997 else
2974- assignment. rhs () = minus_exprt (op, one);
2998+ rhs = minus_exprt (op, one);
29752999
3000+ verilog_blocking_assignt assignment{op, rhs};
29763001 assignment.add_source_location ()=statement.source_location ();
3002+
29773003 synth_statement (assignment);
29783004}
29793005
@@ -3126,9 +3152,7 @@ void verilog_synthesist::synth_function_call_or_task_enable(
31263152 const symbolt &a_symbol=ns.lookup (parameters[i].get_identifier ());
31273153 if (parameters[i].get_bool (ID_input))
31283154 {
3129- verilog_blocking_assignt assignment;
3130- assignment.lhs ()=a_symbol.symbol_expr ();
3131- assignment.rhs ()=actuals[i];
3155+ verilog_blocking_assignt assignment{a_symbol.symbol_expr (), actuals[i]};
31323156 assignment.add_source_location ()=statement.source_location ();
31333157 synth_statement (assignment);
31343158 }
@@ -3142,9 +3166,7 @@ void verilog_synthesist::synth_function_call_or_task_enable(
31423166 const symbolt &a_symbol=ns.lookup (parameters[i].get_identifier ());
31433167 if (parameters[i].get_bool (ID_output))
31443168 {
3145- verilog_blocking_assignt assignment;
3146- assignment.lhs ()=actuals[i];
3147- assignment.rhs ()=a_symbol.symbol_expr ();
3169+ verilog_blocking_assignt assignment{actuals[i], a_symbol.symbol_expr ()};
31483170 assignment.add_source_location ()=statement.source_location ();
31493171 synth_statement (assignment);
31503172 }
@@ -3173,8 +3195,23 @@ void verilog_synthesist::synth_statement(
31733195 statement.id ()==ID_casex ||
31743196 statement.id ()==ID_casez)
31753197 synth_case (statement);
3176- else if (statement.id ()==ID_blocking_assign)
3177- synth_assign (statement, true );
3198+ else if (
3199+ statement.id () == ID_verilog_blocking_assign ||
3200+ statement.id () == ID_verilog_blocking_assign_plus ||
3201+ statement.id () == ID_verilog_blocking_assign_minus ||
3202+ statement.id () == ID_verilog_blocking_assign_mult ||
3203+ statement.id () == ID_verilog_blocking_assign_div ||
3204+ statement.id () == ID_verilog_blocking_assign_mod ||
3205+ statement.id () == ID_verilog_blocking_assign_bitand ||
3206+ statement.id () == ID_verilog_blocking_assign_bitor ||
3207+ statement.id () == ID_verilog_blocking_assign_bitxor ||
3208+ statement.id () == ID_verilog_blocking_assign_lshr ||
3209+ statement.id () == ID_verilog_blocking_assign_lshl ||
3210+ statement.id () == ID_verilog_blocking_assign_ashr ||
3211+ statement.id () == ID_verilog_blocking_assign_ashl)
3212+ {
3213+ synth_assign (to_verilog_assign (statement));
3214+ }
31783215 else if (statement.id () == ID_procedural_continuous_assign)
31793216 {
31803217 throw errort ().with_location (statement.source_location ())
@@ -3202,8 +3239,8 @@ void verilog_synthesist::synth_statement(
32023239 throw errort ().with_location (statement.source_location ())
32033240 << " synthesis of expect property not supported" ;
32043241 }
3205- else if (statement.id ()==ID_non_blocking_assign )
3206- synth_assign (statement, false );
3242+ else if (statement.id () == ID_verilog_non_blocking_assign )
3243+ synth_assign (to_verilog_assign ( statement) );
32073244 else if (statement.id ()==ID_force)
32083245 synth_force (to_verilog_force (statement));
32093246 else if (statement.id ()==ID_if)
0 commit comments