blob: 66ffc19ea1ed2c7d4e8725c2d311f3957427326c [file] [log] [blame]
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
"""Helper macros for generating RISC-V compliance test targets."""
load("//rules:opentitan_test.bzl", "opentitan_functest", "verilator_params")
def rv_compliance_test(name, arch):
test_file = "@riscv-compliance//:riscv-test-suite/{}/src/{}.S".format(arch, name)
reference_output = "@riscv-compliance//:riscv-test-suite/{}/references/{}.reference_output".format(arch, name)
expected_signature = "{}.expected_signature.S".format(name)
native.genrule(
name = "{}_expected_signature".format(name),
srcs = [reference_output],
outs = [expected_signature],
cmd = """
echo "kExpectedSignature:" >> $@
echo ".global kExpectedSignature" >> $@
perl -pe 's/([a-fA-F0-9]+)/.word 0x$$1/' \
$(location {}) \
>> $@
""".format(reference_output),
)
opentitan_functest(
name = name,
srcs = [
test_file,
expected_signature,
"compliance_main.c",
"compliance_main.S",
],
verilator = verilator_params(
timeout = "long",
),
linkopts = ["-Wl,--no-relax"],
deps = [
"//sw/device/lib/testing/test_framework:ottf_main",
"@riscv-compliance//:riscv-test-env",
],
)
TESTS = {
"rv32i": [
"I-ADD-01",
"I-ADDI-01",
"I-AND-01",
"I-ANDI-01",
"I-AUIPC-01",
"I-BEQ-01",
"I-BGE-01",
"I-BGEU-01",
"I-BLT-01",
"I-BLTU-01",
"I-BNE-01",
"I-DELAY_SLOTS-01",
# TODO(lowrisc/opentitan#11876): Failing for unnknown reasons.
#"I-EBREAK-01",
"I-ECALL-01",
"I-ENDIANESS-01",
"I-IO-01",
"I-JAL-01",
"I-JALR-01",
"I-LB-01",
"I-LBU-01",
"I-LH-01",
"I-LHU-01",
"I-LUI-01",
"I-LW-01",
# TODO(lowrisc/ibex#100): These tests are broken due to flaws in
# riscv-compliance rather than Ibex/OpenTitan.
#"I-MISALIGN_JMP-01",
#"I-MISALIGN_LDST-01",
# TODO(lowrisc/opentitan#11876): Failing for unnknown reasons.
#"I-NOP-01",
"I-OR-01",
"I-ORI-01",
"I-RF_size-01",
"I-RF_width-01",
# TODO(lowrisc/opentitan#11968): Failing do to sign-extension issue.
#"I-RF_x0-01",
"I-SB-01",
"I-SH-01",
"I-SLL-01",
"I-SLLI-01",
"I-SLT-01",
"I-SLTI-01",
"I-SLTIU-01",
"I-SLTU-01",
"I-SRA-01",
"I-SRAI-01",
"I-SRL-01",
"I-SRLI-01",
"I-SUB-01",
"I-SW-01",
"I-XOR-01",
"I-XORI-01",
],
"rv32im": [
"DIV",
"DIVU",
"MUL",
"MULH",
"MULHSU",
"MULHU",
"REM",
"REMU",
],
"rv32imc": [
"C-ADD",
"C-ADDI",
"C-ADDI16SP",
"C-ADDI4SPN",
"C-AND",
"C-ANDI",
"C-BEQZ",
"C-BNEZ",
"C-J",
"C-JAL",
"C-JALR",
"C-JR",
"C-LI",
"C-LUI",
"C-LW",
"C-LWSP",
"C-MV",
"C-OR",
"C-SLLI",
"C-SRAI",
"C-SRLI",
"C-SUB",
"C-SW",
"C-SWSP",
"C-XOR",
],
"rv32Zicsr": [
"I-CSRRC-01",
"I-CSRRCI-01",
"I-CSRRS-01",
"I-CSRRSI-01",
"I-CSRRW-01",
"I-CSRRWI-01",
],
}