Skip to content

Commit ba50db2

Browse files
authored
1 parent 1310445 commit ba50db2

14 files changed

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

0 commit comments

Comments
 (0)