Coder Social home page Coder Social logo

Comments (10)

martinwhitaker avatar martinwhitaker commented on August 24, 2024

For me, running under Linux. the output appears immediately. What version of Icarus and O/S are you using?

from iverilog.

getvictor avatar getvictor commented on August 24, 2024

@martinwhitaker, what do you mean by immediately? What I'm looking for is for the first $display to appear first, then the second, etc. Currently I'm seeing them all appear on the screen at the same time at the end of the run.

I tried it with Icarus 0.9.6 on Ubuntu 13.04, and with a recent Icarus 0.10.0 on RHEL5

from iverilog.

martinwhitaker avatar martinwhitaker commented on August 24, 2024

By immediately I mean as soon as the simulation reaches that point, i.e. exactly what you expect/want.

I would only expect the output to be delayed if you have redirected or piped standard output, e.g. something like 'vvp a.out | tee run.log' will give the behaviour you are seeing. Are you running vvp directly from a command prompt in a terminal window?

from iverilog.

caryr avatar caryr commented on August 24, 2024

What you are looking for is the following (from 1364-2005)

17.2.6 Flushing output

For example:
$fflush ( mcd );
$fflush ( fd );
$fflush ( );

writes any buffered output to the file(s) specified by mcd, to the file specified by fd, or if $fflush is invoked
with no arguments, to all open files.

and this snippet from 17.2.1

Three file descriptors are pre-opened; they are STDIN, STDOUT, and STDERR, which have the values 32'h8000_0000, 32'h8000_0001, and 32'h8000_0002, respectively. STDIN is pre-opened for reading, and STDOUT and STDERR are pre-opened for append.

If you don't have other files open for writing that would benefit from buffering just calling $fflush(); should be enough otherwise try $fflush(32'h8000_0001); to just flush STDOUT.

Cary

from iverilog.

getvictor avatar getvictor commented on August 24, 2024

Yes, using $fflush() works.
Thank you.

from iverilog.

getvictor avatar getvictor commented on August 24, 2024

@martinwhitaker, yes, I ran vvp directly from command prompt and also from inside a bash script. I always see results flushed out at the end of the sim.

from iverilog.

martinwhitaker avatar martinwhitaker commented on August 24, 2024

Glad to hear Cary's solution works for you, but it shouldn't be needed! stdout should be line-buffered when connected to a terminal, so each $display should produce output immediately. Unfortunately I can't think of any explanation for why this is not happening for you.

from iverilog.

getvictor avatar getvictor commented on August 24, 2024

Ok. I see the difference in behavior now. I'm running vvp like this:
vvp a.out | tee log.txt. Whenever the vvp output gets piped or redirected, the results don't get flushed out. This is inconvenient -- I'm writing a Java-based wrapper (intended for quick Verilog prototyping using different simulators) and I must do redirection. Any chance this behavior can be changed?

from iverilog.

steveicarus avatar steveicarus commented on August 24, 2024

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The behavior you are seeing is the typical behavoir of stdout
as defined by the C library. It is possible to override this
(by explicitly setting stdout to line buffered) but the reason
the people in the olden days did this is because output that is
not going to the tty is typically being sent to a file or other
non-interactive destination and the C library chooses the most
efficient way to do that.

What is typically done with programs that want to interactively
wrap interactive programs is to use ptty devices to link the
wrapper program to the interactive program.

On 07/17/2013 07:04 AM, getvictor wrote:

Ok. I see the difference in behavior now. I'm running vvp like
this: |vvp a.out | tee log.txt|. Whenever the vvp output gets piped
or redirected, the results don't get flushed out. This is
inconvenient since I'm writing a Java-based wrapper (intended for
quick Verilog prototyping using different simulators). Any chance
this behavior can be changed?

— Reply to this email directly or view it on GitHub
#3 (comment).


Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlHmse4ACgkQrPt1Sc2b3imjpgCgzoRK2EORC3sC0TBKMcBo+BKv
aRgAnisnyMB1j5azhdSCaIzZBhVg7JlL
=ftIx
-----END PGP SIGNATURE-----

from iverilog.

getvictor avatar getvictor commented on August 24, 2024

@steveicarus, thank you for the explanation. I found a way to enable line buffering while redirecting: unbuffer vvp a.out | tee log.txt

from iverilog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.