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

Adding Support for Verilog and SystemVerilog #3257

Closed
explocion opened this issue Jan 7, 2023 · 16 comments
Closed

Adding Support for Verilog and SystemVerilog #3257

explocion opened this issue Jan 7, 2023 · 16 comments

Comments

@explocion
Copy link

Is your feature request related to a problem? Please describe.

Recently, I'm developing for some FPGA using Verilog, which is a Hardware Description Language. Common setup for Verilog uses Makefile to automate simulation and synthesize using a Verilog "compiler", e.g., iverilog or verilator. Then, the module and testbenches would be "compiled" (simulation output) to a VCD (Value Change Dump) file which is able to generate waveforms. Therefore, I'm wondering if xmake could also support similar feature out-of-box.

Describe the solution you'd like

In order to port to current architecture of xmake, I suggest taking iverilog and verilator as "compiler" chains, and treat simulation as "build" task. The simulation testbenches are the same as boilerplate code in testing in C/C++. Similarly, the Verilog code can also be build without testbenches, which is called synthesize, which produce something similar to LLVM IR for FPGAs. This is the same as building the main part of a C/C++ project. Therefore, I'm thinking of an xmake file like this:

set_languages("verilog", "system-verilog")
set_toolchains("iverilog")
add_verilog_flags("...")

target("test", {
    kind = "vcd",
    files = { "src/main.v", "tests/test.v"}
})

target("main", {
    kind = "synth",
    files = "src/main.v"
})

Describe alternatives you've considered

No response

Additional context

No response

@waruqi waruqi added this to the v2.7.6 milestone Jan 7, 2023
@waruqi
Copy link
Member

waruqi commented Jan 7, 2023

I will look at it later.

@waruqi
Copy link
Member

waruqi commented Jan 10, 2023

Can you give me a hello world project with makefile?

and where is the verilog and verilator? is this https://github.com/steveicarus/iverilog?

@waruqi
Copy link
Member

waruqi commented Jan 11, 2023

I have supported it. #3274

xmake update -s github:xmake-io/xmake#iverilog

Basic

add_requires("iverilog")
target("hello")
    add_rules("iverilog.binary")
    set_toolchains("@iverilog")
    add_files("src/*.v")

Set abstract configuration

add_requires("iverilog")
target("hello")
    add_rules("iverilog.binary")
    set_toolchains("@iverilog")
    add_files("src/*.v")
    add_defines("TEST")
    add_includedirs("inc")
    set_languages("v1800-2009")

Set custom flags

add_requires("iverilog")
target("hello")
    add_rules("iverilog.binary")
    set_toolchains("@iverilog")
    add_files("src/*.v")
    add_values("iverilogs.flags", "-DTEST")

Build project

$ xmake
checking for iverilog ... iverilog
checking for vvp ... vvp
[ 50%]: linking.iverilog hello.vvp
[100%]: build ok!

Run with vvp

$ xmake run
hello world!
LXT2 info: dumpfile hello.vcd opened for output.
src/main.v:6: $finish called at 0 (1s)

@waruqi
Copy link
Member

waruqi commented Jan 11, 2023

Then, the module and testbenches would be "compiled" (simulation output) to a VCD (Value Change Dump) file which is able to generate waveforms.

How can I specify the generation of a vcd file via command parameters? I can't control the output path and I need to modify the code to generate it using dumpfile in the .v code.

@kassane
Copy link

kassane commented Jan 11, 2023

Verilator allows you to transpile verilog code into modern C++ or systemC, formal verification(lint) and iverilog is simulator only.

@waruqi
Copy link
Member

waruqi commented Jan 11, 2023

Verilator allows you to transpile verilog code into modern C++ or systemC, formal verification(lint) and iverilog is simulator only.

But iverilog can also compile code directly, should I use Verilator or iverilog as a compiler?

Also, I don't know how to specify the output path of vcd via the command line, it seems to be specified only in the code.

@kassane
Copy link

kassane commented Jan 12, 2023

Verilator allows you to transpile verilog code into modern C++ or systemC, formal verification(lint) and iverilog is simulator only.

But iverilog can also compile code directly, should I use Verilator or iverilog as a compiler?

Particularly, my unpleasant experience with icarus verilog was that it was slow compared to verilator in testbech.
Below are some verilator commands.

Note: iverolog can directly generate the binary, but verilator will always convert the code to C++(--cc) or systemC (--sc) before building the binary.

  - Build a specific C project in the current directory:
    verilator --binary --build-jobs 0 -Wall path/to/source.v

  - Create a C++ executable in a specific folder:
    verilator --cc --exe --build --build-jobs 0 -Wall path/to/source.cpp path/to/output.v

  - Perform linting over a code in the current directory:
    verilator --lint-only -Wall

  - Create XML output about the design (files, modules, instance hierarchy, logic and data types) to feed into other tools:
    verilator --xml-output -Wall path/to/output.xml

