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

realtime monitoring of simulation output #16

Open
sgherbst opened this issue Nov 6, 2017 · 1 comment
Open

realtime monitoring of simulation output #16

sgherbst opened this issue Nov 6, 2017 · 1 comment

Comments

@sgherbst
Copy link

sgherbst commented Nov 6, 2017

Hi,

On my platform (macOS Sierra 10.12.5, vvp 11.0, iverilog 11.0) the display=True option of simulation.run doesn't provide realtime output when using the iverilog simulator. The simulation runs, but no simulator output is printed until the simulation finishes. Such realtime feedback would be useful for running long simulations.

I traced the issue back to vvp and opened an issue there.

As workaround for now, I found that the issue can be resolved by calling vvp through unbuffer, which can be installed on macOS via brew install homebrew/dupes/expect. I believe it is standard on Linux systems.

Here is a sample implementation in simulation.run_iverilog, near line 175.

# generate the simulation command
sim_cmd = [os.path.join('.', outputfile)]
if display:
    # use unbuffer if available
    try:
        # unbuffer will print out a usage message to stderr if available, which is suppressed
        subprocess.Popen('unbuffer', stderr=subprocess.DEVNULL).wait()
        sim_cmd = ['unbuffer'] + sim_cmd
    except FileNotFoundError:
        pass

# run the simulation
sim_rslt = ''
with subprocess.Popen(sim_cmd, stdout=subprocess.PIPE) as p:
    for line in p.stdout:
        decoded = line.decode(encode)
        sim_rslt += decoded
        if display:
            print(decoded, end='')

Thanks,
Steven

@sgherbst
Copy link
Author

sgherbst commented Nov 6, 2017

It looks like this behavior of vvp is expected according to a comment, so I think it's probably necessary to use unbuffer, stdbuf, or similar to achieve realtime output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant