| # Copyright 2023 Google LLC. | 
 | # Copyright lowRISC contributors. | 
 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. | 
 | # SPDX-License-Identifier: Apache-2.0 | 
 |  | 
 | load( | 
 |     "//rules:matcha.bzl", | 
 |     "NEXUS_CORE_TARGETS", | 
 |     "VERILATOR_CORE_TARGETS", | 
 |     "smc_flash_binary", | 
 | ) | 
 | load("//rules:matcha_test.bzl", "matcha_verilator_test") | 
 |  | 
 | package(default_visibility = ["//visibility:public"]) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_tlul_mailbox_test", | 
 |     srcs = [ | 
 |         "smc_tlul_mailbox_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:smc_ctrl", | 
 |         "//sw/device/lib/dif:tlul_mailbox", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest_def", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_cam_irq_test", | 
 |     srcs = [ | 
 |         "smc_cam_irq_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:cam_ctrl", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest_def", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_cam_i2c_test", | 
 |     srcs = [ | 
 |         "smc_cam_i2c_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     per_device_deps = { | 
 |         "fpga_nexus": [NEXUS_CORE_TARGETS.get("smc")], | 
 |     }, | 
 |     deps = [ | 
 |         "//sw/device/lib:camera_hm01b0", | 
 |         "//sw/device/lib/dif:cam_ctrl", | 
 |         "//sw/device/lib/dif:isp_wrapper", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_ml_top_irq_test", | 
 |     srcs = [ | 
 |         "smc_ml_top_irq_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:ml_top", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest_def", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "simple_smc", | 
 |     srcs = [ | 
 |         "simple_smc.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_supervisor_mode_test", | 
 |     srcs = [ | 
 |         "smc_supervisor_mode_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_virtual_memory_test", | 
 |     srcs = [ | 
 |         "smc_virtual_memory_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_interrupt_boundary_test", | 
 |     srcs = [ | 
 |         "smc_interrupt_boundary_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/lib/dif:rv_timer", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_lsu_interrupt_boundary_test", | 
 |     srcs = [ | 
 |         "smc_lsu_interrupt_boundary_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/lib/dif:rv_timer", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_page_boundary_test", | 
 |     srcs = [ | 
 |         "smc_page_boundary_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_lsu_page_boundary_test", | 
 |     srcs = [ | 
 |         "smc_lsu_page_boundary_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_atomics_test", | 
 |     srcs = [ | 
 |         "smc_atomics_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |         "-march=rv32imac", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib:virtual_memory", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_rv_timer_test", | 
 |     srcs = [ | 
 |         "smc_rv_timer_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/lib/dif:rv_timer", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_env_test", | 
 |     srcs = [ | 
 |         "smc_env_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_isp_wrapper_test", | 
 |     srcs = [ | 
 |         "smc_isp_wrapper_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:isp_wrapper", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_isp_wrapper_tpg_128_64_test", | 
 |     srcs = [ | 
 |         "smc_isp_wrapper_tpg_128_64_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:isp_wrapper", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_kelvin_hello_test", | 
 |     srcs = [ | 
 |         "smc_kelvin_hello_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     per_device_deps = { | 
 |         "sim_verilator": [VERILATOR_CORE_TARGETS.get("smc")], | 
 |         "sim_dv": ["//sw/device/lib/arch:smc_sim_dv"], | 
 |     }, | 
 |     deps = [ | 
 |         "//hw/ip/ml_top/data:ml_top_regs", | 
 |         "//sw/device/lib/dif:ml_top", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_kelvin_checksum_test", | 
 |     srcs = [ | 
 |         "smc_kelvin_checksum_test.c", | 
 |         "//sw/device/tests/testdata:test_image.h", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     per_device_deps = { | 
 |         "sim_verilator": [VERILATOR_CORE_TARGETS.get("smc")], | 
 |         "sim_dv": ["//sw/device/lib/arch:smc_sim_dv"], | 
 |     }, | 
 |     deps = [ | 
 |         "//hw/ip/ml_top/data:ml_top_regs", | 
 |         "//sw/device/lib/dif:ml_top", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_kelvin_model_test", | 
 |     srcs = [ | 
 |         "smc_kelvin_model_test.c", | 
 |         "//sw/device/examples/testdata:kelvin_model_ml_bin.h", | 
 |         "//sw/device/tests/testdata:test_image.h", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     per_device_deps = { | 
 |         "sim_verilator": [VERILATOR_CORE_TARGETS.get("smc")], | 
 |         "sim_dv": ["//sw/device/lib/arch:smc_sim_dv"], | 
 |     }, | 
 |     deps = [ | 
 |         "//hw/ip/ml_top/data:ml_top_regs", | 
 |         "//hw/top_matcha/sw/autogen:top_matcha", | 
 |         "//sw/device/lib/dif:ml_top", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_isp_wrapper_irq_test", | 
 |     srcs = [ | 
 |         "smc_isp_wrapper_irq_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:isp_wrapper", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest_def", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_ml_dmem_test", | 
 |     srcs = [ | 
 |         "smc_ml_dmem_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/silicon_creator/lib:manifest_def", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_i2s_rx_test", | 
 |     srcs = [ | 
 |         "smc_i2s_rx_test.c", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:i2s", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/lib/runtime:irq", | 
 |     ], | 
 | ) | 
 |  | 
 | smc_flash_binary( | 
 |     name = "smc_i2s_tx_test", | 
 |     srcs = [ | 
 |         "smc_i2s_tx_test.c", | 
 |         "//sw/device/tests/testdata:i2s_440hz_audio_tx.h", | 
 |     ], | 
 |     copts = [ | 
 |         "-nostdlib", | 
 |         "-ffreestanding", | 
 |     ], | 
 |     deps = [ | 
 |         "//sw/device/lib/dif:i2s", | 
 |         "//sw/device/lib/dif:rv_plic_smc", | 
 |         "//sw/device/tests:test_lib_smc", | 
 |         "@lowrisc_opentitan//sw/device/lib/runtime:irq", | 
 |     ], | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_kelvin_hello_test", | 
 |     ml_flash_binary = "//sw/device/tests/kelvin:kelvin_hello_world.elf", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_kelvin_hello_test", | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_ml_top_irq_test", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_ml_top_irq_test", | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_smc_isp_wrapper_test", | 
 |     timeout = "long", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_isp_wrapper_test", | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_smc_isp_wrapper_irq_test", | 
 |     timeout = "long", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_isp_wrapper_irq_test", | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_smc_isp_wrapper_tpg_128_64_test", | 
 |     timeout = "long", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_isp_wrapper_tpg_128_64_test", | 
 | ) | 
 |  | 
 | matcha_verilator_test( | 
 |     name = "verilator_kelvin_checksum_test", | 
 |     timeout = "long", | 
 |     ml_flash_binary = "//sw/device/tests/kelvin:kelvin_checksum.elf", | 
 |     sec_flash_binary = "//sw/device/tests:simple_sec", | 
 |     smc_flash_binary = ":smc_kelvin_checksum_test", | 
 | ) |