Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[multitop_dev] Test PR #25317

Merged
merged 6 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hw/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ string_list_flag(
fusesoc_build(
name = "verilator_real",
srcs = [
"//hw/top",
"//hw/top:top_desc",
],
cores = [
"//:cores",
Expand Down
6 changes: 3 additions & 3 deletions hw/bitstream/vivado/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fusesoc_build(
name = "fpga_cw310",
testonly = True,
srcs = [
"//hw/top",
"//hw/top:top_desc",
_CW310_TESTROM,
_OTP_RMA,
],
Expand Down Expand Up @@ -90,7 +90,7 @@ fusesoc_build(
name = "fpga_cw310_hyperdebug",
testonly = True,
srcs = [
"//hw/top",
"//hw/top:top_desc",
_CW310_TESTROM,
_OTP_RMA,
],
Expand Down Expand Up @@ -140,7 +140,7 @@ fusesoc_build(
name = "fpga_cw340",
testonly = True,
srcs = [
"//hw/top",
"//hw/top:top_desc",
_CW340_TESTROM,
_OTP_RMA,
],
Expand Down
51 changes: 33 additions & 18 deletions hw/top/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load(
"//rules:autogen.bzl",
"opentitan_ip_c_header",
Expand All @@ -14,42 +15,56 @@ load("//hw/top:defs.bzl", IPS = "OPENTITAN_ALL_IPS")

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

# FIXME rework that properly with platforms
constraint_setting(
name = "top_setting",
default_constraint_value = ":top_earlgrey",
)
ALL_TOPS = [
"earlgrey",
"darjeeling",
]

constraint_value(
name = "top_earlgrey",
constraint_setting = ":top_setting",
# Use this flag to select the top.
string_flag(
name = "top",
build_setting_default = "earlgrey",
values = ALL_TOPS,
)

# Config settings to test against tops.
[
config_setting(
name = "is_{}".format(top),
flag_values = {
":top": top,
},
)
for top in ALL_TOPS
]

alias(
name = "top",
name = "top_desc",
actual = select(
{
":top_earlgrey": "//hw/top_earlgrey",
":is_earlgrey": "//hw/top_earlgrey",
":is_darjeeling": "//hw/top_darjeeling",
},
no_match_error = "no top selected",
no_match_error = "unknown top",
),
)

alias(
name = "top_lib",
actual = select(
{
":top_earlgrey": "//hw/top_earlgrey/sw/autogen:top_earlgrey",
":is_earlgrey": "//hw/top_earlgrey/sw/autogen:top_earlgrey",
":is_darjeeling": "//hw/top_darjeeling/sw/autogen:top_darjeeling",
},
no_match_error = "no top selected",
no_match_error = "unknown top",
),
)

[
opentitan_ip_c_header(
name = "{}_c_regs".format(ip),
ip = ip,
top = ":top",
top = ":top_desc",
)
for ip in IPS
]
Expand All @@ -58,22 +73,22 @@ alias(
opentitan_ip_rust_header(
name = "{}_rust_regs".format(ip),
ip = ip,
top = ":top",
top = ":top_desc",
)
for ip in IPS
]

opentitan_top_dt_api(
name = "dt_api",
top = ":top",
top = ":top_desc",
deps = [":top_lib"],
)

[
opentitan_ip_dt_header(
name = "dt_{}".format(ip),
ip = ip,
top = ":top",
top = ":top_desc",
deps = [":dt_api"],
)
for ip in IPS
Expand All @@ -87,6 +102,6 @@ cc_library(

opentitan_top_devicetables(
name = "devicetables",
top = ":top",
top = ":top_desc",
deps = [":dt_headers"],
)
18 changes: 18 additions & 0 deletions hw/top/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,21 @@ OPENTITAN_ALL_IPS = [
"uart",
"usbdev",
]

def opentitan_require_top(top_name):
"""
Use this macro in the `target_compatible_with` attribute of
a rule to express the requirement that this target should only
be considered for a particular top.

Example:
cc_library(
name = "bla",
...
target_compatible_with = opentitan_require_top("earlgrey"),
)
"""
return select({
"//hw/top:is_{}".format(top_name): [],
"//conditions:default": ["@platforms//:incompatible"],
})
11 changes: 6 additions & 5 deletions hw/top_darjeeling/ip/ast/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("//rules/opentitan:hw.bzl", "opentitan_ip")

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

filegroup(
name = "all_files",
srcs = glob(["**"]) + [
"//hw/top_darjeeling/ip/ast/data:all_files",
],
opentitan_ip(
name = "ast",
files = glob(["**"]),
hjson = "//hw/top_darjeeling/ip/ast/data:hjson",
)
24 changes: 2 additions & 22 deletions hw/top_darjeeling/ip/ast/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@

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

load(
"//rules:autogen.bzl",
"autogen_hjson_c_header",
"autogen_hjson_rust_header",
)

autogen_hjson_c_header(
name = "ast_c_regs",
srcs = [
"ast.hjson",
],
)

autogen_hjson_rust_header(
name = "ast_rust_regs",
srcs = [
"ast.hjson",
],
)

filegroup(
name = "all_files",
srcs = glob(["**"]),
name = "hjson",
srcs = ["ast.hjson"],
)
11 changes: 6 additions & 5 deletions hw/top_darjeeling/ip/sensor_ctrl/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

load("//rules/opentitan:hw.bzl", "opentitan_ip")

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

filegroup(
name = "all_files",
srcs = glob(["**"]) + [
"//hw/top_darjeeling/ip/sensor_ctrl/data:all_files",
],
opentitan_ip(
name = "sensor_ctrl",
files = glob(["**"]),
hjson = "//hw/top_darjeeling/ip/sensor_ctrl/data:hjson",
)
24 changes: 2 additions & 22 deletions hw/top_darjeeling/ip/sensor_ctrl/data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@

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

load(
"//rules:autogen.bzl",
"autogen_hjson_c_header",
"autogen_hjson_rust_header",
)

autogen_hjson_c_header(
name = "sensor_ctrl_c_regs",
srcs = [
"sensor_ctrl.hjson",
],
)

autogen_hjson_rust_header(
name = "sensor_ctrl_rust_regs",
srcs = [
"sensor_ctrl.hjson",
],
)

filegroup(
name = "all_files",
srcs = glob(["**"]),
name = "hjson",
srcs = ["sensor_ctrl.hjson"],
)
29 changes: 6 additions & 23 deletions hw/top_darjeeling/ip_autogen/clkmgr/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

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

load(
"//rules:autogen.bzl",
"autogen_hjson_c_header",
"autogen_hjson_rust_header",
)
load("//rules/opentitan:hw.bzl", "opentitan_ip")

autogen_hjson_c_header(
name = "clkmgr_c_regs",
srcs = [
"data/clkmgr.hjson",
],
)

autogen_hjson_rust_header(
name = "clkmgr_rust_regs",
srcs = [
"data/clkmgr.hjson",
],
)
package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_files",
srcs = glob(["**"]),
opentitan_ip(
name = "clkmgr",
files = glob(["**"]),
hjson = "data/clkmgr.hjson",
)
29 changes: 6 additions & 23 deletions hw/top_darjeeling/ip_autogen/pinmux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

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

load(
"//rules:autogen.bzl",
"autogen_hjson_c_header",
"autogen_hjson_rust_header",
)
load("//rules/opentitan:hw.bzl", "opentitan_ip")

autogen_hjson_c_header(
name = "pinmux_c_regs",
srcs = [
"data/pinmux.hjson",
],
)

autogen_hjson_rust_header(
name = "pinmux_rust_regs",
srcs = [
"data/pinmux.hjson",
],
)
package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_files",
srcs = glob(["**"]),
opentitan_ip(
name = "pinmux",
files = glob(["**"]),
hjson = "data/pinmux.hjson",
)
29 changes: 6 additions & 23 deletions hw/top_darjeeling/ip_autogen/pwrmgr/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,12 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

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

load(
"//rules:autogen.bzl",
"autogen_hjson_c_header",
"autogen_hjson_rust_header",
)
load("//rules/opentitan:hw.bzl", "opentitan_ip")

autogen_hjson_c_header(
name = "pwrmgr_c_regs",
srcs = [
"data/pwrmgr.hjson",
],
)

autogen_hjson_rust_header(
name = "pwrmgr_rust_regs",
srcs = [
"data/pwrmgr.hjson",
],
)
package(default_visibility = ["//visibility:public"])

filegroup(
name = "all_files",
srcs = glob(["**"]),
opentitan_ip(
name = "pwrmgr",
files = glob(["**"]),
hjson = "data/pwrmgr.hjson",
)
Loading
Loading