Skip to content

Commit 352da59

Browse files
committed
[bazel] Rework HW files targets
This commit switches the HW targets (verilator, bitstream) to use the target create by `opentitan_top`. This allows to remove many of the hacky `all_files` targets used everywhere. This commit does keep a few and even creates some, but tries to adhere to the following convention: only use `glob()` or `all_files` for sub-directories that contain no bazel targets and should be passed "as-is" to fusesoc. Signed-off-by: Amaury Pouly <[email protected]>
1 parent 4b42939 commit 352da59

File tree

24 files changed

+31
-212
lines changed

24 files changed

+31
-212
lines changed

BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ filegroup(
1414
name = "cores",
1515
srcs = [
1616
"check_tool_requirements.core",
17+
"tool_requirements.py",
1718
"topgen.core",
1819
"topgen-reg-only.core",
20+
"//util:check_tool_requirements.py",
1921
],
2022
)
2123

hw/BUILD

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ string_list_flag(
3535
fusesoc_build(
3636
name = "verilator_real",
3737
srcs = [
38-
":all_files",
38+
"//hw/top",
3939
],
4040
cores = [
4141
"//:cores",
@@ -101,25 +101,6 @@ genrule(
101101
visibility = ["//visibility:public"],
102102
)
103103

104-
# TODO(lowRISC/opentitan#7972): Globbing all of the //hw/... hierarchy together
105-
# is a bit of a hack. Longer term, we need proper rules for expressing the
106-
# relationships between verilog components.
107-
filegroup(
108-
name = "all_files",
109-
srcs = glob(
110-
["**"],
111-
# TODO(lowRISC/opentitan#15882): make Verilator work with foundry repo present.
112-
exclude = ["foundry/**"],
113-
) + [
114-
"//:tool_requirements.py",
115-
"//hw/ip:all_files",
116-
"//hw/ip_templates:all_files",
117-
"//hw/top_earlgrey:all_files",
118-
"//util:check_tool_requirements.py",
119-
],
120-
visibility = ["//visibility:public"],
121-
)
122-
123104
pkg_files(
124105
name = "package",
125106
srcs = ["verilator_bin"],

hw/bitstream/vivado/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fusesoc_build(
4040
name = "fpga_cw310",
4141
testonly = True,
4242
srcs = [
43-
"//hw:all_files",
43+
"//hw/top",
4444
_CW310_TESTROM,
4545
_OTP_RMA,
4646
],
@@ -90,7 +90,7 @@ fusesoc_build(
9090
name = "fpga_cw310_hyperdebug",
9191
testonly = True,
9292
srcs = [
93-
"//hw:all_files",
93+
"//hw/top",
9494
_CW310_TESTROM,
9595
_OTP_RMA,
9696
],
@@ -140,7 +140,7 @@ fusesoc_build(
140140
name = "fpga_cw340",
141141
testonly = True,
142142
srcs = [
143-
"//hw:all_files",
143+
"//hw/top",
144144
_CW340_TESTROM,
145145
_OTP_RMA,
146146
],

hw/ip/tlul/data/BUILD renamed to hw/dv/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ package(default_visibility = ["//visibility:public"])
66

77
filegroup(
88
name = "all_files",
9-
srcs = glob(["**"]),
9+
srcs = glob(
10+
["**"],
11+
),
1012
)

hw/ip/BUILD

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,3 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
package(default_visibility = ["//visibility:public"])
6-
7-
filegroup(
8-
name = "all_files",
9-
srcs = glob(["**"]) + [
10-
"//hw/ip/adc_ctrl",
11-
"//hw/ip/aes",
12-
"//hw/ip/aon_timer",
13-
"//hw/ip/csrng",
14-
"//hw/ip/edn",
15-
"//hw/ip/entropy_src",
16-
"//hw/ip/gpio",
17-
"//hw/ip/hmac",
18-
"//hw/ip/i2c",
19-
"//hw/ip/keymgr",
20-
"//hw/ip/kmac",
21-
"//hw/ip/lc_ctrl",
22-
"//hw/ip/otbn:all_files",
23-
"//hw/ip/otp_ctrl",
24-
"//hw/ip/pattgen",
25-
"//hw/ip/pinmux:all_files",
26-
"//hw/ip/prim",
27-
"//hw/ip/prim_generic:all_files",
28-
"//hw/ip/prim_xilinx:all_files",
29-
"//hw/ip/prim_xilinx_ultrascale:all_files",
30-
"//hw/ip/pwm",
31-
"//hw/ip/rom_ctrl",
32-
"//hw/ip/rv_core_ibex",
33-
"//hw/ip/rv_dm",
34-
"//hw/ip/rv_timer",
35-
"//hw/ip/spi_device",
36-
"//hw/ip/spi_host",
37-
"//hw/ip/sram_ctrl",
38-
"//hw/ip/sysrst_ctrl",
39-
"//hw/ip/tlul",
40-
"//hw/ip/trial1:all_files",
41-
"//hw/ip/uart",
42-
"//hw/ip/usbdev",
43-
],
44-
)

hw/ip/prim/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ load("//rules/opentitan:hw.bzl", "opentitan_ip")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]) + [
12-
],
13-
)
14-
159
opentitan_ip(
1610
name = "prim",
1711
doc = glob(["doc/**"]),

hw/ip/tlul/BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ load("//rules/opentitan:hw.bzl", "opentitan_ip")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]) + [
12-
"//hw/ip/tlul/data:all_files",
13-
],
14-
)
15-
169
opentitan_ip(
1710
name = "tlul",
1811
doc = glob(["doc/**"]),

hw/ip_templates/BUILD

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,3 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
package(default_visibility = ["//visibility:public"])
6-
7-
filegroup(
8-
name = "all_files",
9-
srcs = glob(["**"]) + [
10-
"//hw/ip_templates/clkmgr:all_files",
11-
"//hw/ip_templates/flash_ctrl:all_files",
12-
"//hw/ip_templates/pwrmgr:all_files",
13-
"//hw/ip_templates/rstmgr:all_files",
14-
],
15-
)

hw/ip_templates/pwrmgr/BUILD

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

hw/ip_templates/rstmgr/BUILD

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

hw/ip_templates/clkmgr/BUILD renamed to hw/lint/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ package(default_visibility = ["//visibility:public"])
66

77
filegroup(
88
name = "all_files",
9-
srcs = glob(["**"]),
9+
srcs = glob(
10+
["**"],
11+
),
1012
)

hw/top_earlgrey/BUILD

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ opentitan_top(
7070
],
7171
rtl = glob([
7272
"*.core",
73-
"dv/**",
7473
"rtl/**",
7574
"lint/**",
76-
]),
77-
)
78-
79-
filegroup(
80-
name = "all_files",
81-
srcs = glob(["**"]) + [
75+
"util/**",
76+
]) + [
77+
"//:cores", # FIXME move those files somewhere else?
78+
"//hw/dv:all_files",
79+
"//hw/lint:all_files",
80+
"//hw/top_earlgrey/dv:all_files",
81+
"//hw/vendor:all_files",
82+
# The following will be moved to a proper IP when the pinmux port to ipgen is complete.
83+
"//hw/ip/pinmux:all_files",
8284
"//hw/top_earlgrey/data:all_files",
83-
"//hw/top_earlgrey/dv/verilator:all_files",
84-
"//hw/top_earlgrey/ip:all_files",
85-
"//hw/top_earlgrey/sw:all_files",
85+
"//hw/top_earlgrey/ip/pinmux:all_files",
8686
],
8787
)
8888

hw/top_earlgrey/dv/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
package(default_visibility = ["//visibility:public"])
66

7+
filegroup(
8+
name = "all_files",
9+
srcs = glob(["**"]),
10+
)
11+
712
filegroup(
813
name = "config",
914
srcs = [

hw/top_earlgrey/dv/verilator/BUILD

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

hw/top_earlgrey/ip/BUILD

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

hw/top_earlgrey/ip/xbar/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ load("//rules/opentitan:hw.bzl", "opentitan_ip")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]) + [
12-
],
13-
)
14-
159
opentitan_ip(
1610
name = "xbar",
1711
doc = glob(["doc/**"]),

hw/top_earlgrey/ip/xbar_main/BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ load("//rules/opentitan:hw.bzl", "opentitan_ip")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]) + [
12-
"//hw/top_earlgrey/ip/xbar_main/data:all_files",
13-
],
14-
)
15-
169
opentitan_ip(
1710
name = "xbar_main",
1811
doc = glob(["doc/**"]),

hw/top_earlgrey/ip/xbar_main/data/BUILD

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

hw/top_earlgrey/ip/xbar_peri/BUILD

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ load("//rules/opentitan:hw.bzl", "opentitan_ip")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]) + [
12-
"//hw/top_earlgrey/ip/xbar_peri/data:all_files",
13-
],
14-
)
15-
169
opentitan_ip(
1710
name = "xbar_peri",
1811
doc = glob(["doc/**"]),

hw/top_earlgrey/ip/xbar_peri/data/BUILD

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

hw/top_earlgrey/sw/BUILD

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

hw/top_earlgrey/sw/autogen/BUILD

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,3 @@ ld_library(
2121
name = "top_earlgrey_memory",
2222
includes = ["top_earlgrey_memory.ld"],
2323
)
24-
25-
filegroup(
26-
name = "all_files",
27-
srcs = glob(["**"]),
28-
)

hw/top_earlgrey/sw/autogen/chip/BUILD

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@ load("@rules_rust//rust:defs.bzl", "rust_library")
66

77
package(default_visibility = ["//visibility:public"])
88

9-
filegroup(
10-
name = "all_files",
11-
srcs = glob(["**"]),
12-
)
13-
149
rust_library(
1510
name = "top_earlgrey",
16-
srcs = [":all_files"],
11+
srcs = glob(["*.rs"]),
1712
crate_root = "mod.rs",
1813
)

hw/ip_templates/flash_ctrl/BUILD renamed to hw/vendor/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ package(default_visibility = ["//visibility:public"])
66

77
filegroup(
88
name = "all_files",
9-
srcs = glob(["**"]),
9+
srcs = glob(
10+
["**"],
11+
),
1012
)

0 commit comments

Comments
 (0)