SyoSil ApS UVM Scoreboard  1.0.3.0
cl_scb_test_copy_cfg.svh
1 /// This test is used to ensure that copying data from one cl_syoscb_cfg object to the next correctly moves over all information
3  //-------------------------------------
4  // Non randomizable variables
5  //-------------------------------------
6  string queues[] = '{"Q1", "Q2", "Q3"};
7  string producers[] = '{"P1", "P2"};
8 
9  //-------------------------------------
10  // UVM Macros
11  //-------------------------------------
12  `uvm_component_utils(cl_scb_test_copy_cfg)
13 
14  //-------------------------------------
15  // Constructor
16  //-------------------------------------
17  extern function new(string name = "cl_scb_test_copy_cfg", uvm_component parent = null);
18 
19  //-------------------------------------
20  // Functions
21  //-------------------------------------
22  extern task run_phase(uvm_phase phase);
23 endclass: cl_scb_test_copy_cfg
24 
25 function cl_scb_test_copy_cfg::new(string name = "cl_scb_test_copy_cfg", uvm_component parent = null);
26  super.new(name, parent);
27 endfunction: new
28 
29 task cl_scb_test_copy_cfg::run_phase(uvm_phase phase);
30  //Declarations
31  cl_tb_cfg_rnd cfg_rnd;
32  cl_syoscb_cfg cfg1, cfg2, cfg3;
33  bit pack1[];
34  bit pack2[];
35  bit pack3[];
36  int miscnt;
37  uvm_printer p[3];
38  uvm_printer default_printer;
39  uvm_comparer c[3];
40  uvm_comparer default_comparer;
41  uvm_packer packer;
42 
43 
44  //Initialize objects
45  cfg_rnd = this.config_create_and_randomize();
46  cfg1 = new;
47  cfg2 = new;
48  cfg3 = new;
49  default_comparer = new;
50  packer = new;
51  `ifndef UVM_VERSION
52  packer.use_metadata = 1'b1;
53  `endif
54 
55  //Set up cfg1
56  cfg_rnd.set_rnd_fields(cfg1);
57  cfg1.set_queues(queues);
58  void'(cfg1.set_producer("P1", queues));
59  void'(cfg1.set_producer("P2", queues));
60 
61  //Initialize printers in cfg1
62  //Using different printer types to ensure all combinations are tested
63  p[0] = cl_syoscb_printer_config::get_printer_of_type(pk_syoscb::SYOSCB_PRINTER_TABLE);
64  p[1] = cl_syoscb_printer_config::get_printer_of_type(pk_syoscb::SYOSCB_PRINTER_TREE);
65  p[2] = cl_syoscb_printer_config::get_printer_of_type(pk_syoscb::SYOSCB_PRINTER_LINE);
66  default_printer = cl_syoscb_printer_config::get_printer_of_type(pk_syoscb::SYOSCB_PRINTER_XML);
67  for(int i=0; i<3; i++) begin
69  cfg1.set_printer(p[i], '{queues[i]}, '{"P1"});
70  end
72  cfg1.set_default_printer(default_printer);
73 
74  //Initialize comparers in cfg1
75  foreach(c[i]) begin
76  c[i] = new;
78  cfg1.set_comparer(c[i], '{queues[i]}, '{"P2"});
79  end
80  cl_syoscb_comparer_config::set_verbosity(default_comparer, 400);
81  cfg1.set_default_comparer(default_comparer);
82 
83  //Copy to cfg2 and pack both cfg1 and cfg2. Packed data should be equal
84  cfg2.copy(cfg1);
85  $display("Packed %0d bits when packing cfg1", cfg1.pack(pack1, packer));
86  $display("Packed %0d bits when packing cfg2", cfg2.pack(pack2, packer));
87 
88  foreach(pack1[i]) begin
89  if(pack1[i] != pack2[i]) begin
90  `uvm_error("CFG_COPY", $sformatf("Error when copying cfg1 to cfg2. Should be similar, but found a difference in pack @ %0d", i))
91  end
92  end
93 
94  //Unpack pack2 into cfg3. Repack that data into pack3, it should still
95  //be the same as pack2.
96  //This is really just a workaround since we cannot calls .compare on config objects
97  //since the queues are included in the comparison
98  $display("Unpacked %0d bits into cfg3 from cfg2's pack", cfg3.unpack(pack2));
99  $display("Packed %0d bits when packing cfg3", cfg3.pack(pack3, packer));
100  foreach(pack2[i]) begin
101  if(pack2[i] != pack3[i]) begin
102  `uvm_error("CFG_COPY", $sformatf("Error when comparing cfg2 and cfg3. Should be equal, but found a difference in pack @ %0d", i))
103  end
104  end
105 
106  //Introduce differences in cfg2, we now expect packed data to be different
107  //beteen pack1 and pack2
108  p[0] = cl_syoscb_printer_config::get_printer_of_type(pk_syoscb::SYOSCB_PRINTER_TREE);
110  cfg2.set_printer(p[0], '{"Q1"}, '{"P1"});
111 
112  c[0] = new;
114  cfg2.set_comparer(c[0], '{"Q2"}, '{"P2"});
115 
116  void'(cfg2.pack(pack2, packer));
117 
118  miscnt = 0;
119  foreach(pack1[i]) begin
120  if(pack1[i] != pack2[i]) begin
121  miscnt++;
122  end
123  end
124  if(miscnt == 0) begin
125  `uvm_error("CFG_COPY", "Error when copying cfg1 to cfg2. No packed difference found when introducing errors");
126  end
127 endtask: run_phase
static uvm_printer get_printer_of_type(t_printer_type ptype)
Generates a new printer of the correct type.
static void set_verbosity(uvm_comparer comparer, int unsigned cv=UVM_DEBUG)
Sets the verbosity level of a given comparer.
virtual void set_default_comparer(uvm_comparer comparer)
Configuration API: Set the value of the default_comparer member variable
virtual void set_printer(uvm_printer printer, string queue_names[], string producer_names[])
Configuration API: Sets the given uvm_printer to be used for some queue/producer-combinations.
This test is used to ensure that copying data from one cl_syoscb_cfg object to the next correctly mov...
virtual void set_default_printer(uvm_printer printer)
Configuration API: Set the value of the default_printer member variable
Base class for all SCB tests.
static void set_file_descriptor(uvm_printer printer, int fd=0)
Sets the file descriptor to be used for a given printer.
virtual bit set_producer(string producer, queue_names[])
Configuration API: Sets the given producer for the listed queues If any errors occur, information about this is printed as a UVM_DEBUG message If a list of queues has already been set for a given producer, overrides that list.
virtual void set_comparer(uvm_comparer comparer, string queue_names[], string producer_names[])
Configuration API: Sets the comparer to be used for a number of queues.
virtual void set_queues(string queue_names[])
Configuration API: Will set the legal queues when provided with a list of queue names.

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