Skip to content

Commit 1cc4e5d

Browse files
committed
1 parent 0c468e6 commit 1cc4e5d

13 files changed

+1073
-0
lines changed

modules/verilator/5.034/MODULE.bazel

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""https://verilator.org/"""
2+
3+
module(
4+
name = "verilator",
5+
version = "5.034",
6+
bazel_compatibility = [">=7.2.1"],
7+
)
8+
9+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
10+
bazel_dep(name = "platforms", version = "0.0.11")
11+
bazel_dep(name = "rules_bison", version = "0.3.1")
12+
bazel_dep(name = "rules_cc", version = "0.1.1")
13+
bazel_dep(name = "rules_flex", version = "0.3.1")
14+
bazel_dep(name = "rules_m4", version = "0.2.4")
15+
bazel_dep(name = "rules_python", version = "1.3.0")
16+
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
+355
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,355 @@
1+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
2+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
3+
load("@rules_flex//flex:flex.bzl", "flex")
4+
load(
5+
"//private:verilator_utils.bzl",
6+
"current_flex_lexer_header",
7+
"verilator_astgen",
8+
"verilator_bisonpre",
9+
"verilator_build_template",
10+
"verilator_flexfix",
11+
"verilator_version",
12+
)
13+
14+
package(default_visibility = ["//visibility:private"])
15+
16+
licenses(["notice"])
17+
18+
exports_files([
19+
"Artistic",
20+
"COPYING",
21+
"COPYING.LESSER",
22+
])
23+
24+
verilator_version(
25+
name = "version",
26+
changelog = "Changes",
27+
)
28+
29+
verilator_build_template(
30+
name = "config_package",
31+
out = "src/config_package.h",
32+
substitutions = {
33+
"#define PACKAGE_STRING \"\"": "#define PACKAGE_STRING \"Verilator v{VERILATOR_VERSION}\"",
34+
},
35+
template = "src/config_package.h.in",
36+
version = ":version",
37+
)
38+
39+
write_file(
40+
name = "config_rev_template",
41+
out = "src/config_rev.h.in",
42+
content = """\
43+
static const char* const DTVERSION_rev = "";
44+
45+
""".splitlines(),
46+
newline = "unix",
47+
)
48+
49+
verilator_build_template(
50+
name = "config_rev",
51+
out = "src/config_rev.h",
52+
substitutions = {
53+
"DTVERSION_rev = \"\"": "DTVERSION_rev = \"v{VERILATOR_VERSION}\"",
54+
},
55+
template = "src/config_rev.h.in",
56+
version = ":version",
57+
)
58+
59+
verilator_build_template(
60+
name = "verilated_config",
61+
out = "include/verilated_config.h",
62+
substitutions = {
63+
"@PACKAGE_NAME@": "Verilator",
64+
"@PACKAGE_VERSION@": "{VERILATOR_VERSION}",
65+
},
66+
template = "include/verilated_config.h.in",
67+
version = ":version",
68+
)
69+
70+
verilator_astgen(
71+
name = "verilator_astgen",
72+
srcs = [
73+
"src/V3Ast.h",
74+
"src/V3AstNodeDType.h",
75+
"src/V3AstNodeExpr.h",
76+
"src/V3AstNodeOther.h",
77+
"src/V3DfgVertices.h",
78+
"src/Verilator.cpp",
79+
],
80+
outs = [
81+
"V3Ast__gen_forward_class_decls.h",
82+
"V3Ast__gen_impl.h",
83+
"V3Ast__gen_macros.h",
84+
"V3Ast__gen_report.txt",
85+
"V3Ast__gen_type_enum.h",
86+
"V3Ast__gen_type_info.h",
87+
"V3Ast__gen_type_tests.h",
88+
"V3Ast__gen_visitor_decls.h",
89+
"V3Ast__gen_visitor_defns.h",
90+
"V3Ast__gen_yystype.h",
91+
"V3Dfg__gen_ast_to_dfg.h",
92+
"V3Dfg__gen_auto_classes.h",
93+
"V3Dfg__gen_dfg_to_ast.h",
94+
"V3Dfg__gen_forward_class_decls.h",
95+
"V3Dfg__gen_macros.h",
96+
"V3Dfg__gen_type_enum.h",
97+
"V3Dfg__gen_type_tests.h",
98+
"V3Dfg__gen_visitor_decls.h",
99+
"V3Dfg__gen_visitor_defns.h",
100+
],
101+
args = [
102+
"--astdef",
103+
"V3AstNodeDType.h",
104+
"--astdef",
105+
"V3AstNodeExpr.h",
106+
"--astdef",
107+
"V3AstNodeOther.h",
108+
"--dfgdef",
109+
"V3DfgVertices.h",
110+
"--classes",
111+
],
112+
astgen = "src/astgen",
113+
)
114+
115+
verilator_astgen(
116+
name = "verilator_astgen_const",
117+
srcs = [
118+
"src/V3Ast.h",
119+
"src/V3AstNodeDType.h",
120+
"src/V3AstNodeExpr.h",
121+
"src/V3AstNodeOther.h",
122+
"src/V3Const.cpp",
123+
"src/V3DfgVertices.h",
124+
"src/Verilator.cpp",
125+
],
126+
outs = [
127+
"V3Const__gen.cpp",
128+
],
129+
args = [
130+
"--astdef",
131+
"V3AstNodeDType.h",
132+
"--astdef",
133+
"V3AstNodeExpr.h",
134+
"--astdef",
135+
"V3AstNodeOther.h",
136+
"--dfgdef",
137+
"V3DfgVertices.h",
138+
"V3Const.cpp",
139+
],
140+
astgen = "src/astgen",
141+
)
142+
143+
flex(
144+
name = "verilator_lex_flex",
145+
src = "src/verilog.l",
146+
)
147+
148+
verilator_flexfix(
149+
name = "verilator_lex_flexfix",
150+
src = ":verilator_lex_flex",
151+
out = "V3Lexer.yy.cpp",
152+
args = ["V3Lexer"],
153+
flexfix = "src/flexfix",
154+
)
155+
156+
flex(
157+
name = "verilator_prelex_pregen",
158+
src = "src/V3PreLex.l",
159+
)
160+
161+
verilator_flexfix(
162+
name = "verilator_prelex_flexfix",
163+
src = ":verilator_prelex_pregen",
164+
out = "V3PreLex.yy.cpp",
165+
args = ["V3PreLex"],
166+
flexfix = "src/flexfix",
167+
)
168+
169+
verilator_bisonpre(
170+
name = "verilator_bison",
171+
bisonpre = "src/bisonpre",
172+
out_hdr = "V3ParseBison.h",
173+
out_src = "V3ParseBison.c",
174+
yacc_src = "src/verilog.y",
175+
)
176+
177+
cc_library(
178+
name = "verilatedos",
179+
hdrs = [
180+
"include/verilatedos.h",
181+
"include/verilatedos_c.h",
182+
],
183+
strip_include_prefix = "include/",
184+
)
185+
186+
current_flex_lexer_header(
187+
name = "current_flex_lexer_header",
188+
out = "flex/src/FlexLexer.h",
189+
)
190+
191+
cc_library(
192+
name = "FlexLexer",
193+
srcs = [":flex/src/FlexLexer.h"],
194+
includes = ["flex/src"],
195+
)
196+
197+
# TODO(kkiningh): Verilator also supports multithreading, should we enable it?
198+
cc_library(
199+
name = "verilator_libV3",
200+
srcs = glob(
201+
["src/V3*.cpp"],
202+
exclude = [
203+
"src/V3*_test.cpp",
204+
"src/V3Const.cpp",
205+
],
206+
) + [
207+
":V3Ast__gen_forward_class_decls.h",
208+
":V3Ast__gen_impl.h",
209+
":V3Ast__gen_macros.h",
210+
":V3Ast__gen_type_enum.h",
211+
":V3Ast__gen_type_info.h",
212+
":V3Ast__gen_type_tests.h",
213+
":V3Ast__gen_visitor_decls.h",
214+
":V3Ast__gen_visitor_defns.h",
215+
":V3Ast__gen_yystype.h",
216+
":V3Const__gen.cpp",
217+
":V3Dfg__gen_ast_to_dfg.h",
218+
":V3Dfg__gen_auto_classes.h",
219+
":V3Dfg__gen_dfg_to_ast.h",
220+
":V3Dfg__gen_forward_class_decls.h",
221+
":V3Dfg__gen_macros.h",
222+
":V3Dfg__gen_type_enum.h",
223+
":V3Dfg__gen_type_tests.h",
224+
":V3Dfg__gen_visitor_decls.h",
225+
":V3Dfg__gen_visitor_defns.h",
226+
":V3ParseBison.h",
227+
],
228+
hdrs = glob(["src/V3*.h"]) + [
229+
"src/config_build.h",
230+
"src/config_package.h",
231+
"src/config_rev.h",
232+
],
233+
copts = [
234+
# TODO: We should probably set this later
235+
"-DDEFENV_SYSTEMC_INCLUDE=\\\"@invalid@\\\"",
236+
"-DDEFENV_SYSTEMC_LIBDIR=\\\"@invalid@\\\"",
237+
"-DDEFENV_VERILATOR_ROOT=\\\"@invalid@\\\"",
238+
# TODO: Remove these once upstream fixes these warnings
239+
"-Wno-unneeded-internal-declaration",
240+
],
241+
defines = ["YYDEBUG"],
242+
strip_include_prefix = "src/",
243+
textual_hdrs = [
244+
# These are included directly by other C++ files
245+
# See https://github.com/bazelbuild/bazel/issues/680
246+
":V3Lexer.yy.cpp",
247+
":V3PreLex.yy.cpp",
248+
":V3ParseBison.c",
249+
],
250+
deps = [
251+
":FlexLexer",
252+
":verilatedos",
253+
],
254+
)
255+
256+
cc_library(
257+
name = "vltstd",
258+
hdrs = [
259+
"include/vltstd/sv_vpi_user.h",
260+
"include/vltstd/svdpi.h",
261+
"include/vltstd/vpi_user.h",
262+
],
263+
strip_include_prefix = "include/vltstd",
264+
)
265+
266+
cc_library(
267+
name = "verilator",
268+
srcs = [
269+
"include/gtkwave/fastlz.h",
270+
"include/gtkwave/fst_config.h",
271+
"include/gtkwave/fstapi.h",
272+
"include/gtkwave/lz4.h",
273+
"include/gtkwave/wavealloca.h",
274+
"include/verilated.cpp",
275+
"include/verilated_fst_c.cpp",
276+
"include/verilated_imp.h",
277+
"include/verilated_syms.h",
278+
"include/verilated_threads.cpp",
279+
"include/verilated_vcd_c.cpp",
280+
"include/verilated_vpi.cpp",
281+
],
282+
hdrs = [
283+
"include/verilated_config.h",
284+
"include/verilated_dpi.h",
285+
"include/verilated_fst_c.h",
286+
"include/verilated_funcs.h",
287+
"include/verilated_intrinsics.h",
288+
"include/verilated_sc.h",
289+
"include/verilated_sym_props.h",
290+
"include/verilated_threads.h",
291+
"include/verilated_timing.h",
292+
# Needed for verilated_vcd_c.cpp and verilated_fst_c.cpp
293+
"include/verilated_trace_imp.h",
294+
"include/verilated_trace.h",
295+
"include/verilated_types.h",
296+
"include/verilated_vcd_c.h",
297+
"include/verilated_vpi.h",
298+
"include/verilated.h",
299+
],
300+
# TODO: Remove these once upstream fixes these warnings
301+
copts = [
302+
"-Wno-unused-const-variable",
303+
"-std=c++17",
304+
"-ffp-contract=off",
305+
],
306+
includes = ["include"],
307+
linkopts = [
308+
"-lpthread",
309+
],
310+
strip_include_prefix = "include/",
311+
textual_hdrs = [
312+
"include/gtkwave/fastlz.c",
313+
"include/gtkwave/fstapi.c",
314+
"include/gtkwave/lz4.c",
315+
],
316+
visibility = ["//visibility:public"],
317+
deps = [
318+
":verilatedos",
319+
":vltstd",
320+
"@zlib",
321+
],
322+
)
323+
324+
# This alias is for supporting the legacy name but while allowing the
325+
# `cc_library` target to be renamed to avoid a `liblibverilator.a`
326+
# output name.
327+
alias(
328+
name = "libverilator",
329+
actual = "verilator",
330+
visibility = ["//visibility:public"],
331+
)
332+
333+
cc_library(
334+
name = "svdpi",
335+
hdrs = [
336+
"include/vltstd/svdpi.h",
337+
],
338+
strip_include_prefix = "include/vltstd",
339+
visibility = ["//visibility:public"],
340+
)
341+
342+
cc_binary(
343+
name = "verilator_executable",
344+
srcs = ["src/Verilator.cpp"],
345+
copts = [
346+
"-std=c++17",
347+
"-ffp-contract=off",
348+
],
349+
linkopts = [
350+
"-lpthread",
351+
"-latomic",
352+
],
353+
visibility = ["//visibility:public"],
354+
deps = [":verilator_libV3"],
355+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../MODULE.bazel

0 commit comments

Comments
 (0)