Skip to content
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

Support old format $display ($time, "...") #467

Closed
veripoolbot opened this issue Mar 23, 2012 · 16 comments
Closed

Support old format $display ($time, "...") #467

veripoolbot opened this issue Mar 23, 2012 · 16 comments
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800

Comments

@veripoolbot
Copy link
Contributor


Author Name: Alex Solomatnikov
Original Redmine Issue: 467 from https://www.veripool.org


Code:

$display ($time, "ps Error: STRATIX or STRATIXGX in non DPA mode does not support the specified deserialization factor!");

error:

syntax error, unexpected $time, expecting STRING or ')'

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-03-23T01:29:57Z


Obviously Verilator currently expects a format string.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Alex Solomatnikov
Original Date: 2012-03-23T01:32:55Z


Another example:

$display($realtime, "ps Warning: Inclock_Period Violation");

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Alex Solomatnikov
Original Date: 2012-04-24T19:21:09Z


More $display() cases that don't work with verilator:

$display("Error!  lpm_representation value must be \"SIGNED\" or \"UNSIGNED\".", $time);

verilator output:

%Error: ...: Extra arguments for $display format

Another case:

$display("Time: %0t", $time, "   Warning : Detected transition on SCANCLK during quiet time. PLL may not function correctly."); 

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-21T01:15:40Z


See also #�.

Patches are welcome; at one point the code didn't discriminate between a user-string "..." and a number which just happened to print as a string, so it couldn't know if $display("foo") should print as a number or string. Some of that is now better, but it's likely still a problem in some places.

Also it's better to make a large format string than to break it up, because Verilator knows how to constant propagate into displays, so ideally a large $display will become in the output just a constant string. This doesn't work across multiple displays.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-21T13:40:01Z


I've started working on this. I see what you mean about constant propagation into display statements.

One question I have is how to tell if one of the arguments (other than the first) is a string.

I have this as input:

 $write("%h", a, ">");

The dtype for the node for the ">" dumps:

BASICDTYPE 0x2687090 <e17679> {g3222} @dt=this@(G/w8)  logic [GENERIC] kwd=logic range=[7:0]

Is there some clue that this was a string?

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-21T13:41:20Z


My current plan is to extend the format string in LinkResolveVisitor with appropriate format % operators for the extra nodes.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-21T14:19:38Z


Found V3Number::isFromString(), answering my own question.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-21T16:48:03Z


Attached is a work in progress to address this issue. I'll remove all the chatter from the final patch.

As I append strings found in the argument list to the format string, I need to remove those strings from the argument list. Is argp->unlinkFrBack() the right thing to call?

I'll work on some tests and then clean it up.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-23T00:30:20Z


Generally very good. Just a few nits.

+++ b/src/verilog.y
-       |       yD_FCLOSE '(' idClassSel ')'            { $$ = new AstFClose($1, $3); }
+       |       yD_FCLOSE '(' expr ')'                  { $$ = new AstFClose($1, $3); }
         |       yD_FFLUSH parenE                        { $1->v3error("Unsupported: $fflush of all handles does not map to C++."); }
-       |       yD_FFLUSH '(' idClassSel ')'            { $$ = new AstFFlush($1, $3); }
+       |       yD_FFLUSH '(' expr ')'                  { $$ = new AstFFlush($1, $3); }

Assume some tests will show the need for this, and that the change works OK.  Please provide as a separate patch.


+++ b/src/V3LinkResolve.cpp

-    void expectFormat(AstNode* nodep, const string& format, AstNode* argp, bool isScan) {
+    void expectFormat(AstNode* nodep, const string& format, AstNode* argp, bool isScan, string *newFormatp = 0) {

Please pass newFormat as a reference (newFormatr - r means reference).  Better, it can just be the return value.

+               int isFromString = 0;

bool


+                   int inpercent = 0;

bool inpercent = false;  (likewise "= true" below)

+                   newFormat.append(", %h");

newFormat += ", %h";


@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-26T15:17:17Z


Thanks for the feedback. Attached is the updated patch.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jamey Hicks
Original Date: 2015-10-26T15:42:18Z


One more update which supersedes the last patch.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-28T00:59:33Z


Great, pushed to git towards 3.878.

(Made one trivial change to add a dataByte() accessor to V3Number, which seemed cleaner.)

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-11-01T13:22:26Z


In 3.878.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: John Demme (@teqdruid)
Original Date: 2016-12-22T21:42:57Z


Hi Guys-

Sorry, but from reading this exchange it's difficult for me to tell what's been fixed. Is the following now supported?
$display ($time, "ps Error: STRATIX or STRATIXGX in non DPA mode does not support the specified deserialization factor!");

I ask since similar things in altera_mf.v don't seem to work in the latest master. (This appears to be the last barrier to altera_mf.v parsing!)

~John

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2017-01-10T00:19:56Z


The $display($time) is fixed in git towards 3.891.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: John Demme (@teqdruid)
Original Date: 2017-01-10T01:35:00Z


Excellent! Thanks

@veripoolbot veripoolbot added resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800 labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800
Projects
None yet
Development

No branches or pull requests

1 participant