Add regression tests for `$unit::` reference order
Check separately that `$unit::` references to a variable, named event, and parameter declared later in the compilation unit are rejected. Also check that preceding compilation-unit items remain visible and that a later function name remains visible as permitted by the LRM section 3.12.1 exception. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
9a06cf5483
commit
c71709d75d
|
|
@ -0,0 +1,9 @@
|
|||
// Check that $unit:: does not allow a forward named event reference.
|
||||
|
||||
module test;
|
||||
|
||||
initial -> $unit::value;
|
||||
|
||||
endmodule
|
||||
|
||||
event value;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Check that $unit:: does not allow a forward parameter reference.
|
||||
|
||||
module test;
|
||||
|
||||
localparam integer result = $unit::value;
|
||||
|
||||
endmodule
|
||||
|
||||
parameter integer value = 42;
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// Check legal $unit:: references and a forward function reference.
|
||||
|
||||
parameter integer parameter_value = 17;
|
||||
integer variable_value = 42;
|
||||
event event_value;
|
||||
|
||||
module test;
|
||||
|
||||
reg event_seen;
|
||||
reg failed;
|
||||
|
||||
`define check(val, exp) \
|
||||
if (val !== exp) begin \
|
||||
$display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \
|
||||
`"val`", exp, val); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
always @($unit::event_value)
|
||||
event_seen = 1'b1;
|
||||
|
||||
initial begin
|
||||
failed = 1'b0;
|
||||
event_seen = 1'b0;
|
||||
|
||||
#1;
|
||||
-> $unit::event_value;
|
||||
#1;
|
||||
|
||||
`check($unit::parameter_value, 17);
|
||||
`check($unit::variable_value, 42);
|
||||
`check(event_seen, 1'b1);
|
||||
`check($unit::function_value(), 23);
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
function integer function_value;
|
||||
function_value = 23;
|
||||
endfunction
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// Check that $unit:: does not allow a forward variable reference.
|
||||
|
||||
module test;
|
||||
|
||||
initial $display("%0d", $unit::value);
|
||||
|
||||
endmodule
|
||||
|
||||
integer value;
|
||||
|
|
@ -505,6 +505,10 @@ sv_type_param_restrict_union1 vvp_tests/sv_type_param_restrict_union1.json
|
|||
sv_type_param_restrict_union2 vvp_tests/sv_type_param_restrict_union2.json
|
||||
sv_type_param_restrict_union_fail1 vvp_tests/sv_type_param_restrict_union_fail1.json
|
||||
sv_type_param_restrict_union_fail2 vvp_tests/sv_type_param_restrict_union_fail2.json
|
||||
sv_unit_order_event_fail vvp_tests/sv_unit_order_event_fail.json
|
||||
sv_unit_order_parameter_fail vvp_tests/sv_unit_order_parameter_fail.json
|
||||
sv_unit_order_valid vvp_tests/sv_unit_order_valid.json
|
||||
sv_unit_order_variable_fail vvp_tests/sv_unit_order_variable_fail.json
|
||||
sv_wildcard_import8 vvp_tests/sv_wildcard_import8.json
|
||||
sv_wildcard_port_order vvp_tests/sv_wildcard_port_order.json
|
||||
sv_wildcard_port_order_relaxed vvp_tests/sv_wildcard_port_order_relaxed.json
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_unit_order_event_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_unit_order_parameter_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "sv_unit_order_valid.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"type" : "CE",
|
||||
"source" : "sv_unit_order_variable_fail.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ]
|
||||
}
|
||||
Loading…
Reference in New Issue