Closed veripoolbot closed 5 years ago
Original Redmine Comment Author Name: Udi Finkelstein Original Date: 2019-05-02T13:40:23Z
Sorry, no way to edit posts :-(
The text above is obviously taken from the IEEE1800-2017 LRM.
This is the test case:
module t;
localparam X=1;
generate
if (X == 1)
$info("X is 1");
else
$info("X is not 1");
endgenerate
endmodule
Original Redmine Comment Author Name: Udi Finkelstein Original Date: 2019-05-02T18:43:13Z
Searching a github copy of verilator for completely different stuff ($diplay() implementations), I hit upon the Verilator parser section, where it is clearly indicated this is already supported... I then realized that if this was not supported, it would have caused parsing error on my test, which it did not.
So, it seems that elaboration tasks are partially supported (parsed but not correctly executed).
Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2019-05-02T19:51:16Z
As you noted this is (supposedly) supported, can you please edit the e.g. test_regress/t/t_assert_elab_bad.pl test to show the issue, and then ideally debug?
Original Redmine Comment Author Name: Udi Finkelstein Original Date: 2019-05-03T00:30:48Z
I'm less familiar with the Verilator codebase, but I';ll try next week. In the meantime, I've worked on: https://github.com/YosysHQ/yosys/pull/983
Original Redmine Comment Author Name: Udi Finkelstein Original Date: 2019-05-03T07:14:58Z
OK, I tried looking into it. From the XML I see that the $info/$warning etc. in a function are put directly inside the function. while the same functions inside a generate block are dumped exactly the same (XML-wise) regardless of whether they are part of an initial/always block (runtime task) or directly under the generate block (elaboration time):
Take this code for example:
module t;
generate
if (1)
$warning;
if (1)
begin
initial
$info;
end
endgenerate
endmodule
$warning is an elaboration time task, while the $Info is a runtime task.
The XML shows them both on the same level under an
<netlist>
<module fl="d1" name="t" origName="t">
<begin fl="d4" name="genblk1">
<initial fl="d4">
<display fl="d4" displaytype="$write">
<sformatf fl="d4" name="[%0t] %%Warning: t.sv:4: Assertion failed in %m\n" dtype_id="1">
<time fl="d4" dtype_id="2"/>
<scopename fl="d4" dtype_id="2"/>
</sformatf>
</display>
</initial>
</begin>
<begin fl="d6" name="genblk2">
<initial fl="d7">
<display fl="d8" displaytype="$write">
<sformatf fl="d8" name="[%0t] -Info: t.sv:8: Assertion failed in %m\n" dtype_id="1">
<time fl="d8" dtype_id="2"/>
<scopename fl="d8" dtype_id="2"/>
</sformatf>
</display>
</initial>
</begin>
</module>
</code>
It yet remains to be seen why the $warning call is created under an
Going back to the working code for functions, I tried:
module t2;
function logic checkParameter(input logic [31:0] N);
$info("In function...");
endfunction
localparam x = checkParameter(0);
endmodule
and got:
-Info: In function...
%Error: Internal Error: t2.sv:2: ../V3Simulate.h:261: No value found for node.
%Error: Internal Error: See the manual and http://www.veripool.org/verilator for more assistance.
%Error: Command Failed /home/udif/git/verilator/bin/verilator_bin --xml-only -sv t2.sv
I also noticed that as long as the constant function is used by runtime constructs and not cmpile time constructs, it won't be triggered. e.g., if I change localparam x = checkParameter(0);
to ```wire x = checkParameter(0);
Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2019-06-15T13:35:38Z
Did some poking on this, will add it to the soon-to-work on list. If you or someone has time to create a patch it would be welcome.
Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2019-08-05T02:35:20Z
Fixed in git towards 4.018.
Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2019-08-29T23:14:33Z
In 4.018.
Author Name: Udi Finkelstein Original Redmine Issue: 1429 from https://www.veripool.org
While looking for a way to trigger an error on invalid parameter combinations of a parammetrized module, I stumbled upon this hidden gem:
So it seems that if you call $error()/$wrning()/$info()/$fatal() directly within a generate section, outside any procedural always/initial block, it is treated as elaboration system atsks, not runtime system tasks!
I've tried the following example, but it triggered no response from Verilator:
Is it possible to add support for these system tasks in elaboration time?