Also, I don't know how to specify the output path of vcd via the command line, it seems to be specified only in the code.

In the Verilator simply after executing the code get the VCD.
But you will need to add --trace flag during compilation.

@waruqi
Copy link
Member

waruqi commented Jan 12, 2023

Verilator allows you to transpile verilog code into modern C++ or systemC, formal verification(lint) and iverilog is simulator only.

But iverilog can also compile code directly, should I use Verilator or iverilog as a compiler?

Particularly, my unpleasant experience with icarus verilog was that it was slow compared to verilator in testbech. Below are some verilator commands.

Note: iverolog can directly generate the binary, but verilator will always convert the code to C++(--cc) or systemC (--sc) before building the binary.

  - Build a specific C project in the current directory:
    verilator --binary --build-jobs 0 -Wall path/to/source.v

  - Create a C++ executable in a specific folder:
    verilator --cc --exe --build --build-jobs 0 -Wall path/to/source.cpp path/to/output.v

  - Perform linting over a code in the current directory:
    verilator --lint-only -Wall

  - Create XML output about the design (files, modules, instance hierarchy, logic and data types) to feed into other tools:
    verilator --xml-output -Wall path/to/output.xml

Also, I don't know how to specify the output path of vcd via the command line, it seems to be specified only in the code.

In the Verilator simply after executing the code get the VCD. But you will need to add --trace flag during compilation.

thanks, I will look at it.

@explocion
Copy link
Author

Sorry for late replies. I can provide my working CMake configuration to you. Here's the repo link: https://github.com/BinhaoQin/verilator-demo

@waruqi
Copy link
Member

waruqi commented Jan 14, 2023

I have supported both iverilog and verilator simulators.

In addition, I have added support for them in compile_commands.json.

iverilog

See the previous usage example above.

verilator

add_requires("verilator")
target("hello")
    add_rules("verilator.binary")
    set_toolchains("@verilator")
    add_files("src/*.v")
    add_files("src/*.cpp")
    add_values("verilator.flags", "--trace", "--timing")
