|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +`ifndef I3C_SVA |
| 16 | +`define I3C_SVA |
| 17 | + |
| 18 | +// Default clk and reset signals used by assertion macros below. |
| 19 | +`define I3C_ASSERT_DEFAULT_CLK clk_i |
| 20 | +`define I3C_ASSERT_DEFAULT_RST !rst_ni |
| 21 | + |
| 22 | +// Converts an arbitrary block of code into a Verilog string |
| 23 | +`define STRINGIFY(__x) `"__x`" |
| 24 | + |
| 25 | +// I3C_ASSERT_RPT is available to change the reporting mechanism when an assert fails |
| 26 | +`define I3C_ASSERT_RPT(name) \ |
| 27 | +`ifdef UVM \ |
| 28 | + uvm_pkg::uvm_report_error("I3C ASSERT FAILED", name, uvm_pkg::UVM_NONE, \ |
| 29 | + `__FILE__, `__LINE__); \ |
| 30 | +`else \ |
| 31 | + $fatal(1, "[I3C_ASSERT FAILED] [%m] %s (%s:%0d)",name, `__FILE__, `__LINE__); \ |
| 32 | +`endif |
| 33 | + |
| 34 | +// Assert a concurrent property directly. |
| 35 | +`define I3C_ASSERT(assert_name, prop, clk = `I3C_ASSERT_DEFAULT_CLK, rst = `I3C_ASSERT_DEFAULT_RST) \ |
| 36 | +`ifdef CLP_ASSERT_ON \ |
| 37 | + assert_name: assert property (@(posedge clk) disable iff (rst !== 0) (prop)) \ |
| 38 | + else begin \ |
| 39 | + `I3C_ASSERT_RPT(`STRINGIFY(assert_name)) \ |
| 40 | + end \ |
| 41 | +`endif |
| 42 | + |
| 43 | +// Assert a concurrent property NEVER happens |
| 44 | +`define I3C_ASSERT_NEVER(assert_name, prop, clk = `I3C_ASSERT_DEFAULT_CLK, rst = `I3C_ASSERT_DEFAULT_RST) \ |
| 45 | +`ifdef CLP_ASSERT_ON \ |
| 46 | + assert_name: assert property (@(posedge clk) disable iff (rst !== 0) not (prop)) \ |
| 47 | + else begin \ |
| 48 | + `I3C_ASSERT_RPT(`STRINGIFY(assert_name)) \ |
| 49 | + end \ |
| 50 | +`endif |
| 51 | + |
| 52 | +// Assert that signal is not x |
| 53 | +`define I3C_ASSERT_KNOWN(assert_name, sig, clk = `I3C_ASSERT_DEFAULT_CLK, rst = `I3C_ASSERT_DEFAULT_RST) \ |
| 54 | + `I3C_ASSERT(assert_name, !$isunknown(sig), clk, rst) |
| 55 | + |
| 56 | +// Assert that a vector of signals is mutually exclusive |
| 57 | +`define I3C_ASSERT_MUTEX(assert_name, sig, clk = `I3C_ASSERT_DEFAULT_CLK, rst = `I3C_ASSERT_DEFAULT_RST) \ |
| 58 | + `I3C_ASSERT(assert_name, $onehot0(sig), clk, rst) |
| 59 | + |
| 60 | +`define I3C_ASSERT_INIT(__name, __prop) |
| 61 | +`endif |
0 commit comments