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
$fopen() & friends don't work as expected... #21
Comments
Original Redmine Comment Works for me. Perhaps try
instead of a integer. |
Original Redmine Comment mmh,... why verilator_file_descriptor, why should this be verilator-specific? Using `verilator_file_descriptor yields:
|
Original Redmine Comment btw, I forgot to submit verilator_main.cpp:
|
Original Redmine Comment You also need Verilator doesn't use MCD instead C file descriptors which in C under -m64 are 64 bits. See the docs. This may not be the problem though... |
Original Redmine Comment mh, this would render the principal idea of using fwrite & friends for portable testcases ridiculous: if one has to touch&modify every testcase for verilator, then one could as well directly use C wrappers instead:
Isn't a proper MCD implementation very straightforward? (e.g. maintain an array of refcounted open file descriptors/file name pairs, and verilog-MCDs could be simple indices into this array? Entries are only valid if refcount > 0, fopen increases refcount for already open file name, fclose decrements it). Or do I miss something that would make this non-trivial? |
Original Redmine Comment There are some implementation issues, but the main issue is I consider Verilator a synthesis subset simulator, and have no time to deal with Verilogisms (MCD) that simply obscure a nice C equivelent. However if you want to implement it, I'd accept it. To the main issue, does that fix it nor not? |
Original Redmine Comment yes, it works, just... as said before. I'll take a look into the MCD issue next days... will you leave the ticket open, or shall I open a new one? |
Original Redmine Comment There is still a fix here... I updated HEAD to warn if the $fopen etc descriptor isn't 64 bits so these errors can be caught. For MCD support please file another bug, thanks. |
Original Redmine Comment I took a closer look on the Icarus mcd implementation. verilog/vvp/vpi_mcd.cc is pretty self-containing, applying these changes makes it compile stand-alone:
It defines the following functions, which can be used instead of libc's fopen/fprintf/fclose/fflush:
Replacing the direct libc calls with vpi_mcd_*() should be sufficient -- and as side-effect a first minimal basis for the VPI core comes in for free. The file is GPL'd, so there should be no licensing issue. |
Author Name: Holger Wächtler
Original Redmine Issue: 21 from https://www.veripool.org
Original Date: 2008-07-14
Original Assignee: Wilson Snyder (@wsnyder)
file test.vt:
file test.in:
Icarus Verilog output:
test.out generated when simulating using Icarus Verilog:
Verilator creates empty output file and this command line output:
The text was updated successfully, but these errors were encountered: