-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass $display
et al. in initial
blocks on to sim
#4129
Conversation
I'm not confident that this should be merged in its current form. I'm currently working on modifying the frontend to emit |
Since the changes in the frontend are so small, could you still consider merging this, and improve on it / rewrite it later? |
No. In fact, upon further review, I think #3963 has issues that should be resolved first. |
Sure, but I cherry picked only the first two commits, not the third (unfinished) one. Are there really any controversial changes in the current PR? |
I thought there is at first, but on closer look it seems like the cherry picked commits are OK functionality-wise. If you rename the variable in 97d655a from 4e4d702 should definitely not be merged. For 0792744, I've added inline comments. |
Note that this comment:
directly relates to this comment of mine:
So more work will need to be done on |
0792744
to
67ffce4
Compare
I've narrowed down the cause of the issues with |
Great! |
You can cherry pick cfbaf18 to have a fix the |
There is actually still a bug in the Verilog backend even after my fix: this testcase module string_format_top;
parameter STR = "something interesting";
initial begin
$display("A: %s", STR);
$display("B: %0s", STR);
end
endmodule is transformed via (* hdlname = "\\string_format_top" *)
(* top = 1 *)
(* src = "tests/simple/string_format.v:1.1-7.10" *)
module string_format_top();
(* src = "tests/simple/string_format.v:4.3-4.26" *)
wire _0_;
(* src = "tests/simple/string_format.v:5.3-5.27" *)
wire _1_;
always @*
if (1'h1)
$write("A: %s\n", $unsigned(168'h736f6d657468696e6720696e746572657374696e67));
always @*
if (1'h1)
$write("B: %s\n", $unsigned(168'h736f6d657468696e6720696e746572657374696e67));
assign _1_ = 1'h1;
assign _0_ = 1'h1;
endmodule This is very obviously wrong. However, since this particular bit is entirely unrelated to what this PR is doing, it doesn't need to block this PR. |
This allows tools like SBY to capture the $display output independent from anything else sim might log. Additionally it provides source and hierarchy locations for everything printed.
For some reason I'm not able to cherry pick that - is there some git incantation I have to cast? I have synced my local repository, and I was able to cherry pick the out-of-tree commits above earlier. Done! I've also removed my attempt at a fix. |
I don't think you pushed it. |
67ffce4
to
55e0fb2
Compare
Yeah, I just found out 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just needs one change I called out inline.
Please also cherry pick 5579330 since this fixes the bug I described in #4129 (comment). |
These are useful for formal verification with SBY where they can be used to display solver chosen `rand const reg` signals and signals derived from those. The previous error message for non-constant initial $display statements is downgraded to a log message. Constant initial $display statements will be shown both during elaboration and become part of the RTLIL so that the `sim` output is complete.
55e0fb2
to
f88ee39
Compare
Great, done! |
f88ee39
to
1159e48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for all the help! BTW awesome work on the |
Thanks! It was motivated by Amaranth but I implemented it (or at least started that work) in a way that benefits everyone. I do have to say that implementing SystemVerilog semantics correctly took a lot of time and effort... |
I can only imagine! Give yourself a pat on the back, knowing that this would quite possibly never have materialized without your efforts. |
It seems like 5579330 causes tests/fmt/display_lm_tb.cc to fail. |
That happens because CXXRTL does not (yet) support |
Can I simply temporarily comment out the |
That seems to be a bug in CXXRTL. |
Actually no, it's not. This is the command that fails:
This is the testbench output:
I think it's a broken testbench. However, while looking at this, I did find a subtle bug in that CXXRTL code. |
Please cherry-pick commit 388df43. |
The testbench expects both the synthesis log and the simulation log to contain the output. By commenting out |
Yes, I just found a fix for this - both removing the |
I'm not sure that's really the right fix? I'm actually looking at implementing |
Oh, I didn't imagine you'd be attacking that immediately! |
4946e7c
to
d493225
Compare
Cherry-pick 0dd0128. |
Color me impressed! 😅 |
@whitequark Whoops, this commit also completely removes |
What is "simulation" here? |
In this context, the |
This cherry picks the completed parts from #3963, cherry picks commits by @whitequark correcting the Verilog backend output of the
$print
cell and implementing initial$print
cells in CXXRTL, and adds the-nodisplay
option toread_verilog
to optionally suppress elaboration output from$display
et al.Fixes chipsalliance/sv-tests#5082