// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
{
  name: "prim_alert"
  testpoints: [
    {
      name: prim_alert_request_test
      desc: '''Verify alert request from prim_alert_sender.

            - Send an alert request by driving `alert_req` pin to 1.
            - Verify that `alert_ack` signal is set and the alert handshake completes.
            - If the alert is fatal, verify if the alert continuous fires until a reset is
              issued.
            '''
      stage: V1
      tests: ["prim_async_alert",
              "prim_async_fatal_alert",
              "prim_sync_alert",
              "prim_sync_fatal_alert"]
    }

    {
      name: prim_alert_test
      desc: '''Verify alert test request from prim_alert_sender.

             - Send an alert test request by driving `alert_test` pin to 1.
             - Verify that alert handshake completes and `alert_ack` signal stays low.
            '''
      stage: V1
      tests: ["prim_async_alert",
              "prim_async_fatal_alert",
              "prim_sync_alert",
              "prim_sync_fatal_alert"]
    }

    {
      name: prim_alert_ping_request_test
      desc: '''Verify ping request from prim_alert_sender.

            - Send a ping request by driving `ping_req` pin to 1.
            - Verify that `ping_ok` signal is set and ping handshake completes.
            '''
      stage: V1
      tests: ["prim_async_alert",
              "prim_async_fatal_alert",
              "prim_sync_alert",
              "prim_sync_fatal_alert"]
    }

    {
      name: prim_alert_init_trigger_test
      desc: '''Verify init_trigger input from prim_alert_receiver.

            This test is based on previous tests:
            - Based on the prim_alert_request_test, this test adds a parallel sequence to randomly
              drive `init_trigger_i` in prim_alert_receiver.
              Check if `alert_ack_o` returns 1 and check if alert sender/receiver pairs can resume
              normal handshake after alert init finishes.
              For fatal alert, check if fatal alerts keep firing until reset is issued.
            - Based on prim_alert_ping_request_test, this test adds a parallel sequence to randomly
              drive `init_trigger_i` in prim_alert_receiver.
              Check `ping_ok` returns 1.
            '''
      stage: V2
      tests: ["prim_async_alert",
              "prim_async_fatal_alert",
              "prim_sync_alert",
              "prim_sync_fatal_alert"]
    }

    {
      name: prim_alert_integrity_errors_test
      desc: '''Verify the integrity errors from the prim_alert_sender and prim_alert_receiver pair.

            1). `Ack_p/n` integrity error:
                - Send an alert request by driving `alert_req` pin to 1.
                - Force `ack_p` signal to stay low to trigger an integrity error.
                - Verify that prim_alert_receiver can identify the integrity error by setting
                  `integ_fail_o` output to 1.
            2). `Ping_p/n` integrity error:
                - Send a ping request by driving `ping_req` to 1.
                - Force `ping_n` signal to 1 to trigger an integrity error.
                - Verify that prim_alert_receiver can identify the integrity error by setting
                  `integ_fail_o` output to 1.
            '''
      stage: V1
      tests: ["prim_async_alert",
              "prim_async_fatal_alert",
              "prim_sync_alert",
              "prim_sync_fatal_alert"]
    }

    {
      name: prim_alert_gate_sender_clk_rst_test
      desc: '''Gate prim_alert_sender clk or reset during alert_handshake.

            - During alert handshake, gate prim_alert_sender's clock or issue reset.
            - Verify alert handshake can resume after prim_alert_sender is re-initialized.
            - If clock was gated, verify alert handshake will resume when clock is active,
              and verify we will never miss or drop an alert handshake by expecting `alert_ack_o`
              to return 1 after `alert_req` is sent.
            '''
      stage: V3
      tests: []
    }
  ]
}
