// 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_esc"
  testpoints: [
    {
      name: prim_esc_request_test
      desc: '''Verify escalation request from prim_esc_sender.

            - Send an escalation request by driving `esc_req` pin to 1.
            - Wait random length of cycles and verify `esc_en` output is set and `integ_fail`
              output remains 0.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

    {
      name: prim_ping_req_interrupted_by_esc_req_test
      desc: '''Verify prim_esc will process the esc_req when ping handshake is in progress.

            - Send a ping request by driving `ping_req` pin to 1.
            - Randomly wait a few cycles before the ping handshake is completed.
            - Send an escalation request by driving `esc_req` pin to 1.
            - Wait for `ping_ok` to set and `esc_req_out` to set.
            - Check the sequence completes without any signal integrity error.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

    {
      name: prim_esc_tx_integrity_errors_test
      desc: '''Verify `esc_tx` signal integrity error.

            - Send an escalation request by driving `esc_req` pin to 1.
            - Force `esc_n` signal to stay high to trigger an integrity error.
            - Verify that prim_esc_sender identifies the error by setting `integ_fail` signal.
            - Release the `esc_n` signal.
            - Send a ping request and repeat the above sequence and checks.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

    {
      name: prim_esc_reverse_ping_timeout_test
      desc: '''Verify prim_esc_receiver detects ping timeout.

            - Send a ping request by driving `ping_req` pin to 1.
            - Wait for ping handshake to finish and `ping_ok` signal is set.
            - Verify that `esc_en` output remains 0 and `integ_fail` output remains 0.
            - Drive `ping_req` signal back to 0 and wait until ping counter timeout.
            - Verify that `prim_esc_receiver` detects the ping timeout by setting `esc_en` output
              to 1.
            - Reset the DUT to clear `esc_en` output.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

    {
      name: prim_esc_receiver_counter_fail_test
      desc: '''Verify prim_esc_receiver detects counter mismatch.

            - Send a ping request by driving `ping_req` pin to 1.
            - Wait until `ping_ok` output sets to 1, which means the two counters start.
            - Force one of the two identical counters to 0.
            - Verify that prim_esc_receiver detects the counter mismatch and set `esc_en` signal to
              1.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

    {
      name: prim_esc_handshake_with_rand_reset_test
      desc: '''Verify alert request from prim_alert_sender.

            - Send a ping request by driving `ping_req` pin to 1.
            - Randomly issue reset during the escalation handshake.
            - Verify that after reset, the prim_esc_sender and prim_esc_receiver pair functions
              correctly by issuing the tests above.
            '''
      stage: V1
      tests: ["prim_esc_test"]
    }

  ]
}
