Skip to content

Commit 65c87a8

Browse files
committed
Updating VerilogEval benchmark to v2, with a new harness, support for spec-to-RTL, in-context learning example support, failure categorization, and other features.
1 parent 4b9b16e commit 65c87a8

File tree

1,138 files changed

+69740
-1278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,138 files changed

+69740
-1278
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#=========================================================================
2+
# Git Ignore Files
3+
#=========================================================================
4+
# We explicitly ignore a default build directory and the autoconf
5+
# generated autom4te.cache directory. This makes it easy to do a clean
6+
# build under the source directory and still have it appear clean to git.
7+
8+
build*/
9+
autom4te.cache/
10+

Dockerfile

Lines changed: 0 additions & 19 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 NVIDIA Research Projects
3+
Copyright (c) 2023-2024 NVIDIA Research Projects
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -45,4 +45,3 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4545
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4646
THE SOFTWARE.
4747

48-

Makefile.in

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
#=========================================================================
2+
# Makefile
3+
#=========================================================================
4+
#
5+
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
6+
# SPDX-License-Identifier: MIT
7+
# Author : Christopher Batten, NVIDIA and Nathaniel Pinckney, NVIDIA
8+
#
9+
10+
#-------------------------------------------------------------------------
11+
# Basic setup
12+
#-------------------------------------------------------------------------
13+
14+
# Remove all default implicit rules since they can cause subtle bugs
15+
# and they just make things run slower
16+
.SUFFIXES:
17+
% : %,v
18+
% : RCS/%,v
19+
% : RCS/%
20+
% : s.%
21+
% : SCCS/s.%
22+
23+
# Default is to build the prereqs of the all target (defined at bottom)
24+
default : all
25+
.PHONY : default
26+
27+
src_dir := @srcdir@
28+
scripts_dir := $(src_dir)/scripts
29+
30+
#-------------------------------------------------------------------------
31+
# Programs
32+
#-------------------------------------------------------------------------
33+
34+
GENERATE_VERILOG=$(scripts_dir)/sv-generate
35+
GENERATE_FLAGS = "--model=@model@"
36+
37+
examples=@examples@
38+
ifeq ($(examples),yes)
39+
GENERATE_FLAGS += "--examples=4"
40+
else
41+
GENERATE_FLAGS += "--examples=@examples@"
42+
endif
43+
44+
rules=@rules@
45+
ifeq ($(rules),yes)
46+
GENERATE_FLAGS += "--rules"
47+
endif
48+
49+
GENERATE_FLAGS += "--task=@task@"
50+
51+
GENERATE_FLAGS += "--temperature=@temperature@"
52+
GENERATE_FLAGS += "--top-p=@top_p@"
53+
54+
IVERILOG_COMPILE=@IVERILOG@ -Wall -Winfloop -Wno-timescale -g2012 -s tb
55+
56+
#-------------------------------------------------------------------------
57+
# Dataset
58+
#-------------------------------------------------------------------------
59+
60+
dataset_dir = @dataset_dir@
61+
VPATH = ${dataset_dir}
62+
include problems.mk
63+
include samples.mk
64+
65+
# Define prompt files
66+
67+
problem_prompts := $(patsubst %, %_prompt.txt, $(problems))
68+
69+
#-------------------------------------------------------------------------
70+
# Progress indicator
71+
#-------------------------------------------------------------------------
72+
# Here is some neat code that enables a more compact output with a
73+
# progress indication:
74+
#
75+
# https://stackoverflow.com/questions/451413
76+
#
77+
78+
REDIRECT_LOG= &>
79+
REDIRECT_APPEND_LOG= &>>
80+
VERBOSE:=0
81+
QUIET=@
82+
ifeq ($(VERBOSE),1)
83+
QUIET=
84+
REDIRECT_LOG= 2>&1 | tee
85+
REDIRECT_APPEND_LOG= 2>&1 | tee -a
86+
endif
87+
88+
ifndef ECHO
89+
90+
# Do a dry run of make with with given targets and count number of
91+
# times we see HIT_MARK which shows up for every instance of ECHO
92+
93+
HIT_TOTAL != $(MAKE) $(MAKECMDGOALS) --dry-run ECHO="HIT_MARK" | grep -c "HIT_MARK"
94+
95+
# Create a counter which will increment every instance of ECHO
96+
97+
HIT_COUNT = $(eval HIT_N != expr $(HIT_N) + 1)$(HIT_N)
98+
99+
# Create the output counter
100+
101+
ECHO = $(scripts_dir)/echo-progress \
102+
--nsteps=$(HIT_TOTAL) --stepno=$(HIT_COUNT) --verbose=$(VERBOSE)
103+
104+
endif
105+
106+
#-------------------------------------------------------------------------
107+
# Template for per-problem rules
108+
#-------------------------------------------------------------------------
109+
# The template is instantiated for each of the problems.
110+
#
111+
# Arguments:
112+
# $(1) : real problem name (ie with underscores, no dashes)
113+
#
114+
115+
define problem_template
116+
117+
# Figure out number of samples for this problem
118+
119+
sample_num_strs != seq --format "%02g" 1 $$($(1)_num_samples)
120+
121+
# Generate verilog samples
122+
123+
$(1)_sv_samples := $$(patsubst %, $(1)/$(1)_sample%.sv, $$(sample_num_strs))
124+
$(1)_sv_generate_logs := $$(patsubst %, $(1)/$(1)_sample%-sv-generate.log, $$(sample_num_strs))
125+
126+
$$($(1)_sv_samples) : %.sv : $(1)_prompt.txt
127+
@$$(ECHO) Generating $$(notdir $$@) verilog
128+
$$(QUIET) mkdir -p $(1)
129+
$$(QUIET) $$(GENERATE_VERILOG) $$(GENERATE_FLAGS) --verbose \
130+
--output $$@ $$< \
131+
$(REDIRECT_LOG) $$*-sv-generate.log
132+
133+
$(1)-sv-generate : $$($(1)_sv_samples)
134+
135+
pregen_files += $$($(1)_sv_samples)
136+
pregen_files += $$($(1)_sv_generate_logs)
137+
138+
sv_generate_targets += $$($(1)_sv_samples)
139+
140+
$(1)-sv-generate-clean :
141+
rm -rf $$($(1)_sv_samples)
142+
rm -rf $$($(1)_sv_generate_logs)
143+
144+
# Test verilog samples
145+
146+
$(1)_sv_iv_test_bins = \
147+
$$(patsubst %.sv, %, $$($(1)_sv_samples))
148+
149+
$(1)_sv_iv_test_logs = \
150+
$$(patsubst %.sv, %-sv-iv-test.log, $$($(1)_sv_samples))
151+
152+
$$($(1)_sv_iv_test_logs) : %-sv-iv-test.log : %.sv $(1)_test.sv $(1)_ref.sv
153+
@$$(ECHO) Testing $$(notdir $$*) with iverilog
154+
-$$(QUIET) $(IVERILOG_COMPILE) -o $$* $$^ \
155+
$(REDIRECT_LOG) $$*-sv-iv-test.log
156+
-$$(QUIET) timeout 30 ./$$* $(REDIRECT_APPEND_LOG) $$@; \
157+
if [[ $$$${PIPESTATUS[0]} == 124 ]]; then \
158+
echo "TIMEOUT" $(REDIRECT_APPEND_LOG) $$@; \
159+
fi
160+
161+
$(1)-sv-iv-test : $$($(1)_sv_iv_test_logs)
162+
163+
sv_iv_test_targets += $$($(1)_sv_iv_test_logs)
164+
165+
$(1)-sv-iv-test-clean :
166+
rm -rf $$($(1)_sv_iv_test_bins)
167+
rm -rf $$($(1)_sv_iv_test_logs)
168+
169+
sv_iv_test_clean_targets += $(1)-sv-iv-test-clean
170+
171+
# Problem-level clean
172+
173+
$(1)-clean :
174+
rm -rf $(1)
175+
176+
# Add top-level to junk
177+
178+
junk += $(1)
179+
180+
# Phony targets
181+
182+
.PHONY : $(1)-sv-generate
183+
.PHONY : $(1)-sv-iv-test
184+
.PHONY : $(1)-sv-iv-test-clean
185+
186+
endef
187+
188+
$(foreach problem, $(problems), \
189+
$(eval $(call problem_template,$(problem))))
190+
191+
#-------------------------------------------------------------------------
192+
# Top level targets
193+
#-------------------------------------------------------------------------
194+
195+
sv-generate : $(sv_generate_targets)
196+
sv-generate-clean : $(sv_generate_clean_targets)
197+
sv-iv-test : $(sv_iv_test_targets)
198+
sv-iv-test-clean : $(sv_iv_test_clean_targets)
199+
200+
sv-iv-analyze : $(sv_iv_test_targets)
201+
@$(ECHO) Analyzing verilog/iverilog results
202+
$(QUIET) $(scripts_dir)/sv-iv-analyze --csv=summary.csv $(problems) | tee summary.txt
203+
204+
junk += summary.txt summary.csv
205+
206+
#-------------------------------------------------------------------------
207+
# pregen
208+
#-------------------------------------------------------------------------
209+
# Save the generated code and logs so that we can rerun experiments
210+
# without having to regenerate all of the generated code with an LLM.
211+
# We use the special $(file make function because the number of files
212+
# can be so large that it might exceed the command line limit.
213+
214+
pregen_dir := ../../pymtl-eval-pregen
215+
216+
extra_pregen_files = \
217+
problems.mk \
218+
samples.mk \
219+
summary.txt \
220+
summary.csv \
221+
222+
ifneq ($(pregen_dir),NOT_ENABLED)
223+
pregen: $(sv_samples)
224+
$(file > files-to-copy.txt, $(pregen_files))
225+
$(file >> files-to-copy.txt, $(extra_pregen_files))
226+
sed -i.bak -e 's/ \+/\n/g' files-to-copy.txt
227+
rsync --files-from=files-to-copy.txt . \
228+
$(pregen_dir)/$(shell date '+%Y-%m-%d-%H-%M')
229+
rm files-to-copy.txt files-to-copy.txt.bak
230+
else
231+
pregen:
232+
@echo "ERROR: pregen directory was not set with configure"
233+
endif
234+
235+
#-------------------------------------------------------------------------
236+
# configure information
237+
#-------------------------------------------------------------------------
238+
239+
dist_junk += \
240+
config.status Makefile config.log \
241+
242+
#-------------------------------------------------------------------------
243+
# Default
244+
#-------------------------------------------------------------------------
245+
246+
all : sv-iv-analyze
247+
.PHONY : all
248+
249+
#-------------------------------------------------------------------------
250+
# Makefile debugging
251+
#-------------------------------------------------------------------------
252+
# This handy rule will display the contents of any make variable by
253+
# using the target debug-<varname>. So for example, make debug-junk will
254+
# display the contents of the junk variable.
255+
256+
debug-% :
257+
@echo $* = $($*)
258+
259+
#-------------------------------------------------------------------------
260+
# Clean up junk
261+
#-------------------------------------------------------------------------
262+
263+
clean :
264+
rm -rf *~ \#* wave.vcd $(junk)
265+
266+
distclean :
267+
rm -rf *~ \#* wave.vcd $(junk) $(dist_junk)
268+
269+
.PHONY : clean
270+

0 commit comments

Comments
 (0)