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 pre-opened file descriptors for $fwrite() #961

Closed
veripoolbot opened this issue Aug 27, 2015 · 6 comments
Closed

Support pre-opened file descriptors for $fwrite() #961

veripoolbot opened this issue Aug 27, 2015 · 6 comments
Assignees
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800

Comments

@veripoolbot
Copy link
Contributor


Author Name: Wei Song
Original Redmine Issue: 961 from https://www.veripool.org
Original Date: 2015-08-27
Original Assignee: Wilson Snyder (@wsnyder)


Currently the following statement cause compiling error:

$fwrite(32'h80000002, "Error message!");

32'h80000000 to 32'h80000002 are pre-opened file descriptors for stdin, stdout, and stderr.

Or, may be there is a work-around I can use right now.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-08-27T12:30:50Z


Verilator only supports new-style file descriptors, not legacy multi-channel descriptors. This is unlikely to change unless you'd like to contribute a patch to do so - if you'd like pointers of how to do that just ask.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wei Song
Original Date: 2015-08-27T12:42:31Z


I would like to try but it seems related to a lot components.

So the limited target would be supporting only stdin, stdout and stderr.

According to my understanding, I need to:

  1. Change the verilog.y to ask parser recognise the special number as
    pre-opened descriptors.

  2. Pre-open the necessary std channels in C++/SystemC.

  3. Close the channels when necessary.

Some guidance on these?

Pointer to related files would be great.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-08-27T12:56:19Z


The stdin/out/err channels will already be open. You want to use the number computed at runtime, not parse time.

First, make a standalone test in test_regress format (see the docs) that passes on other sims and fails on verilator.

Then, you'll see a message like "Unsupported: $fopen/$fclose/$f* descriptor must be a simple variable" this is made by V3LinkResolve. Change that to accept an AstConst (constant) and check that the value only has stdout/stderr bits set.

There might be some minor changes but eventually the code will verilate.

Then fix include/verilated.h/cpp to fix the VL_FWRITEF runtime code to understand the magic values -- you'll see it calls VL_CVT_I_FP to make a file pointer instead this will need to return a list of stdout and stderr.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-24T01:53:22Z


Fixed in git towards 3.878.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-10-24T01:53:48Z


Fixed in git towards 3.878.

@veripoolbot
Copy link
Contributor Author


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


In 3.878.

@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

2 participants