Support airgapped bitstream/DV flow
Allow using an archive path for some cores to build bitstream targets in an
air-gapped environment. The files of the cores are expected to be built
offline
To enable the config for bitstream, run
bazel build --config=airgapped_env <bitstream target>
For DV, add airgapped cores-root path allowing fusesoc to find the
chisel-built cores.
Test: bazel cquery "deps(//hw/bitstream/vivado:fpga_nexus)"
[--//rules:build_env='airgapped'] and check
dependencies
Change-Id: I6ca0d9a3d501f065d173437a084cad34bbd0f0bb
diff --git a/.bazelrc b/.bazelrc
index 43d1234..a4341dc 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -28,6 +28,9 @@
build:kelvin --platforms=//platforms/riscv32:kelvin
build:sparrow --platforms=@matcha//platforms/riscv32:sparrow
+# Support airgapped build environment
+build:airgapped_env --//rules:build_env='airgapped'
+
# Shared configuration for clang's source-based coverage instrumentation.
# Bazel seems to support this only partially, thus we have to perform some
# additional processing. See
diff --git a/BUILD.bazel b/BUILD.bazel
index 0f0a46b..b131709 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -11,13 +11,20 @@
# Add a file from each directory and let fusesoc to pick the directory.
"@lowrisc_opentitan//hw/dv:BUILD",
"@lowrisc_opentitan//hw/ip:BUILD",
- "@kelvin_hw//hdl/chisel:kelvin.core",
- "//hw/top_matcha/ip/dma/chisel:fastvdma.core",
"@lowrisc_opentitan//hw/lint:BUILD",
"@lowrisc_opentitan//hw/vendor:BUILD",
# Place the following file to make compilation works
"//hw:check_tool_requirements.core",
"@axi2sramcrs//:BUILD",
"@isp_yocto//:BUILD",
- ],
+ ] + select({
+ "//rules:airgapped_env": [
+ "@fastvdma_core//:fastvdma.core",
+ "@kelvin_core//:kelvin.core",
+ ],
+ "//conditions:default": [
+ "//hw/top_matcha/ip/dma/chisel:fastvdma.core",
+ "@kelvin_hw//hdl/chisel:kelvin.core",
+ ],
+ }),
)
diff --git a/WORKSPACE b/WORKSPACE
index e805e27..84eff09 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -38,6 +38,35 @@
path = "../../out/kelvin/sw/bazel_out",
)
+# Used by airgapped environment
+new_local_repository(
+ name = "kelvin_core",
+ build_file_content = """
+exports_files(glob(["**"]))
+
+filegroup(
+ name = "all_files",
+ srcs = glob(["*.*"]),
+ visibility = ["//visibility:public"],
+)
+ """,
+ path = "../../out/kelvin/hw/kelvin_core",
+)
+
+# Used by airgapped environment
+new_local_repository(
+ name = "fastvdma_core",
+ build_file_content = """
+exports_files(glob(["**"]))
+filegroup(
+ name = "all_files",
+ srcs = glob(["*.*"]),
+ visibility = ["//visibility:public"],
+)
+ """,
+ path = "../../out/matcha/hw/fastvdma_core",
+)
+
# CRT is the Compiler Repository Toolkit. It contains the configuration for
# the windows compiler.
load("@lowrisc_opentitan//third_party/crt:repos.bzl", "crt_repos")
diff --git a/hw/BUILD b/hw/BUILD
index e763510..ec4c0d3 100644
--- a/hw/BUILD
+++ b/hw/BUILD
@@ -3,8 +3,8 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
-load("@lowrisc_opentitan//rules:fusesoc.bzl", "fusesoc_build")
load("@bazel_skylib//rules:common_settings.bzl", "string_list_flag")
+load("@lowrisc_opentitan//rules:fusesoc.bzl", "fusesoc_build")
package(default_visibility = ["//visibility:public"])
@@ -82,8 +82,15 @@
name = "all_files",
srcs = glob(["**"]) + [
"//hw/top_matcha:all_files",
- "@kelvin_hw//hdl/chisel:matcha_kelvin_verilog",
- "@kelvin_hw//hdl/chisel:kelvin.core",
"@lowrisc_opentitan//hw/dv:all_files",
- ],
+ ] + select({
+ "//rules:airgapped_env": [
+ "@fastvdma_core//:all_files",
+ "@kelvin_core//:all_files",
+ ],
+ "//conditions:default": [
+ "//hw/top_matcha/ip/dma/chisel:fastvdma_core",
+ "@kelvin_hw//hdl/chisel:kelvin_core",
+ ],
+ }),
)
diff --git a/hw/dv/tools/dvsim/fusesoc.hjson b/hw/dv/tools/dvsim/fusesoc.hjson
index 522e5a6..3337b7a 100644
--- a/hw/dv/tools/dvsim/fusesoc.hjson
+++ b/hw/dv/tools/dvsim/fusesoc.hjson
@@ -14,6 +14,8 @@
fusesoc_cores_root_dirs: ["--cores-root {titan_root}/hw/ip",
"--cores-root {proj_root}/bazel-bin/external/kelvin_hw/hdl/chisel",
"--cores-root {proj_root}/bazel-bin/hw/top_matcha/ip/dma/chisel",
+ "--cores-root {proj_root}/../../out/kelvin/hw/kelvin_core",
+ "--cores-root {proj_root}/../../out/matcha/hw/fastvdma_core",
"--cores-root {titan_root}/hw/dv/sv",
"--cores-root {titan_root}/hw/dv/verilator",
"--cores-root {titan_root}/hw/formal",
diff --git a/rules/BUILD b/rules/BUILD
index d21803e..a10bb72 100644
--- a/rules/BUILD
+++ b/rules/BUILD
@@ -2,8 +2,9 @@
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
-load("//rules:matcha.bzl", "OPENTITAN_PLATFORM")
load("@bazel_skylib//lib:selects.bzl", "selects")
+load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
+load("//rules:matcha.bzl", "OPENTITAN_PLATFORM")
package(default_visibility = ["//visibility:public"])
@@ -24,5 +25,20 @@
selects.config_setting_group(
name = "sparrow_platform",
- match_any = [":sparrow_platform_internal", ":sparrow_platform_external"],
+ match_any = [
+ ":sparrow_platform_internal",
+ ":sparrow_platform_external",
+ ],
+)
+
+string_flag(
+ name = "build_env",
+ build_setting_default = "",
+)
+
+config_setting(
+ name = "airgapped_env",
+ flag_values = {
+ ":build_env": "airgapped",
+ },
)