From c1f750ff9813f0c8a2a789f0f33009e05d12121c Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 1 Nov 2009 15:49:23 +0000 Subject: [PATCH] Fix vvp code generator bug for CA function calls with array word arguments. If a function in a continuous assignment is passed an array word as an argument, syntactically incorrect vvp code is generated. This is because the code calls draw_net_input to generate the input labels part way through writing out the .ufunc statement. If an input is an array word, draw_net_input causes a .array/port statement to be emitted, which gets written out in the middle of the .ufunc statement. This patch fixes the problem by collecting the necessary input labels prior to starting writing the .ufunc statement. (cherry picked from commit 9950704735f3a7e5c40a9245c9cf40f534c83e61) --- tgt-vvp/vvp_scope.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 112ea6337..703571425 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -1607,10 +1607,19 @@ static void draw_lpm_sfunc(ivl_lpm_t net) static void draw_lpm_ufunc(ivl_lpm_t net) { unsigned idx; + unsigned ninp; + const char**input_strings; ivl_scope_t def = ivl_lpm_define(net); const char*dly = draw_lpm_output_delay(net); + /* Get all the input labels that I will use for net signals that + connect to the inputs of the function. */ + ninp = ivl_lpm_size(net); + input_strings = calloc(ninp, sizeof(char*)); + for (idx = 0 ; idx < ninp ; idx += 1) + input_strings[idx] = draw_net_input(ivl_lpm_data(net, idx)); + if (ivl_lpm_trigger(net)) fprintf(vvp_out, "L_%p%s .ufunc/e TD_%s, %u, E_%p", net, dly, vvp_mangle_id(ivl_scope_name(def)), @@ -1622,10 +1631,10 @@ static void draw_lpm_ufunc(ivl_lpm_t net) /* Print all the net signals that connect to the input of the function. */ - for (idx = 0 ; idx < ivl_lpm_size(net) ; idx += 1) { - fprintf(vvp_out, ", %s", draw_net_input(ivl_lpm_data(net, idx))); + for (idx = 0 ; idx < ninp ; idx += 1) { + fprintf(vvp_out, ", %s", input_strings[idx]); } - + free(input_strings); assert((ivl_lpm_size(net)+1) == ivl_scope_ports(def));