blob: d9ebbd8c957baf1bb1bd5f7af2410de95537183c [file] [log] [blame]
Weicai Yangfbf2edc2021-09-27 15:31:08 -07001// Copyright lowRISC contributors.
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5package 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 Yange2d7b132022-02-01 17:20:32 -080019 SecCmPrimSparseFsmFlop,
Weicai Yang6d211c02022-06-03 17:02:02 -070020 SecCmPrimDoubleLfsr,
21 SecCmPrimOnehot
Weicai Yangfbf2edc2021-09-27 15:31:08 -070022 } 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 Iyer46f89e62022-08-17 17:24:00 -070028
Weicai Yang2e580f02022-12-15 15:18:45 -080029 // coverage enable knob
30 bit en_sec_cm_cov = 1;
31
Srikrishna Iyer46f89e62022-08-17 17:24:00 -070032 // 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 Iyere20e05e2022-11-09 18:14:09 -080036 // 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 Iyer46f89e62022-08-17 17:24:00 -070038 sec_cm_base_if_proxy proxies[$];
Srikrishna Iyere20e05e2022-11-09 18:14:09 -080039 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 Maturana5d51fa82023-01-04 11:30:10 -080045 `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 Iyere20e05e2022-11-09 18:14:09 -080051 return proxies[0];
Guillermo Maturana5d51fa82023-01-04 11:30:10 -080052 end else `uvm_fatal(msg_id, $sformatf("find_sec_cm_if_proxy: no proxy with path %s", path))
Srikrishna Iyere20e05e2022-11-09 18:14:09 -080053 return null;
Srikrishna Iyer46f89e62022-08-17 17:24:00 -070054 endfunction
55
Guillermo Maturana5d51fa82023-01-04 11:30:10 -080056 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 Yangfbf2edc2021-09-27 15:31:08 -070065endpackage