OpenCores
URL https://opencores.org/ocsvn/lpffir/lpffir/trunk

Subversion Repositories lpffir

[/] [lpffir/] [trunk/] [uvm/] [tools/] [uvm_syoscb/] [src/] [cl_syoscb_compare_ooo.svh] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 vladimirar
//----------------------------------------------------------------------
2
//   Copyright 2014-2015 SyoSil ApS
3
//   All Rights Reserved Worldwide
4
//
5
//   Licensed under the Apache License, Version 2.0 (the
6
//   "License"); you may not use this file except in
7
//   compliance with the License.  You may obtain a copy of
8
//   the License at
9
//
10
//       http://www.apache.org/licenses/LICENSE-2.0
11
//
12
//   Unless required by applicable law or agreed to in
13
//   writing, software distributed under the License is
14
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
//   CONDITIONS OF ANY KIND, either express or implied.  See
16
//   the License for the specific language governing
17
//   permissions and limitations under the License.
18
//----------------------------------------------------------------------
19
// Class which implements the out of order compare algorithm
20
class cl_syoscb_compare_ooo extends cl_syoscb_compare_base;
21
  //-------------------------------------
22
  // UVM Macros
23
  //-------------------------------------
24
  `uvm_object_utils(cl_syoscb_compare_ooo)
25
 
26
  //-------------------------------------
27
  // Constructor
28
  //-------------------------------------
29
  extern function new(string name = "cl_syoscb_compare_ooo");
30
 
31
  //-------------------------------------
32
  // Compare API
33
  //-------------------------------------
34
  extern virtual function void compare();
35
  extern function void compare_do();
36
endclass: cl_syoscb_compare_ooo
37
 
38
function cl_syoscb_compare_ooo::new(string name = "cl_syoscb_compare_ooo");
39
  super.new(name);
40
endfunction: new
41
 
42
/// Compare API: Mandatory overwriting of the base class' compare method.
43
/// Currently, this just calls do_copy() blindly
44
function void cl_syoscb_compare_ooo::compare();
45
  // Here any state variables should be queried
46
  // to compute if the compare should be done or not
47
  this.compare_do();
48
endfunction: compare
49
 
50
/// Compare API: Mandatory overwriting of the base class' do_compare method.
51
/// Here the actual out of order compare is implemented.
52
///
53
/// The algorithm gets the primary queue and then loops over all other queues to see if
54
/// it can find primary item as any item in all of the other queues. If so then the items
55
/// are removed from all queues. If not then nothing is done. Thus, if some items are not
56
/// matched then the result is that the queue will be non-empty at the end of simulation.
57
/// This will then be caught by the check_phase.
58
function void cl_syoscb_compare_ooo::compare_do();
59
  string primary_queue_name;
60
  cl_syoscb_queue primary_queue;
61
  cl_syoscb_queue_iterator_base primary_queue_iter;
62
  string queue_names[];
63
  int unsigned secondary_item_found[string];
64
  bit compare_continue = 1'b1;
65
  bit compare_result = 1'b0;
66
  cl_syoscb_item primary_item;
67
 
68
  // Initialize state variables
69
  primary_queue_name = this.get_primary_queue_name();
70
  this.cfg.get_queues(queue_names);
71
 
72
  primary_queue = this.cfg.get_queue(primary_queue_name);
73
  if(primary_queue == null) begin
74
    `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to retrieve primary queue handle", this.cfg.get_scb_name()));
75
  end
76
 
77
  primary_queue_iter = primary_queue.create_iterator();
78
 
79
  `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: primary queue: %s", this.cfg.get_scb_name(), primary_queue_name), UVM_FULL);
80
  `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: number of queues: %0d", this.cfg.get_scb_name(), queue_names.size()), UVM_FULL);
81
 
82
  // Outer loop loops through all
83
  while (!primary_queue_iter.is_done()) begin
84
    primary_item = primary_queue_iter.get_item();
85
 
86
    `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: Now comparing primary transaction:\n%s", this.cfg.get_scb_name(), primary_item.sprint()), UVM_FULL);
87
 
88
    // Clear list of found slave items before starting new inner loop
89
    secondary_item_found.delete();
90
 
91
    // Inner loop through all queues
92
    foreach(queue_names[i]) begin
93
      `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: Looking at queue: %s", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
