From b5be76e29b20c26e8e8ec01292638720418f7efa Mon Sep 17 00:00:00 2001 From: Fabian Schuiki Date: Fri, 11 Jul 2025 16:46:59 -0700 Subject: [PATCH 1/3] Tweaks to make report.sh work with current Verilator Link more of the libraries generated by Verilator into the simulator. This fixes a missing thread pool destructor during linking when using Verilator 5.034. Also add a missing `std` namespace prefix. --- scripts/report.sh | 2 +- scripts/verilator_tb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/report.sh b/scripts/report.sh index 9a04e56..4f98981 100644 --- a/scripts/report.sh +++ b/scripts/report.sh @@ -335,7 +335,7 @@ if [[ " ${SIM_LIST} " == *" verilator "* ]]; then done bash ../../scripts/verilator_tb.sh ${job} $( echo rtl ${SYN_LIST} | tr ' ' , ) $( echo $inputs | tr -d ' ' ) \ $( echo $bits\'b0 ~$bits\'b0 $( sort -u fail_patterns.txt | sed "s/^/$bits'b/;" ) $extra_patterns | tr ' ' ',' ) $undef_ref > sim_verilator.cc - if ! make -C obj_dir -f Vtestbench.mk || ! g++ -I "$( grep 'VERILATOR_ROOT *=' obj_dir/Vtestbench.mk | sed 's,.*= *,,' )/include" -o sim_verilator sim_verilator.cc obj_dir/Vtestbench__ALL.a; then + if ! make -C obj_dir -f Vtestbench.mk || ! g++ -I "$( grep 'VERILATOR_ROOT *=' obj_dir/Vtestbench.mk | sed 's,.*= *,,' )/include" -o sim_verilator sim_verilator.cc obj_dir/Vtestbench__ALL.a obj_dir/libVtestbench.a obj_dir/libverilated.a; then echo -n > sim_verilator.log else ./sim_verilator > sim_verilator.log diff --git a/scripts/verilator_tb.h b/scripts/verilator_tb.h index 1079089..07bedb9 100644 --- a/scripts/verilator_tb.h +++ b/scripts/verilator_tb.h @@ -14,7 +14,7 @@ bool pattern_bits[PATTERN_BITS_N]; int pattern_cursor, pattern_idx; std::string input_pat_list; -std::vector input_patterns_buf; +std::vector input_patterns_buf; std::set undef_bits; static inline void set_pattern(const char *pattern) From 43bdc24aab6955e4a434d491fd08ea49187ec8c6 Mon Sep 17 00:00:00 2001 From: Fabian Schuiki Date: Fri, 11 Jul 2025 16:50:36 -0700 Subject: [PATCH 2/3] Explicitly use python2; use `which` to find Verilator --- Makefile | 2 +- scripts/report.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 74fc674..5794784 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ IVERILOG_DIR := # /home/clifford/Work/iverilog/instdir/bin MODELSIM_DIR := /opt/intelFPGA_lite/17.0/modelsim_ase/linux QUARTUS_DIR := /opt/intelFPGA_lite/17.0/quartus/bin VIVADO_DIR := /opt/Xilinx/Vivado/2018.3/bin -VERILATOR := /usr/local/bin/verilator +VERILATOR := $(which verilator) MAKE_JOBS := -j4 -l8 YOSYS_MODE := default REPORT_FULL := diff --git a/scripts/report.sh b/scripts/report.sh index 4f98981..781e3ec 100644 --- a/scripts/report.sh +++ b/scripts/report.sh @@ -496,7 +496,7 @@ fi $y =~ /^(module|input|wire|reg|integer|localparam|output|assign|signed|if|else|for|begin|end|case|endcase|task|endtask|function|endfunction|always|initial|endmodule|\$(display|unsigned|signed))$/ ? "#080" : "#008", $y)!eg' )" echo "" - python ../../scripts/valtab.py ${SIM_LIST} + python2 ../../scripts/valtab.py ${SIM_LIST} echo "" echo "" } > report.html From 3b0ad500746e8fd7ec24b1214974e854b8c72325 Mon Sep 17 00:00:00 2001 From: Fabian Schuiki Date: Fri, 11 Jul 2025 16:51:45 -0700 Subject: [PATCH 3/3] Add circt-verilog support Add a `syn_circt.sh` script to test the `circt-verilog` frontend of the CIRCT project with VlogHammer. --- Makefile | 2 +- README | 1 + scripts/syn_circt.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 scripts/syn_circt.sh diff --git a/Makefile b/Makefile index 5794784..756c6cb 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # -# All supported SYN_LIST tags: vivado quartus xst yosys verific dc lec +# All supported SYN_LIST tags: vivado quartus xst yosys verific dc lec circt # All supported SIM_LIST tags: xsim isim modelsim icarus verilator yosim SYN_LIST := vivado yosys diff --git a/README b/README index 718377d..4dabe0f 100644 --- a/README +++ b/README @@ -12,6 +12,7 @@ supported: Altera Quartus II Web Edition (17.0) Cadence Conformal LEC (8.1) Synopsys Design Compiler (C-2009.06) + CIRCT (no specific version) Note: Cadence Conformal and Synopsys Design Compiler are disabled by default. Add "lec" and "dc" to SYN_LIST in the Makefile to enable them. diff --git a/scripts/syn_circt.sh b/scripts/syn_circt.sh new file mode 100644 index 0000000..02839d0 --- /dev/null +++ b/scripts/syn_circt.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# VlogHammer -- A Verilog Synthesis Regression Test +# +# Copyright (C) 2013 Clifford Wolf +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ $# -ne 1 ]; then + echo "Usage: $0 " >&2 + exit 1 +fi + +job="$1" +set -e +set -o pipefail + +mkdir -p syn_circt + +if ! timeout 180 circt-verilog rtl/$job.v -o syn_circt/$job.mlir 2>syn_circt/$job.txt +then + { + echo '// [VLOGHAMMER_SYN_ERROR] circt-verilog crashed' + echo "/*" + cat syn_circt/$job.txt + echo "*/" + sed -e '/^ *assign/ s,^ *,//,;' rtl/$job.v + } > syn_circt/$job.v +elif ! timeout 180 circt-opt --lower-seq-to-sv --export-verilog syn_circt/$job.mlir -o /dev/null >syn_circt/$job.v 2>syn_circt/$job.txt +then + { + echo '// [VLOGHAMMER_SYN_ERROR] circt-opt crashed' + echo "/*" + cat syn_circt/$job.txt + echo "*/" + sed -e '/^ *assign/ s,^ *,//,;' rtl/$job.v + } > syn_circt/$job.v +fi + +rm -f syn_circt/$job.mlir +rm -f syn_circt/$job.txt