diff --git a/tgt-vvp/draw_mux.c b/tgt-vvp/draw_mux.c index 16d793d73..ac729da53 100644 --- a/tgt-vvp/draw_mux.c +++ b/tgt-vvp/draw_mux.c @@ -83,10 +83,14 @@ static void draw_lpm_mux_nest(ivl_lpm_t net, const char*muxz) net, select_input); for (idx = 0 ; idx < ivl_lpm_size(net) ; idx += 2) { + /* draw_net_input() can emit helper statements, for example for + array words. Emit those before starting the .functor line. */ + const char*input0 = draw_net_input(ivl_lpm_data(net,idx+0)); + const char*input1 = draw_net_input(ivl_lpm_data(net,idx+1)); fprintf(vvp_out, "L_%p/0/%u .functor %s %u", net, idx/2, muxz, width); - fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,idx+0))); - fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,idx+1))); + fprintf(vvp_out, ", %s", input0); + fprintf(vvp_out, ", %s", input1); fprintf(vvp_out, ", L_%p/0s, C4<>;\n", net); } diff --git a/tgt-vvp/draw_substitute.c b/tgt-vvp/draw_substitute.c index 22d5c4223..72fd048c1 100644 --- a/tgt-vvp/draw_substitute.c +++ b/tgt-vvp/draw_substitute.c @@ -25,8 +25,13 @@ void draw_lpm_substitute(ivl_lpm_t net) { unsigned swidth = width_of_nexus(ivl_lpm_data(net,1)); + /* draw_net_input() can emit helper statements, for example for + array words. Emit those before starting the .substitute line. */ + const char*input0 = draw_net_input(ivl_lpm_data(net,0)); + const char*input1 = draw_net_input(ivl_lpm_data(net,1)); + fprintf(vvp_out, "L_%p .substitute %u, %u %u", net, ivl_lpm_width(net), ivl_lpm_base(net), swidth); - fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net,0))); - fprintf(vvp_out, ", %s;\n", draw_net_input(ivl_lpm_data(net,1))); + fprintf(vvp_out, ", %s", input0); + fprintf(vvp_out, ", %s;\n", input1); }