-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the trigger for user functions with no args
- Loading branch information
Showing
5 changed files
with
106 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
module top; | ||
reg passed; | ||
wire wconst, wfconst, wfconstarg; | ||
wire wdconst = 1'b0; | ||
wire wdfconst = cfunc(); | ||
wire wdfconstarg = func(1'b0); | ||
real rfconst; | ||
|
||
function automatic reg cfunc(); | ||
cfunc = 1'b0; | ||
endfunction | ||
|
||
function automatic reg func(input reg val); | ||
func = val; | ||
endfunction | ||
|
||
function automatic real crfunc(); | ||
crfunc = 2.0; | ||
endfunction | ||
|
||
assign wconst = 1'b1; | ||
assign wfconst = cfunc(); | ||
assign wfconstarg = func(1'b1); | ||
assign rfconst = crfunc(); | ||
|
||
initial begin | ||
passed = 1'b1; | ||
#1; | ||
|
||
if (wconst !== 1'b1) begin | ||
$display("Expected wire constant value to be 1'b1, actual is %b", wconst); | ||
passed = 1'b0; | ||
end | ||
|
||
if (wdconst !== 1'b0) begin | ||
$display("Expected wire decl constant value to be 1'b0, actual is %b", wdconst); | ||
passed = 1'b0; | ||
end | ||
|
||
if (wfconst !== 1'b0) begin | ||
$display("Expected wire constant function value to be 1'b0, actual is %b", wfconst); | ||
passed = 1'b0; | ||
end | ||
|
||
if (wdfconst !== 1'b0) begin | ||
$display("Expected wire decl constant function value to be 1'b0, actual is %b", wdfconst); | ||
passed = 1'b0; | ||
end | ||
|
||
if (rfconst != 2.0) begin | ||
$display("Expected real constant function value to be 2.0, actual is %f", rfconst); | ||
passed = 1'b0; | ||
end | ||
|
||
if (wfconstarg !== 1'b1) begin | ||
$display("Expected wire constant arg function value to be 1'b1, actual is %b", wfconstarg); | ||
passed = 1'b0; | ||
end | ||
|
||
if (wdfconstarg !== 1'b0) begin | ||
$display("Expected wire decl constant arg function value to be 1'b0, actual is %b", wdfconstarg); | ||
passed = 1'b0; | ||
end | ||
|
||
if (cfunc() !== 1'b0) begin | ||
$display("Expected constant function value to be 1'b0, actual is %b", cfunc()); | ||
passed = 1'b0; | ||
end | ||
|
||
if (passed) $display("PASSED"); | ||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2001-2022 Stephen Williams ([email protected]) | ||
* Copyright (c) 2001-2023 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -2072,22 +2072,20 @@ static void draw_lpm_ufunc(ivl_lpm_t net) | |
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)), | ||
ivl_lpm_width(net), ivl_lpm_trigger(net)); | ||
else | ||
fprintf(vvp_out, "L_%p%s .ufunc%s TD_%s, %u", net, dly, type_string, | ||
vvp_mangle_id(ivl_scope_name(def)), | ||
ivl_lpm_width(net)); | ||
fprintf(vvp_out, ", "); | ||
if (ivl_lpm_trigger(net)) { | ||
assert(ninp > 0); | ||
fprintf(vvp_out, "L_%p%s .ufunc/e TD_%s, %u, E_%p", net, dly, | ||
vvp_mangle_id(ivl_scope_name(def)), | ||
ivl_lpm_width(net), ivl_lpm_trigger(net)); | ||
} else | ||
fprintf(vvp_out, "L_%p%s .ufunc%s TD_%s, %u", net, dly, type_string, | ||
vvp_mangle_id(ivl_scope_name(def)), | ||
ivl_lpm_width(net)); | ||
|
||
/* Print all the net signals that connect to the input of the | ||
function. */ | ||
for (idx = 0 ; idx < ninp ; idx += 1) { | ||
fprintf(vvp_out, "%s", input_strings[idx]); | ||
if (idx != ninp-1) | ||
fprintf(vvp_out, ", "); | ||
fprintf(vvp_out, ", %s", input_strings[idx]); | ||
} | ||
free(input_strings); | ||
|
||
|
@@ -2107,8 +2105,10 @@ static void draw_lpm_ufunc(ivl_lpm_t net) | |
fprintf(vvp_out, "v%p_0", psig); | ||
} | ||
|
||
if (ninp > 0) | ||
fprintf(vvp_out, ")"); | ||
if (ninp == 0) | ||
fprintf(vvp_out, ","); | ||
else | ||
fprintf(vvp_out, ")"); | ||
#if 0 | ||
/* Now print the reference to the signal from which the | ||
result is collected. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
%{ | ||
/* | ||
* Copyright (c) 2001-2022 Stephen Williams ([email protected]) | ||
* Copyright (c) 2001-2023 Stephen Williams ([email protected]) | ||
* | ||
* This source code is free software; you can redistribute it | ||
* and/or modify it in source code form under the terms of the GNU | ||
|
@@ -258,24 +258,19 @@ statement | |
other thread code that is automatically invoked if any of the | ||
bits in the symbols list change. */ | ||
|
||
| T_LABEL K_UFUNC_REAL T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ';' | ||
{ compile_ufunc_real($1, $3, $5, 0, 0, 0, 0, $7, strdup("E_0x0")); } | ||
| T_LABEL K_UFUNC_REAL T_SYMBOL ',' T_NUMBER ',' symbols '(' symbols ')' T_SYMBOL ';' | ||
{ compile_ufunc_real($1, $3, $5, $7.cnt, $7.vect, $9.cnt, $9.vect, $11, 0); } | ||
|
||
| T_LABEL K_UFUNC_REAL T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ';' | ||
{ compile_ufunc_real($1, $3, $5, 0, 0, 0, 0, $7, 0); } | ||
|
||
| T_LABEL K_UFUNC_VEC4 T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ';' | ||
{ compile_ufunc_vec4($1, $3, $5, 0, 0, 0, 0, $7, strdup("E_0x0")); } | ||
| T_LABEL K_UFUNC_VEC4 T_SYMBOL ',' T_NUMBER ',' symbols '(' symbols ')' T_SYMBOL ';' | ||
{ compile_ufunc_vec4($1, $3, $5, $7.cnt, $7.vect, $9.cnt, $9.vect, $11, 0); } | ||
|
||
| T_LABEL K_UFUNC_VEC4 T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ';' | ||
{ compile_ufunc_vec4($1, $3, $5, 0, 0, 0, 0, $7, 0); } | ||
|
||
| T_LABEL K_UFUNC_E T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ',' symbols '(' symbols ')' T_SYMBOL ';' | ||
{ compile_ufunc_vec4($1, $3, $5, $9.cnt, $9.vect, $11.cnt, $11.vect, $13, $7); } | ||
|
||
| T_LABEL K_UFUNC_E T_SYMBOL ',' T_NUMBER ',' T_SYMBOL ',' T_SYMBOL ';' | ||
{ compile_ufunc_vec4($1, $3, $5, 0, 0, 0, 0, $7, 0); } | ||
|
||
/* Resolver statements are very much like functors. They are | ||
compiled to functors of a different mode. */ | ||
|
||
|