Weicai Yang | fbf2edc | 2021-09-27 15:31:08 -0700 | [diff] [blame] | 1 | // Copyright lowRISC contributors. |
| 2 | // Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | // SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | package sec_cm_pkg; |
| 6 | // dep packages |
| 7 | import uvm_pkg::*; |
| 8 | import prim_alert_pkg::*; |
| 9 | |
| 10 | // macro includes |
| 11 | `include "uvm_macros.svh" |
| 12 | `include "dv_macros.svh" |
| 13 | |
| 14 | // package variables |
| 15 | string msg_id = "sec_cm_pkg"; |
| 16 | |
| 17 | typedef enum int { |
| 18 | SecCmPrimCount, |
Weicai Yang | e2d7b13 | 2022-02-01 17:20:32 -0800 | [diff] [blame] | 19 | SecCmPrimSparseFsmFlop, |
Weicai Yang | 6d211c0 | 2022-06-03 17:02:02 -0700 | [diff] [blame] | 20 | SecCmPrimDoubleLfsr, |
| 21 | SecCmPrimOnehot |
Weicai Yang | fbf2edc | 2021-09-27 15:31:08 -0700 | [diff] [blame] | 22 | } sec_cm_type_e; |
| 23 | |
| 24 | `include "sec_cm_base_if_proxy.sv" |
| 25 | |
| 26 | // store all the sec_cm proxy classes |
| 27 | sec_cm_base_if_proxy sec_cm_if_proxy_q[$]; |
Srikrishna Iyer | 46f89e6 | 2022-08-17 17:24:00 -0700 | [diff] [blame] | 28 | |
Weicai Yang | 2e580f0 | 2022-12-15 15:18:45 -0800 | [diff] [blame] | 29 | // coverage enable knob |
| 30 | bit en_sec_cm_cov = 1; |
| 31 | |
Srikrishna Iyer | 46f89e6 | 2022-08-17 17:24:00 -0700 | [diff] [blame] | 32 | // Finds and returns a sec_cm interface proxy class instance from the sec_cm_if_proxy_q queue. |
| 33 | // |
| 34 | // This function matches the first instance whose `path` matches the input argument `path`. |
| 35 | // A fatal error is thrown if there is no instance in the queue that matches the path. |
Srikrishna Iyer | e20e05e | 2022-11-09 18:14:09 -0800 | [diff] [blame] | 36 | // The argument `is_regex` indicates that the `path` is not a full path, but a regular expression. |
| 37 | function automatic sec_cm_base_if_proxy find_sec_cm_if_proxy(string path, bit is_regex = 0); |
Srikrishna Iyer | 46f89e6 | 2022-08-17 17:24:00 -0700 | [diff] [blame] | 38 | sec_cm_base_if_proxy proxies[$]; |
Srikrishna Iyer | e20e05e | 2022-11-09 18:14:09 -0800 | [diff] [blame] | 39 | if (is_regex) begin |
| 40 | proxies = sec_cm_pkg::sec_cm_if_proxy_q.find_first() with (!uvm_re_match(path, item.path)); |
| 41 | end else begin |
| 42 | proxies = sec_cm_pkg::sec_cm_if_proxy_q.find_first() with (item.path == path); |
| 43 | end |
| 44 | if (proxies.size()) begin |
Guillermo Maturana | 5d51fa8 | 2023-01-04 11:30:10 -0800 | [diff] [blame] | 45 | `uvm_info(msg_id, $sformatf( |
| 46 | "find_sec_cm_if_proxy: found proxy for path %s: type = %0d, full path = %0s", |
| 47 | path, |
| 48 | proxies[0].sec_cm_type, |
| 49 | proxies[0].path |
| 50 | ), UVM_MEDIUM) |
Srikrishna Iyer | e20e05e | 2022-11-09 18:14:09 -0800 | [diff] [blame] | 51 | return proxies[0]; |
Guillermo Maturana | 5d51fa8 | 2023-01-04 11:30:10 -0800 | [diff] [blame] | 52 | end else `uvm_fatal(msg_id, $sformatf("find_sec_cm_if_proxy: no proxy with path %s", path)) |
Srikrishna Iyer | e20e05e | 2022-11-09 18:14:09 -0800 | [diff] [blame] | 53 | return null; |
Srikrishna Iyer | 46f89e6 | 2022-08-17 17:24:00 -0700 | [diff] [blame] | 54 | endfunction |
| 55 | |
Guillermo Maturana | 5d51fa8 | 2023-01-04 11:30:10 -0800 | [diff] [blame] | 56 | function automatic void list_if_proxies(uvm_verbosity verbosity = UVM_MEDIUM); |
| 57 | `uvm_info(msg_id, "The sec_cm proxies:", verbosity) |
| 58 | foreach (sec_cm_if_proxy_q[i]) begin |
| 59 | `uvm_info(msg_id, $sformatf( |
| 60 | "Path %0s, type %d", sec_cm_if_proxy_q[i].path, sec_cm_if_proxy_q[i].sec_cm_type), |
| 61 | verbosity) |
| 62 | end |
| 63 | endfunction |
| 64 | |
Weicai Yang | fbf2edc | 2021-09-27 15:31:08 -0700 | [diff] [blame] | 65 | endpackage |