/mnt/xmake/tests/projects/embed/verilator/hello_vcd$ xmake
checking for platform ... linux
checking for architecture ... x86_64
checking for verilator ... verilator
[  0%]: compiling.verilog src/main.v
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp
[ 11%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0__Slow.cpp
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp
[ 11%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0__Slow.cpp
[ 11%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__Slow.cpp
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp
[ 17%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello.cpp
[ 23%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0.cpp
[ 29%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0.cpp
[ 35%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Syms.cpp
[ 41%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0__Slow.cpp
[ 47%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0.cpp
[ 52%]: cache compiling.release src/sim_main.cpp
[ 88%]: linking.release hello
[100%]: build ok!
ruki@4db94baa81bc:/mnt/xmake/tests/projects/embed/verilator/hello_vcd$ xmake run hello /tmp/hello.vcd
hello world!
%Warning: $dumpvar ignored as not preceded by $dumpfile
- src/main.v:5: Verilog $finish
/mnt/xmake/tests/projects/embed/verilator/hello_vcd$ xmake -rv
[  0%]: compiling.verilog src/main.v
/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/bin/verilator --cc --make cmake --prefix hello --Mdir build/.gens/hello/linux/x86_64/release/rules/verilator --trace --timing src/main.v
[  5%]: compiling.verilog src/main.v
/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/bin/verilator --cc --make cmake --prefix hello --Mdir build/.gens/hello/linux/x86_64/release/rules/verilator --trace --timing src/main.v
[ 11%]: cache compiling.release src/sim_main.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/src/sim_main.cpp.o src/sim_main.cpp
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp.o /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp.o /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp
[ 11%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp.o /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp
[ 11%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__Slow.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__Slow.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__Slow.cpp
[ 11%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0__Slow.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_hac2b4ce6__0__Slow.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0__Slow.cpp
[ 17%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0__Slow.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_h50fced7c__0__Slow.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0__Slow.cpp
[ 41%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello.cpp
[ 41%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_hac2b4ce6__0.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_hac2b4ce6__0.cpp
[ 41%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_h50fced7c__0.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello___024root__DepSet_h50fced7c__0.cpp
[ 41%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Syms.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Syms.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Syms.cpp
[ 47%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0__Slow.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Trace__0__Slow.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0__Slow.cpp
[ 52%]: cache compiling.release build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0.cpp
/usr/bin/gcc -c -std=c++20 -Ibuild/.gens/hello/linux/x86_64/release/rules/verilator -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include -I/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/vltstd -DVM_COVERAGE=0 -DVM_SC=0 -DVM_THREADS=1 -DVM_TIMING=0 -DVM_TRACE_FST=0 -DVM_TRACE_VCD=1 -o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Trace__0.cpp.o build/.gens/hello/linux/x86_64/release/rules/verilator/hello__Trace__0.cpp
[ 88%]: linking.release hello
/usr/bin/g++ -o build/linux/x86_64/release/hello build/.objs/hello/linux/x86_64/release/src/sim_main.cpp.o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp.o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp.o build/.objs/hello/linux/x86_64/release/home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__Slow.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_hac2b4ce6__0__Slow.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_h50fced7c__0__Slow.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_hac2b4ce6__0.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello___024root__DepSet_h50fced7c__0.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Syms.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Trace__0__Slow.cpp.o build/.objs/hello/linux/x86_64/release/gens/rules/verilator/hello__Trace__0.cpp.o -lpthread
[100%]: build ok!

@waruqi
Copy link
Member

waruqi commented Jan 14, 2023

Sorry for late replies. I can provide my working CMake configuration to you. Here's the repo link: https://github.com/BinhaoQin/verilator-demo

add_requires("verilator")
target("Vregister_test")
    add_rules("verilator.binary")
    set_toolchains("@verilator")
    add_files("*.v")
    add_files("simulation/*.cpp")
    add_values("verilator.flags", "-GWIDTH=4", "--trace", "--timing")
verilator-demo$ xmake 
[  0%]: compiling.verilog register_test.v
[  0%]: compiling.verilog register.v
[  5%]: compiling.verilog register_test.v
[  5%]: compiling.verilog register.v
[ 10%]: cache compiling.release simulation/main.cpp
[ 10%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated.cpp
[ 10%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_vcd_c.cpp
[ 10%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_timing.cpp
[ 10%]: cache compiling.release /home/ruki/.xmake/packages/v/verilator/2023.1.10/e75fe612bb12409694b6e09b14731d42/share/verilator/include/verilated_threads.cpp
[ 10%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024root__Slow.cpp
[ 15%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024root__DepSet_h21587979__0__Slow.cpp
[ 20%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024root__DepSet_h252a163f__0__Slow.cpp
[ 25%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024unit__Slow.cpp
[ 30%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024unit__DepSet_h58c8ecdb__0__Slow.cpp
[ 35%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test.cpp
[ 40%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024root__DepSet_h21587979__0.cpp
[ 45%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test___024root__DepSet_h252a163f__0.cpp
[ 50%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test__Syms.cpp
[ 55%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test__Trace__0__Slow.cpp
[ 60%]: cache compiling.release build/.gens/Vregister_test/linux/x86_64/release/rules/verilator/Vregister_test__Trace__0.cpp
[ 90%]: linking.release Vregister_test
[100%]: build ok!

verilator-demo$ xmake run       
%Warning: $dumpvar ignored as not preceded by $dumpfile
Time:    0:: reset: 1, D: 1111, Q: 0000
Time:    5:: reset: 1, D: 1111, Q: 0000
Time:   10:: reset: 1, D: 1111, Q: 0000
Time:   10:: reset: 1, D: 1111, Q: 0000
Time:   15:: reset: 1, D: 1111, Q: 0000
Time:   20:: reset: 0, D: 1111, Q: 0000
Time:   20:: reset: 0, D: 1111, Q: 0000
Time:   25:: reset: 0, D: 1111, Q: 1111
Time:   30:: reset: 0, D: 1111, Q: 1111
Time:   30:: reset: 0, D: 1111, Q: 1111
Time:   35:: reset: 0, D: 1111, Q: 1111
- register_test.v:36: Verilog $finish
Time:   40:: reset: 0, D: 1111, Q: 1111
Time:   40:: reset: 0, D: 1111, Q: 1111

@waruqi
Copy link
Member

waruqi commented Jan 14, 2023

How to test it?

# update to iverilog branch version
xmake update -s github:xmake-io/xmake#iverilog
# update xmake repository
xrepo update-repo
# build and run example
cd xmake/tests/project/embed/verilator/hello
xmake
xmake run

@waruqi
Copy link
Member

waruqi commented Jan 14, 2023

It work fine on linux/macOS now.

But I'm having some problems on windows, and I'm not sure what's causing the problem at the moment. verilator/verilator#3873

@explocion
Copy link
Author

explocion commented Jan 14, 2023

For the issue #3873, Perhaps the compilation command does not specify a top module? I'm not really sure if it is the issue.

@waruqi
Copy link
Member

waruqi commented Jan 15, 2023

For the issue #3873, Perhaps the compilation command does not specify a top module? I'm not really sure if it is the issue.

I try setting it. It still does not work. --top xxx

@waruqi
Copy link
Member

waruqi commented Jan 18, 2023

I have also supported for windows on dev branch now.

verilator/verilator#3873 (comment)

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

No branches or pull requests

3 participants