SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_queue_hash_md5.svh
1 /// MD5 implementation of a hash queue which optimizes the OOO compare.
2 /// The queue implements the queue API as defined by cl_syoscb_queue_base.
3 class cl_syoscb_queue_hash_md5 extends cl_syoscb_queue_hash#(pk_syoscb::MD5_HASH_DIGEST_WIDTH);
4 
5  //-------------------------------------
6  // UVM Macros
7  //-------------------------------------
8  `uvm_component_utils_begin(cl_syoscb_queue_hash_md5)
9  `uvm_component_utils_end
10 
11  //-------------------------------------
12  // Constructor
13  //-------------------------------------
14  extern function new(string name, uvm_component parent);
15 
16  // Iterator support functions
17  extern virtual function cl_syoscb_queue_iterator_base create_iterator(string name = "");
18 
19  // Locator support function
20  extern virtual function cl_syoscb_queue_locator_base get_locator();
21 
22  // Misc support function
23  // Implementation of the UVM function do_copy() for the hash MD5 queue. The base class only
24  // defines the generic API structure for hash queue, then it is up to the derived one to
25  // implement the correct do_copy behaviour for any specific implementation. do_copy in fact
26  // requires to know the exact hash digest lenght for the object rhs; and for this reason
27  // do_copy can't be implemented in the base class and shared over all implementations
28  extern virtual function void do_copy(uvm_object rhs);
30 
31 function cl_syoscb_queue_hash_md5::new(string name, uvm_component parent);
32  super.new(name, parent);
33 
34  this.hash_algo = cl_syoscb_hash_md5::type_id::create("hash_algo", this);
35 endfunction: new
36 
37 /// <b>Queue API:</b> See cl_syoscb_queue_base#create_iterator for more details
40  string iter_name;
42 
43  // Wait to get exclusive access to the queue
44  // if there are multiple iterators
45  while(this.iter_sem.try_get() == 0);
46 
47  if(name == "") begin
48  iter_name = $sformatf("%0s_iter%0d", this.get_name(), this.num_iters_created);
49  end else begin
50  iter_name = name;
51  end
52 
53  f = this.iterators.find_index() with (item.get_name() == name);
54  if(f.size() != 0) begin
55  `uvm_info("ITERATOR", $sformatf("[%0s] An iterator with the name %0s already exists", this.cfg.get_scb_name(), name), UVM_DEBUG)
56  this.iter_sem.put();
57  return null;
58  end
59  result = cl_syoscb_queue_iterator_hash_md5::type_id::create(iter_name);
60 
61  // No need to check return value since set_queue will issue
62  // and `uvm_error of something goes wrong
63  void'(result.set_queue(this));
64 
65  this.iterators[result] = result;
66  this.num_iters_created++;
67  this.iter_sem.put();
68 
69  return result;
70 endfunction: create_iterator
71 
72 /// <b>Queue API:</b> See cl_syoscb_queue_base#create_iterator for more details
75 
76  locator = cl_syoscb_queue_locator_hash_md5::type_id::create($sformatf("%s_loc", this.get_name()));
77  void'(locator.set_queue(this));
78 
79  return locator;
80 endfunction: get_locator
81 
82 // Custom do_copy implementation for iterators in AA in order to shallow copy the elements from rhs
83 function void cl_syoscb_queue_hash_md5::do_copy(uvm_object rhs);
84  cl_syoscb_queue_hash#(pk_syoscb::MD5_HASH_DIGEST_WIDTH) rhs_cast;
85  cl_syoscb_hash_aa_wrapper#(pk_syoscb::MD5_HASH_DIGEST_WIDTH) rhs_aa;
86  tp_digest l_digest;
87 
88  if(!$cast(rhs_cast, rhs))begin
89  `uvm_fatal("do_copy",
90  $sformatf("The given object argument is not %0p type", rhs_cast.get_type()))
91  end
92  rhs_aa = rhs_cast.get_hash();
93 
94  // Delete the aa content because this queue_base might be used before calling the copy
95  // method. on the other hand, the result of this.copy(rhs), should override each field values
96  // without keeping memory on what was before.
97  this.hash.delete_all();
98 
99  if(rhs_aa.first(l_digest)) begin
100  do begin
101  for(int idx=0; idx<rhs_aa.get_size(l_digest); idx++) begin
102  cl_syoscb_item other_item;
103  other_item = rhs_aa.get_item(l_digest, idx);
104  this.hash.insert(l_digest, other_item);
105  end
106  end
107  while(rhs_cast.hash.next(l_digest));
108  end
109 
110  super.do_copy(rhs);
111 endfunction: do_copy
virtual cl_syoscb_queue_iterator_base create_iterator(string name="")
Queue API: See cl_syoscb_queue_base::create_iterator for more details
cl_syoscb_queue_iterator_base iterators[cl_syoscb_queue_iterator_base]
List of iterators registered with this queue.
Locator class for searching over hash queues using md5 as the hash algorithm.
virtual tp_aa_hash get_hash()
Gets the hash AA wrapper used for this queue.
MD5 implementation of a hash queue which optimizes the OOO compare.
cl_syoscb_hash_base< HASH_DIGEST_WIDTH > hash_algo
Handle to the implemented hash algorithm.
cl_syoscb_hash_base< HASH_DIGEST_WIDTH >::tp_hash_digest tp_digest
Typedef for hash algorithm digests.
Locator base class defining the locator API used for searching in queues.
semaphore iter_sem
Semaphore guarding exclusive access to the queue when multiple iterators are in play.
cl_syoscb_hash_aa_wrapper< HASH_DIGEST_WIDTH > hash
Queue implementation with an assosiative array. Wrapped in a class for performance reasons...
Queue iterator base class defining the iterator API used for iterating over queues.
virtual cl_syoscb_queue_locator_base get_locator()
Queue API: See cl_syoscb_queue_base::create_iterator for more details
Queue iterator class defining the iterator API used for iterating md5 hash queues.
int num_iters_created
The number of iterators that have been created for this queue so far.
A wrapper around an associative array, used for storing hash queues.
Class which represents the base concept of a hash queue.

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