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

Subversion Repositories lpffir

[/] [lpffir/] [trunk/] [uvm/] [tools/] [uvm_syoscb/] [src/] [cl_syoscb_compare_iop.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 in order by producer compare algorithm
20
class cl_syoscb_compare_iop extends cl_syoscb_compare_base;
21
  //-------------------------------------
22
  // UVM Macros
23
  //-------------------------------------
24
  `uvm_object_utils(cl_syoscb_compare_iop)
25
 
26
  //-------------------------------------
27
  // Constructor
28
  //-------------------------------------
29
  extern function new(string name = "cl_syoscb_compare_iop");
30
 
31
  //-------------------------------------
32
  // Compare API
33
  //-------------------------------------
34
  extern virtual function void compare();
35
  extern function void compare_do();
36
endclass: cl_syoscb_compare_iop
37
 
38
function cl_syoscb_compare_iop::new(string name = "cl_syoscb_compare_iop");
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_iop::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 the primary item as the first item of the same producer in all of the other queues.
55
/// If so then the items 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_iop::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-iop: 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-iop: primary queue: %s", this.cfg.get_scb_name(), primary_queue_name), UVM_FULL);
80
  `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: 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-iop: 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-iop: 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-iop: %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-iop: Unable to retrieve secondary queue handle", this.cfg.get_scb_name()));
106
        end
107
 
108
        `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: %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
            // Only do the compare if the producers match
121
            if(primary_item.get_producer == sih.get_producer()) begin
122
              if(sih.compare(primary_item) == 1'b1) begin
123
                secondary_item_found[queue_names[i]] = secondary_queue_iter.get_idx();
124
                `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: Secondary item found at index: %0d:\n%s", this.cfg.get_scb_name(), secondary_queue_iter.get_idx(), sih.sprint()), UVM_FULL);
125
                break;
126
               end else begin
127
                `uvm_error("COMPARE_ERROR", $sformatf("[%s]: cmp-iop: Item:\n%s\nfrom primary queue: %s not found in secondary queue: %s. Found this item in %s instead:\n%s",
128
                                                      this.cfg.get_scb_name(), primary_item.sprint(), primary_queue_name, queue_names[i], queue_names[i], sih.sprint()))
129
 
130
                // The first element was not a match => break since this is an in order compare on the producer
131
                break;
132
              end
133
            end
134
 
135
            if(!secondary_queue_iter.next()) begin
136
              `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to get next element from iterator on secondary queue: %s", this.cfg.get_scb_name(), queue_names[i]));
137
            end
138
          end
139
 
140
          if(!secondary_queue.delete_iterator(secondary_queue_iter)) begin
141
            `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to delete iterator from secondaery queue: %s", this.cfg.get_scb_name(), queue_names[i]));
142
          end
143
        end else begin
144
          `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: %s is empty - skipping", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
145
        end
146
      end else begin
147
        `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: %s is the primary queue - skipping", this.cfg.get_scb_name(), queue_names[i]), UVM_FULL);
148
      end
149
    end
150
 
151
    // Only start to remove items if all slave items are found (One from each slave queue)
152
    if(secondary_item_found.size() == queue_names.size()-1) begin
153
      string queue_name;
154
      cl_syoscb_item pih;
155
 
156
      // Get the item from the primary queue
157
      pih = primary_queue_iter.get_item();
158
 
159
      `uvm_info("DEBUG", $sformatf("[%s]: cmp-iop: Found match for primary queue item :\n%s", this.cfg.get_scb_name(), pih.sprint()), UVM_FULL);
160
 
161
      // Remove from primary
162
      if(!primary_queue.delete_item(primary_queue_iter.get_idx())) begin
163
        `uvm_error("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to delete item idx %0d from queue %s",
164
                                            this.cfg.get_scb_name(), primary_queue_iter.get_idx(), primary_queue.get_name()));
165
      end
166
 
167
      // Remove from all secondaries
168
      while(secondary_item_found.next(queue_name)) begin
169
        cl_syoscb_queue secondary_queue;
170
 
171
        // Get the secondary queue
172
        secondary_queue = this.cfg.get_queue(queue_name);
173
 
174
        if(secondary_queue == null) begin
175
          `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to retrieve secondary queue handle", this.cfg.get_scb_name()));
176
        end
177
 
178
        if(!secondary_queue.delete_item(secondary_item_found[queue_name])) begin
179
          `uvm_error("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to delete item idx %0d from queue %s",
180
                                              this.cfg.get_scb_name(), secondary_item_found[queue_name], secondary_queue.get_name()));
181
        end
182
      end
183
    end
184
 
185
    // Call .next() blindly since we do not care about the
186
    // return value, since we might be at the end of the queue.
187
    // Thus, .next() will return 1'b0 at the end of the queue
188
    void'(primary_queue_iter.next());
189
  end
190
 
191
  if(!primary_queue.delete_iterator(primary_queue_iter)) begin
192
    `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: cmp-iop: Unable to delete iterator from primary queue: %s", this.cfg.get_scb_name(), primary_queue_name));
193
  end
194
endfunction: compare_do

powered by: WebSVN 2.1.0

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