SyoSil ApS UVM Scoreboard  1.0.3.0
cl_scb_test_uvm_xml_printer.svh
1 typedef class uxp_parent_seq_item; //parent, child, small seq items are defined below tests
2 typedef enum {ON, OFF} t_on_off; //Defined below tests
3 
4 /// A test which can be used to generate an XML printout for verifying the uvm_xml_printer
5 class cl_scb_test_uvm_xml_printer extends cl_scb_test_single_scb;
6  //-------------------------------------
7  // Non randomizable variables
8  //-------------------------------------
9 
10 
11  //-------------------------------------
12  // UVM Macros
13  //-------------------------------------
14  `uvm_component_utils_begin(cl_scb_test_uvm_xml_printer)
15 
16  `uvm_component_utils_end
17 
18  //-------------------------------------
19  // Constructor
20  //-------------------------------------
21  function new(string name = "cl_scb_test_uvm_xml_printer", uvm_component parent = null);
22  super.new(name, parent);
23  endfunction: new
24 
25  //-------------------------------------
26  // Functions
27  //-------------------------------------
28  extern task run_phase(uvm_phase phase);
29  extern function void pre_build();
31 
32 function void cl_scb_test_uvm_xml_printer::pre_build();
33  super.pre_build();
34 
35  this.syoscb_cfgs.syoscb_cfg[0].set_enable_no_insert_check(0);
36  this.syoscb_cfgs.syoscb_cfg[0].set_disable_report(1'b1);
37  this.syoscb_cfgs.syoscb_cfg[0].set_end_greediness(pk_syoscb::SYOSCB_COMPARE_NOT_GREEDY);
38 
39 
40  this.syoscb_cfgs.syoscb_cfg[0].set_full_scb_dump(1'b1);
41  this.syoscb_cfgs.syoscb_cfg[0].set_full_scb_dump_type(pk_syoscb::XML);
42  void'(this.syoscb_cfgs.syoscb_cfg[0].set_full_scb_dump_split(1'b0));
43 
44  this.syoscb_cfgs.syoscb_cfg[0].set_full_scb_dump_file_name("xml_printer");
45 endfunction: pre_build
46 
47 task cl_scb_test_uvm_xml_printer::run_phase(uvm_phase phase);
48  uxp_parent_seq_item parent;
49  cl_syoscb_item syoscb_item;
50  uvm_xml_printer xp;
51  uvm_table_printer tp;
52  int fd;
53  string sxp;
54 
55  phase.raise_objection(this);
56  super.run_phase(phase);
57 
58  this.scb_env.syoscb[0].compare_control(1'b0);
59 
60  parent = uxp_parent_seq_item::type_id::create("parent");
61  syoscb_item = cl_syoscb_item::type_id::create("syoscb_item");
62 
63  for(int i=1; i<=2; i++) begin
64  if(!parent.randomize()) begin
65  `uvm_fatal("RAND", "Unable to randomize")
66  end
67  parent.str = "Hello, world";
68  parent.q.push_back(1*i);
69  parent.q.push_back(2*i);
70  parent.q.push_back(100*i);
71  parent.r = 3.14*i;
72 
73  parent.aa["one"] = 1*i;
74  parent.aa["two"] = 2*i;
75  parent.aa["hundred"] = 100*i;
76 
77  this.scb_env.syoscb[0].add_item("Q1", "P1", parent);
78  end
79 
80  if(!parent.randomize()) begin
81  `uvm_fatal("RAND", "Unable to randomize")
82  end
83 
84  this.scb_env.syoscb[0].add_item("Q2", "P1", parent.child);
85 
86  phase.drop_objection(this);
87 endtask: run_phase
88 
89 /// Tests whether the uvm_xml_printer correctly outputs a warning when it is used on a non-cl_syoscb_item sequencei item.
90 class cl_scb_test_uvm_xml_printer_break extends cl_scb_test_uvm_xml_printer;
91  //-------------------------------------
92  // Non randomizable variables
93  //-------------------------------------
94 
95 
96  //-------------------------------------
97  // UVM Macros
98  //-------------------------------------
99  `uvm_component_utils_begin(cl_scb_test_uvm_xml_printer_break)
100 
101  `uvm_component_utils_end
102 
103  //-------------------------------------
104  // Constructor
105  //-------------------------------------
106  function new(string name = "cl_scb_test_uvm_xml_printer_break", uvm_component parent = null);
107  super.new(name, parent);
108  endfunction: new
109 
110  //-------------------------------------
111  // Functions
112  //-------------------------------------
113  extern task run_phase(uvm_phase phase);
114 
115 endclass: cl_scb_test_uvm_xml_printer_break
116 
117 task cl_scb_test_uvm_xml_printer_break::run_phase(uvm_phase phase);
118  uvm_xml_printer xml_printer;
119  uxp_parent_seq_item item;
120  uvm_root uvm_top;
121 
122  phase.raise_objection(this);
123  uvm_top = uvm_root::get();
124  uvm_top.set_report_severity_id_override(UVM_WARNING, "XML_PRINT", UVM_INFO);
125 
126  super.run_phase(phase);
127 
128  xml_printer = new;
129  item = uxp_parent_seq_item::type_id::create("item");
130 
131  if(!item.randomize()) begin
132  `uvm_fatal("RAND", "Unable to randomize seq. item")
133  end
134  void'(item.sprint(xml_printer));
135 
136  phase.drop_objection(this);
137 endtask: run_phase
138 
139 //Definitions for auxilliary classes for these tests
140 class uxp_small_seq_item extends uvm_sequence_item;
141  rand int i;
142  rand byte by;
143 
144  `uvm_object_utils_begin(uxp_small_seq_item)
145  `uvm_field_int(i, UVM_DEFAULT)
146  `uvm_field_int(by, UVM_DEFAULT)
147  `uvm_object_utils_end
148 
149  function new(string name = "uxp_small_seq_item");
150  super.new(name);
151  endfunction: new
152 endclass: uxp_small_seq_item
153 
154 class uxp_child_seq_item extends uvm_sequence_item;
155  rand int arr[15];
156  uxp_small_seq_item children[3];
157 
158  `uvm_object_utils_begin(uxp_child_seq_item)
159  `uvm_field_sarray_int(arr, UVM_DEFAULT)
160  `uvm_field_sarray_object(children, UVM_DEFAULT)
161  `uvm_object_utils_end
162 
163  function new(string name = "uxp_child_seq_item");
164  super.new(name);
165 
166  children[0] = new("child0");
167  //Child1 intentionally left as null
168  children[2] = new("child2");
169 
170  endfunction: new
171 
172 endclass: uxp_child_seq_item
173 
174 class uxp_parent_seq_item extends uvm_sequence_item;
175  rand int a;
176  rand byte b;
177  rand t_on_off t;
178  real r;
179  string str;
180  int q[$];
181  int aa[string];
182  uxp_child_seq_item child;
183  int empt[];
184  uxp_child_seq_item null_object;
185 
186  `uvm_object_utils_begin(uxp_parent_seq_item)
187  `uvm_field_int(a, UVM_DEFAULT)
188  `uvm_field_int(b, UVM_DEFAULT)
189  `uvm_field_enum(t_on_off, t, UVM_DEFAULT)
190  `uvm_field_real(r, UVM_DEFAULT)
191  `uvm_field_string(str, UVM_DEFAULT)
192  `uvm_field_queue_int(q, UVM_DEFAULT)
193  `uvm_field_aa_int_string(aa, UVM_DEFAULT)
194  `uvm_field_object(child, UVM_DEFAULT)
195  `uvm_field_array_int(empt, UVM_DEFAULT)
196  `uvm_field_object(null_object, UVM_DEFAULT)
197  `uvm_object_utils_end
198 
199  function new(string name = "uxp_parent_seq_item");
200  super.new(name);
201  endfunction: new
202 
203  function void pre_randomize();
204  this.child = uxp_child_seq_item::type_id::create("child");
205  endfunction: pre_randomize
206 endclass: uxp_parent_seq_item
The UVM scoreboard item which wraps uvm_sequence_item .
An XML printer for cl_syoscb_items.
A test which can be used to generate an XML printout for verifying the uvm_xml_printer.

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:34
Find a documentation bug? Report bugs to: scoreboard@syosil.com