94
 
95
      if(queue_names[i] != primary_queue_name) begin
96
        cl_syoscb_queue secondary_queue;
97
        cl_syoscb_queue_iterator_base secondary_queue_iter;
98
 
99
        `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: %s is a secondary queue - now comparing", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
100
 
101
        // Get the secondary queue
102
        secondary_queue = this.cfg.get_queue(queue_names[i]);
103
 
104
        if(secondary_queue == null) begin
105
          `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to retrieve secondary queue handle", this.cfg.get_scb_name()));
106
        end
107
 
108
        `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: %0d items in queue: %s", this.cfg.get_scb_name(), secondary_queue.get_size(), queue_names[i]), UVM_FULL);
109
 
110
        // Only trigger the compare if there are elements in the queue
111
        if(secondary_queue.get_size()>0) begin
112
          // Get an iterator for the secondary queue
113
          secondary_queue_iter = secondary_queue.create_iterator();
114
 
115
          // Only the first match is removed
116
          while(!secondary_queue_iter.is_done()) begin
117
            // Get the item from the secondary queue
118
            cl_syoscb_item sih = secondary_queue_iter.get_item();
119
 
120
            if(sih.compare(primary_item) == 1'b1) begin
121
              secondary_item_found[queue_names[i]] = secondary_queue_iter.get_idx();
122
              `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: Secondary item found at index: %0d:\n%s", this.cfg.get_scb_name(), secondary_queue_iter.get_idx(), sih.sprint()), UVM_FULL);
123
              break;
124
            end
125
            if(!secondary_queue_iter.next()) begin
126
              `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to get next element from iterator on secondary queue: %s", this.cfg.get_scb_name(), queue_names[i]));
127
            end
128
          end
129
 
130
          if(!secondary_queue.delete_iterator(secondary_queue_iter)) begin
131
            `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to delete iterator from secondaery queue: %s", this.cfg.get_scb_name(), queue_names[i]));
132
          end
133
        end else begin
134
          `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: %s is empty - skipping", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
135
        end
136
 
137
      end else begin
138
        `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: %s is the primary queue - skipping", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
139
      end
140
    end
141
 
142
    // Only start to remove items if all slave items are found (One from each slave queue)
143
    if(secondary_item_found.size() == queue_names.size()-1) begin
144
      string queue_name;
145
      cl_syoscb_item pih;
146
 
147
      // Get the item from the primary queue
148
      pih = primary_queue_iter.get_item();
149
 
150
      `uvm_info("DEBUG", $sformatf("[%s]: cmp-ooo: Found match for primary queue item :\n%s", this.cfg.get_scb_name(), pih.sprint()), UVM_FULL);
151
 
152
      // Remove from primary
153
      if(!primary_queue.delete_item(primary_queue_iter.get_idx())) begin
154
        `uvm_error("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to delete item idx %0d from queue %s",
155
                                            this.cfg.get_scb_name(), primary_queue_iter.get_idx(), primary_queue.get_name()));
156
      end
157
 
158
      // Remove from all secondaries
159
      while(secondary_item_found.next(queue_name)) begin
160
        cl_syoscb_queue secondary_queue;
161
 
162
        // Get the secondary queue
163
        secondary_queue = this.cfg.get_queue(queue_name);
164
 
165
        if(secondary_queue == null) begin
166
          `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to retrieve secondary queue handle", this.cfg.get_scb_name()));
167
        end
168
 
169
        if(!secondary_queue.delete_item(secondary_item_found[queue_name])) begin
170
          `uvm_error("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to delete item idx %0d from queue %s",
171
                                              this.cfg.get_scb_name(), secondary_item_found[queue_name], secondary_queue.get_name()));
172
        end
173
      end
174
    end
175
 
176
    // Call .next() blindly since we do not care about the
177
    // return value, since we might be at the end of the queue.
178
    // Thus, .next() will return 1'b0 at the end of the queue
179
    void'(primary_queue_iter.next());
180
  end
181
 
182
  if(!primary_queue.delete_iterator(primary_queue_iter)) begin
183
    `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-ooo: Unable to delete iterator from primary queue: %s", this.cfg.get_scb_name(), primary_queue_name));
184
  end
185
endfunction: compare_do

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.