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 9950704735)
This commit is contained in:
Martin Whitaker 2009-11-01 15:49:23 +00:00 committed by Stephen Williams
parent c7414f79b0
commit c1f750ff98
1 changed files with 12 additions and 3 deletions

View File

@ -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));