SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_queue_iterator_base.svh
1 /// Queue iterator base class defining the iterator API used for iterating over queues.
2 /// The iterator API is modelled after the Java ListIterator interface https://docs.oracle.com/javase/8/docs/api/java/util/ListIterator.html.
3 /// To iterate over all elements of a queue, use a while loop of the type
4 /// <pre>
5 /// void'(iter.first());
6 /// while(iter.has_next()) begin
7 /// cl_syoscb_proxy_item_base pib = iter.next();
8 /// //do something
9 /// end
10 /// </pre>
11 /// Internally, the iterator's position is always between elements. Calling #next or #previous will advance
12 /// or reverse the iterator, returning the item that was moved past
13 /// <pre>
14 /// items: queue[0] queue[1] queue[2] ... queue[n-1]
15 /// cursor positions: ^ ^ ^ ^ ^ ^
16 /// </pre>
17 class cl_syoscb_queue_iterator_base extends uvm_object;
18  //-------------------------------------
19  // Non randomizable variables
20  //-------------------------------------
21  /// The owner of this iterator
23 
24  /// Current position in the queue
25  protected int unsigned position = 0;
26 
27  /// Local handle to the SCB cfg
28  protected cl_syoscb_cfg cfg;
29 
30  //-------------------------------------
31  // UVM Macros
32  //-------------------------------------
33  `uvm_object_utils_begin(cl_syoscb_queue_iterator_base)
34  `uvm_field_object(owner, UVM_DEFAULT)
35  `uvm_field_int(position, UVM_DEFAULT | UVM_DEC)
36  `uvm_field_object(cfg, UVM_DEFAULT | UVM_REFERENCE)
37  `uvm_object_utils_end
38 
39  function new(string name = "cl_syoscb_queue_iterator_base");
40  super.new(name);
41  endfunction: new
42 
43  //-------------------------------------
44  // Iterator API
45  //-------------------------------------
46  extern virtual function cl_syoscb_proxy_item_base next();
47  extern virtual function bit has_next();
48  extern virtual function int next_index();
49  extern virtual function cl_syoscb_proxy_item_base previous();
50  extern virtual function bit has_previous();
51  extern virtual function int previous_index();
52  extern virtual function bit first();
53  extern virtual function bit last();
54  extern protected virtual function cl_syoscb_queue_base get_queue();
55  extern virtual function bit set_queue(cl_syoscb_queue_base owner);
56  extern protected virtual function cl_syoscb_proxy_item_base get_item_proxy();
57 
59 
60 /// <b>Iterator API:</b> Moves the iterator one step forward, returning the next item in the queue.
61 /// \return The next item if successful, raises a uvm_error if there is no next item
63  `uvm_fatal("IMPL_ERROR", $sformatf("cl_syoscb_queue_iterator_base::next() *MUST* be overwritten"));
64  return null;
65 endfunction: next
66 
67 /// <b>Iterator API:</b> Checks if there are more items in the queue in the forward direction
68 /// \return 1 if there are more items in the forward direction, 0 otherwise (either empty queue or past last item)
70  `uvm_fatal("IMPL_ERROR", $sformatf("cl_syoscb_queue_iterator_base::has_next() *MUST* be overwritten"));
71  return 1'b0;
72 endfunction: has_next
73 
74 /// <b>Iterator API:</b> Returns the index of the item which would be returned if #next() was called
75 /// \return The index of the next item, or queue.size() if the iterator has reached the end.
77  return this.position;
78 endfunction: next_index
79 
80 /// <b>Iterator API:</b> Moves the iterator one step backward, returning the previous item in the queue.
81 /// \return The previous item if successful, raises a uvm_error if there is no previous item
83  `uvm_fatal("IMPL_ERROR",
84  $sformatf("cl_syoscb_queue_iterator_base::previous() *MUST* be overwritten"));
85  return null;
86 endfunction: previous
87 
88 /// <b>Iterator API:</b> Checks if there are more items in the queue in the backward direction
89 /// \return 1 if there are more items in the backward direction, 0 otherwise (either empty queue or at first item)
91  `uvm_fatal("IMPL_ERROR", $sformatf("cl_syoscb_queue_iterator_base::has_previous() *MUST* be overwritten"));
92  return 1'b0;
93 endfunction: has_previous
94 
95 /// <b>Iterator API:</b> Returns the index of the item which would be returned if #previous() was called
96 /// \return The index of the previous item, or -1 if the iterator is pointing to the first item of the queue
98  return this.position - 1;
99 endfunction: previous_index
100 
101 /// <b>Iterator API:</b> Moves the iterator to the first item in the queue.
102 /// Calling #has_previous at this point will always return 1'b0
103 /// \return 1 if successful, 0 if the queue is empty
105  `uvm_fatal("IMPL_ERROR", $sformatf("cl_syoscb_queue_iterator_base::first() *MUST* be overwritten"));
106  return 1'b0;
107 endfunction: first
108 
109 /// <b>Iterator API:</b> Moves the iterator to the last item in the queue.
110 /// Calling #has_next at this point will always return 1'b0.
111 /// \return 1 if succesful, 0 if there is no first item (queue is empty)
113  `uvm_fatal("IMPL_ERROR", $sformatf("cl_syoscb_queue_iterator_base::last() *MUST* be overwritten"));
114  return 1'b0;
115 endfunction: last
116 
117 /// <b>Iterator API:</b> Internal API: Returns the queue over which this iterator is iterating.
118 /// \return A handle to the queue. Raises a UVM_FATAL if no queue is associated with the iterator.
120  if(this.owner == null) begin
121  // An iterator should always have an associated queue
122  `uvm_fatal("QUEUE_ERROR",
123  $sformatf("Unable to find queue associated with iterator %s", this.get_name()));
124  return null;
125  end else begin
126  return this.owner;
127  end
128 endfunction: get_queue
129 
130 /// <b>Iterator API:</b> Sets the queue over which this iterator is iterating.
131 /// If a queue has already been associated with this iterator, or the queue type does not
132 /// match the iterator type, generates a UVM_ERROR message with id ITER_ERROR.
133 /// \return 1 if successful, raises a UVM_ERROR otherwise (a queue is already associated with this iterator, or wrong queue type)
134 function bit cl_syoscb_queue_iterator_base::set_queue(cl_syoscb_queue_base owner);
135  `uvm_fatal("IMPL_ERROR",
136  $sformatf("cl_syoscb_queue_iterator_base::set_queue() *MUST* be overwritten"));
137  return 1'b0;
138 endfunction: set_queue
139 
140 /// <b>Iterator API:</b> Internal API: Returns a proxy item that can be used to access the element
141 /// that was just moved past by calling #next or #previous.
142 /// \return A proxy item for the element that was moved past.
144  `uvm_fatal("IMPL_ERROR",
145  $sformatf("cl_syoscb_queue_iterator_base::get_item_proxy() *MUST* be overwritten"));
146  return null;
147 endfunction: get_item_proxy
cl_syoscb_queue_base owner
The owner of this iterator.
virtual cl_syoscb_proxy_item_base previous()
Iterator API: Moves the iterator one step backward, returning the previous item in the queue...
virtual bit has_next()
Iterator API: Checks if there are more items in the queue in the forward direction ...
virtual cl_syoscb_queue_base get_queue()
Iterator API: Internal API: Returns the queue over which this iterator is iterating.
Base class for all proxy items.
virtual int next_index()
Iterator API: Returns the index of the item which would be returned if next() was called ...
cl_syoscb_cfg cfg
Local handle to the SCB cfg.
virtual int previous_index()
Iterator API: Returns the index of the item which would be returned if previous() was called ...
virtual bit first()
Iterator API: Moves the iterator to the first item in the queue.
Queue iterator base class defining the iterator API used for iterating over queues.
int unsigned position
Current position in the queue.
Class which represents the base concept of a queue.
virtual cl_syoscb_proxy_item_base next()
Iterator API: Moves the iterator one step forward, returning the next item in the queue...
virtual bit last()
Iterator API: Moves the iterator to the last item in the queue.
virtual bit set_queue(cl_syoscb_queue_base owner)
Iterator API: Sets the queue over which this iterator is iterating.
virtual cl_syoscb_proxy_item_base get_item_proxy()
Iterator API: Internal API: Returns a proxy item that can be used to access the element that was just...
virtual bit has_previous()
Iterator API: Checks if there are more items in the queue in the backward direction ...
Configuration class for the SyoSil UVM scoreboard.

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