Issue #53
Problem with $fopen translation
| Status: | Closed | Start date: | 01/22/2009 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | Wilson Snyder | % Done: | 0% |
|
| Category: | Unsupported | |||
| Target version: | - |
Description
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
History
Updated by Wilson Snyder over 4 years ago
- Category set to Unsupported
- Status changed from New to AskedReporter
- Assignee set to Wilson Snyder
- Priority changed from Normal to Low
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.
Updated by Jeremy Bennett over 4 years ago
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
Updated by Wilson Snyder almost 4 years ago
- Status changed from AskedReporter to Closed
Problem was resolved; unsupported issue remains to do someday.
Also available in: Atom
![[logo]](/img/veripool_small.png)