SyoSil ApS UVM Scoreboard  1.0.3.0
cl_scbs_test_io_custom_filter_trfm.svh
1 //This file contains the test for a custom filter transform + some additional
2 //classes necessary to make the test work.
3 //The classes are defined here to avoid cluttering the test directory
4 //The classes are a custom filter transform, a new scoreboard implementation and the test itself (in that order)
5 //All methods are implemented in-line to keep things slightly condensed
6 
7 // Custom filter transform
8 // Implementation is the same as pk_utils_uvm::filter_trfm, but they are two entirely separate classes
9 // Also does not inherit from uvm_subscriber to prove that they can have separate base classes, so long as
10 // uvm_component is a parent
11 class my_custom_filter_trfm#(type IN = int, type OUT = uvm_sequence_item) extends uvm_component;
12  typedef my_custom_filter_trfm#(IN,OUT) this_type;
13 
14  uvm_analysis_imp#(IN, this_type) analysis_export;
15  uvm_analysis_port#(OUT) ap;
16 
17  `uvm_component_param_utils(my_custom_filter_trfm#(IN, OUT))
18 
19  function new(string name = "my_custom_filter_trfm", uvm_component parent = null);
20  super.new(name, parent);
21  this.analysis_export = new("my_analysis_imp", this);
22  this.ap = new("ap", this);
23  endfunction: new
24 
25  //Function transform
26  virtual function void transform(IN t, output OUT items[]);
27  items = new[1];
28  items[0] = t;
29  endfunction: transform
30 
31  //Function write
32  virtual function void write(IN t);
33  OUT items[];
34  this.transform(t, items);
35  foreach(items[i]) begin
36  this.ap.write(items[i]);
37  end
38  endfunction: write
39 endclass: my_custom_filter_trfm
40 
41 //Custom scoreboard implementation
42 //We need a custom scoreboard implementation since the implementation of create_filter()
43 //and connect_filter_and_subscriber() depend on the kind of filter transform that we are employing.
44 //The rest of the code is a straight copy-paste from cl_syoscbs, as the functionality is the same
45 class my_custom_syoscbs#(type FIN = int) extends cl_syoscbs_base;
46 
47  typedef my_custom_filter_trfm #(FIN, uvm_sequence_item) tp_ft;
48 
49  `uvm_component_param_utils(my_custom_syoscbs#(FIN))
50 
51  //Function new
52  function new(string name="my_custom_syoscbs", uvm_component parent=null);
53  super.new(name, parent);
54  endfunction: new
55 
56  //Function get_filter_trfm
57  virtual function tp_ft get_filter_trfm(string queue_name,
58  string producer_name,
59  int unsigned idx);
60  //Get base object, typecast to this scb's filter transform, return typecasted version
61  tp_ft ft;
62  uvm_component ft_orig;
63  ft_orig = this.get_filter_trfm_base(queue_name, producer_name, idx);
64  if(ft_orig == null) begin
65  ft = null;
66  end else begin
67  if(!$cast(ft, ft_orig)) begin
68  `uvm_fatal("TYPECAST", "Unable to typecast from uvm_component to filter transform type")
69  end
70  end
71  return ft;
72  endfunction: get_filter_trfm
73 
74  //Function build_phase
75  function void build_phase(uvm_phase phase);
76  super.build_phase(phase);
77  foreach (this.scbs[i]) begin
78  cl_syoscb_cfg tmp_cfg = this.cfg.get_cfg(i);
79  this.create_filters(i, tmp_cfg);
80  end
81  endfunction: build_phase
82 
83  //Function connect_phase
84  function void connect_phase(uvm_phase phase);
85  super.connect_phase(phase);
86  foreach (this.fts[i]) begin
87  cl_syoscb_cfg tmp_cfg = this.cfg.get_cfg(i);
88  this.connect_filters(i, tmp_cfg);
89  end
90  endfunction: connect_phase
91 
92  //Function create_filter
93  protected function void create_filter(input string queue_name,
94  input string producer_name,
95  input int unsigned idx);
96  string ft_name = $sformatf("ft_%s_%s[%0d]", queue_name, producer_name, idx);
97  this.fts[idx][queue_name][producer_name] = tp_ft::type_id::create(ft_name, this);
98  endfunction: create_filter
99 
100  //Function connect_filter_and_subscriber
101  protected function void connect_filter_and_subscriber(input string queue_name,
102  input string producer_name,
103  input int unsigned idx);
104 
105  cl_syoscb_subscriber scb_subscriber;
106  tp_ft ft;
107 
108  scb_subscriber = this.scbs[idx].get_subscriber(queue_name, producer_name);
109  ft = this.get_filter_trfm(queue_name, producer_name, idx);
110 
111  ft.ap.connect(scb_subscriber.analysis_export);
112  endfunction: connect_filter_and_subscriber
113 
114 endclass: my_custom_syoscbs
115 
116 /// SCBs test using a filter transform not inherited from pk_uvm_utils::filter_trfm, to show that all
117 /// types of filter transforms work
118 // All this test does is set a type override from cl_syoscbs_base to my_custom_syoscbs#(cl_tb_seq_item)
119 // In main phase, verifies that filters are of correct type
121  cl_tb_tlm_monitor#(cl_tb_seq_item),
122  my_custom_filter_trfm#(cl_tb_seq_item, uvm_sequence_item));
123  //-------------------------------------
124  // Non randomizable variables
125  //-------------------------------------
126 
127 
128  //-------------------------------------
129  // UVM Macros
130  //-------------------------------------
131  `uvm_component_utils(cl_scbs_test_io_custom_filter_trfm)
132 
133  //-------------------------------------
134  // Constructor
135  //-------------------------------------
136  function new(string name = "cl_scbs_test_io_custom_filter_trfm", uvm_component parent = null);
137  super.new(name, parent);
138  endfunction: new
139 
140  //-------------------------------------
141  // Functions
142  //-------------------------------------
143  extern function void pre_build();
144  extern task main_phase(uvm_phase phase);
145 
146 
148 
149 
150 function void cl_scbs_test_io_custom_filter_trfm::pre_build();
151  super.pre_build();
152  //Perform a factory override of the filter transform to be created
153  cl_syoscbs_base::type_id::set_type_override(my_custom_syoscbs#(cl_tb_seq_item)::get_type());
154 endfunction: pre_build
155 
156 task cl_scbs_test_io_custom_filter_trfm::main_phase(uvm_phase phase);
157  uvm_component uc;
158  my_custom_filter_trfm#(cl_tb_seq_item, uvm_sequence_item) mcft;
159 
160  phase.raise_objection(this);
161  super.main_phase(phase);
162 
163  uc = this.scbs_env.syoscbs.get_filter_trfm_base("Q1", "P1", 0);
164  if(!$cast(mcft, uc)) begin
165  `uvm_fatal("TYPECAST", "uvm_component could not be cast to my_custom_filter_trfm")
166  end else if(mcft.analysis_export.get_name() != "my_analysis_imp") begin
167  `uvm_fatal("TYPECAST", "my_custom_filter_trfm did not have the correct analysis_imp name")
168  end
169  phase.drop_objection(this);
170 endtask: main_phase
SCBs test using a filter transform not inherited from pk_uvm_utils::filter_trfm, to show that all typ...
Base class for all SCBs tests.
Base class for a wrapper around multiple SyoSil Scoreboards.
Generic subscriber for the scoreboard.
Configuration class for the SyoSil UVM scoreboard.

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.3.0

Copyright 2014-2022 SyoSil ApS
All Rights Reserved Worldwide

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
doxygen
Doxygen Version: 1.8.14
Generated with IDV SV Filter Version: 2.6.3
Fri Sep 2 2022 14:38:39
Find a documentation bug? Report bugs to: scoreboard@syosil.com