themperek / cocotb-test

Unit testing for cocotb
BSD 2-Clause "Simplified" License
148 stars 72 forks source link

GHDL waveform #100

Closed qarlosalberto closed 4 years ago

qarlosalberto commented 4 years ago

Hi,

I'm having problems to generate the waveform with cocotb-test and GHDL:

I can generate the .vcd waveform with a simple Makefile:


TOPLEVEL_LANG=vhdl
VHDL_SOURCES =  $(PWD)/../../RTL_code/sample.vhd
TOPLEVEL=sample
MODULE=sample_cocotb
SIM=ghdl
COMPILE_ARGS=--ieee=synopsys
SIM_ARGS=--vcd=func.vcd
include $(shell cocotb-config --makefiles)/Makefile.inc
include $(shell cocotb-config --makefiles)/Makefile.sim

But no with cocotb-test:

from cocotb_test.simulator import run
import os

CURRENT_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'

def test_modulator():
    run(
        vhdl_sources=[CURRENT_PATH +
                      "/../../RTL_code/sample.vhd"],
        toplevel="sample",
        module="sample_cocotb",
        toplevel_lang="vhdl",
        sim_args=["--vcd=func.vcd"],
        compile_args=["--ieee=synopsys"]
    )

SIM=ghdl pytest -v -s --junitxml=test-results.xml --cocotbxml=test-cocotb.xml

marph91 commented 4 years ago

It works for me with GHDL 1.0-dev (v0.37.0-959-ga18e1503). The waveform is located at the sim_build folder.

qarlosalberto commented 4 years ago

Is there a way to see the GHDL command? A debug output?

I'm using the master branch of cocotb-test

marph91 commented 4 years ago

I'm not aware of any debug output.

In your case it might be a naming issue. The Simulator class expects an parameter with the name simulation_args instead of sim_args. See https://github.com/themperek/cocotb-test/blob/master/cocotb_test/simulator.py#L43.

qarlosalberto commented 4 years ago

Ohhh yes, the problem was in simulation_args

Thank you! :)

themperek commented 4 years ago

Should we change simulation_args to sim_args?

qarlosalberto commented 4 years ago

I think yes, it's a little confused. And it doesn't show any error, you don't know what is happen :/

qarlosalberto commented 4 years ago

Other idea is to show an error/warning if you pass an invalid argument:

run(
    verilog_sources=[os.path.join(example_dir, "ping_tun_tap", "hdl", "icmp_reply.sv")],
    toplevel="icmp_reply",
    python_search=[os.path.join(example_dir, "ping_tun_tap", "tests")],
    module="test_icmp_reply",
    bad_argument="other"
)
themperek commented 4 years ago

Other idea is to show an error/warning if you pass an invalid argument:

This would make customization more painful. But maybe makes sense to change this. Remove this line: https://github.com/themperek/cocotb-test/blob/f67762202aa0c48b4db8488a07b8010836c96694/cocotb_test/simulator.py#L53