blob: 75e10849e785d5b4173d812c4c8b1ca0d71a9246 [file]
# Copyright 2023 Google LLC
# 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("@lowrisc_opentitan//rules:splice.bzl", "bitstream_splice")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//rules:targets.bzl", "get_targets")
package(default_visibility = ["//visibility:public"])
# The readmem directives in the fusesoc-ized build tree will be in the subdir
# ${build_root}/src/lowrisc_prim_util_memload_0/rtl/prim_util_memload.svh,
# and ${build_root} will be a subdirectory called `build.fpga_nexus` inside of
# bazel-out/k8-{configname}/bin/hw/bitstream/vivado.
# Therefore, the relative path between prim_util_memload.svh and the project-root
# relative $(location ...) resolved labels is up 10 subdirectories.
_PREFIX = "../../../../../../../../../.."
TARGETS = get_targets()
_FPGA_NEXUS_TESTROM = ["//sw/device/lib/testing/test_rom:{}_test_rom_fpga_nexus_scr_vmem".format(target) for target in TARGETS]
_FPGA_NEXUS_OTP_RMA = ["//hw/top_{}/data:otp_img_rma".format(target) for target in TARGETS]
_FPGA_NEXUS_TESTROM_PATHS = ["{}/$(location {})".format(_PREFIX, TESTROM) for TESTROM in _FPGA_NEXUS_TESTROM]
_FPGA_NEXUS_OTP_RMA_PATHS = ["{}/$(location {})".format(_PREFIX, OTP_IMG) for OTP_IMG in _FPGA_NEXUS_OTP_RMA]
_FPGA_NEXUS_TARGET_INFO = zip(
get_targets(),
_FPGA_NEXUS_TESTROM,
_FPGA_NEXUS_TESTROM_PATHS,
_FPGA_NEXUS_OTP_RMA,
_FPGA_NEXUS_OTP_RMA_PATHS,
)
# Note: all of the targets are tagged with "manual" to prevent them from being
# matched by bazel wildcards like "//...". In order to build the bitstream,
# you need to ask for it directly or by dependency via another rule, such as
# a functest.
[fusesoc_build(
name = "{}_fpga_nexus".format(target),
testonly = True,
srcs = [
"//hw:all_files",
TESTROM,
OTP_IMG,
],
cores = [
"//:cores",
"//hw/ip:BUILD",
"//hw/top_{}:BUILD".format(target),
],
data = ["@lowrisc_opentitan//hw/ip/otbn:all_files"],
flags = [
"--BootRomInitFile=" + TESTROM_PATH,
"--OtpCtrlMemInitFile=" + OTP_PATH,
],
output_groups = {
"bitstream": ["synth-vivado/google_systems_chip_{}_nexus_0.1.bit".format(target)],
"rom_mmi": ["synth-vivado/rom.mmi"],
"otp_mmi": ["synth-vivado/otp.mmi"],
"logs": [
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/synth_1/runme.log".format(target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/runme.log".format(target),
"synth-vivado/vivado.log",
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/synth_1/chip_{}_nexus_utilization_synth.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_power_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_utilization_placed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_bus_skew_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_drc_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_io_placed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_timing_summary_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_control_sets_placed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_methodology_drc_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_drc_opted.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_clock_utilization_routed.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/chip_{}_nexus_route_status.rpt".format(target, target),
"synth-vivado/google_systems_chip_{}_nexus_0.1.runs/impl_1/utilization_kelvin.rpt".format(target, target),
],
},
systems = ["google:systems:chip_{}_nexus".format(target)],
tags = ["manual"],
target = "synth",
use_system_fusesoc = True,
) for target, TESTROM, TESTROM_PATH, OTP_IMG, OTP_PATH in _FPGA_NEXUS_TARGET_INFO]
[filegroup(
name = "{}_fpga_nexus_test_rom".format(target),
testonly = True,
srcs = [":{}_fpga_nexus".format(target)],
output_group = "bitstream",
tags = ["manual"],
) for target in TARGETS]
[filegroup(
name = "{}_rom_mmi".format(target),
testonly = True,
srcs = [":{}_fpga_nexus".format(target)],
output_group = "rom_mmi",
tags = ["manual"],
) for target in TARGETS]
[filegroup(
name = "{}_otp_mmi".format(target),
testonly = True,
srcs = [":{}_fpga_nexus".format(target)],
output_group = "otp_mmi",
tags = ["manual"],
) for target in TARGETS]
[filegroup(
name = "{}_logs".format(target),
testonly = True,
srcs = [":{}_fpga_nexus".format(target)],
output_group = "logs",
tags = ["manual"],
) for target in TARGETS]
[bitstream_splice(
name = "{}_fpga_nexus_mask_test_rom".format(target),
testonly = True,
src = ":{}_fpga_nexus_test_rom".format(target),
data = "//sw/device/lib/testing/test_rom:{}_test_rom_fpga_nexus_scr_vmem".format(target),
meminfo = ":{}_rom_mmi".format(target),
tags = ["manual"],
) for target in TARGETS]
[bitstream_splice(
name = "{}_fpga_nexus_mask_puppeteer_rom".format(target),
testonly = True,
src = ":{}_fpga_nexus_test_rom".format(target),
data = "//sw/device/lib/testing/test_rom:{}_puppeteer_rom_fpga_nexus_scr_vmem".format(target),
meminfo = ":{}_rom_mmi".format(target),
tags = ["manual"],
) for target in TARGETS]
[bitstream_splice(
name = "{}_fpga_nexus_mask_test_rom_no_otp".format(target),
testonly = True,
src = ":{}_fpga_nexus_test_rom".format(target),
data = "//sw/device/lib/testing/test_rom:{}_test_rom_no_otp_fpga_nexus_scr_vmem".format(target),
meminfo = ":{}_rom_mmi".format(target),
tags = ["manual"],
) for target in TARGETS]
[bitstream_splice(
name = "{}_fpga_nexus_mask_test_rom_no_otp_empty".format(target),
testonly = True,
src = ":{}_fpga_nexus_mask_test_rom_no_otp".format(target),
data = "//hw/top_{}/data:otp_img_empty".format(target),
meminfo = ":{}_otp_mmi".format(target),
tags = ["manual"],
) for target in TARGETS]
[pkg_tar(
name = "{}_fpga_nexus_smoketest".format(target),
testonly = True,
srcs = [
":{}_fpga_nexus_mask_test_rom".format(target),
":{}_fpga_nexus_mask_test_rom_no_otp_empty".format(target),
":{}_logs".format(target),
":{}_otp_mmi".format(target),
":{}_rom_mmi".format(target),
"//sw/device/examples/hello_world_multicore:hello_world_multicore_sc_embedded_fpga_nexus_bin",
],
extension = "tar.gz",
mode = "0755",
strip_prefix = "/",
tags = ["manual"],
) for target in TARGETS]