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

Problem with $fopen translation #53

Closed
veripoolbot opened this issue Jan 22, 2009 · 3 comments
Closed

Problem with $fopen translation #53

veripoolbot opened this issue Jan 22, 2009 · 3 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: Jeremy Bennett (@jeremybennett)
Original Redmine Issue: 53 from https://www.veripool.org
Original Date: 2009-01-22
Original Assignee: Wilson Snyder (@wsnyder)


A couple of problems with @$fopen@ (taken from the OpenRISC 1000). I have the original Verilog:

integer fflash;
    initial fflash = $fopen("flash.log");


First problem is that Verilator only accepts the two argument version of @$fopen@ (which returns a file descriptor), rather than the single argument version, which returns a multi-channel descriptor. I tried patching this to

integer fflash;
    initial fflash = $fopen("flash.log","w");

Verilator now works fine, but I get defective C++. The code generated includes:

void Vorpsoc::_initial__TOP(Vorpsoc__Syms* __restrict vlSymsp) {
     VL_DEBUG_IF(cout<<"    Vorpsoc::_initial__TOP"<<endl; );
     Vorpsoc* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp;
     // Variables
     VL_SIGW(__Vtemp1,71,0,3);
     // Body
     // INITIAL at rtl/verilog/mem_if/flash_top.v:330
     __Vtemp1[0] = 0x2e6c6f67;
     __Vtemp1[1] = 0x6c617368;
     __Vtemp1[2] = 0x66;
     VL_EXTENDS_QI(64,32, vlTOPp->v__DOT__flash_top__DOT__fflash) = VL_FOPEN_WI(3, __Vtemp1, 0x77);


This last line prompts the G++ error:

Vorpsoc.cpp:5399: error: lvalue required as left operand of assignment

As far as I can see @VL_EXTENDS_QI@ is an inline function, so should not appear on the LHS of an assignment.

It's not a killer (this is not an important part of the code), but any suggestions on a workaround welcome.

Original Verilog file attached

Thanks, Jeremy

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2009-01-22T18:34:33Z


You need to use `verilator_file_descriptor instead of integer to hold the file descriptor as Verilator just makes it a pointer. See the docs.

There's been talk of fixing this but it isn't high on the list, if you'd like to sort it out, I'd love a patch.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jeremy Bennett (@jeremybennett)
Original Date: 2009-01-23T07:59:41Z


Thanks for the quick reply. My error - I didn't read the documentation fully. I'll keep in mind the need for a patch for the future.

Jeremy

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2009-06-23T23:55:49Z


Problem was resolved; unsupported issue remains to do someday.

@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