SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_subscriber.svh
1 /// Generic subscriber for the scoreboard. It provides the write method
2 /// for UVM monitors and utilizes the function based API of the scoreboard to insert
3 /// the items received through the write method.
4 class cl_syoscb_subscriber extends uvm_subscriber#(uvm_sequence_item);
5  //-------------------------------------
6  // Non randomizable variables
7  //-------------------------------------
8  /// The name of the queue this subscriber writes data to
9  local string queue_name;
10  /// The name of the producer that this is subscribed to
11  local string producer;
12  /// Whether to use mutexed add_item calls (1) or non-mutexed (0)
13  local bit mutexed_add_item_enable = 1'b0;
14 
15  //-------------------------------------
16  // UVM Macros
17  //-------------------------------------
18  `uvm_component_utils_begin(cl_syoscb_subscriber)
19  `uvm_field_string(queue_name, UVM_DEFAULT);
20  `uvm_field_string(producer, UVM_DEFAULT);
21  `uvm_component_utils_end
22 
23  //-------------------------------------
24  // Constructor
25  //-------------------------------------
26  extern function new(string name = "cl_syoscb_subscriber", uvm_component parent = null);
27 
28  //-------------------------------------
29  // UVM overwrites/extensions
30  //-------------------------------------
31  extern function void write(uvm_sequence_item t);
32 
33  //-------------------------------------
34  // Subscriber API
35  //-------------------------------------
36  extern virtual function string get_queue_name();
37  extern virtual function void set_queue_name(string qn);
38  extern virtual function string get_producer();
39  extern virtual function void set_producer(string p);
40  extern virtual function void set_mutexed_add_item_enable(bit maie);
41 endclass: cl_syoscb_subscriber
42 
43 function cl_syoscb_subscriber::new(string name = "cl_syoscb_subscriber", uvm_component parent = null);
44  super.new(name, parent);
45 endfunction: new
46 
47 /// Implementation of the write method which must be implemented when extending uvm_subscriber.
48 function void cl_syoscb_subscriber::write(uvm_sequence_item t);
49  cl_syoscb parent;
50 
51  // Get the parent which is the SCB top
52  // This is needed for access to the function based API
53  begin
54  uvm_component tmp_parent;
55 
56  tmp_parent = this.get_parent();
57 
58  if(!$cast(parent, tmp_parent)) begin
59  // *NOTE*: Here the parent cannot be cast. Thus, the print cannot contain the SCB name
60  `uvm_fatal("IMPL_ERROR", "Unable to cast parent of subscriber");
61  end
62  end
63 
64  `uvm_info("DEBUG", $sformatf("Trigger add_item by subscriber: %s (Queue: %s, Producer: %s)", this.get_name(), this.queue_name, this.producer), UVM_FULL);
65 
66  // Add the item to the queue
67  if(this.mutexed_add_item_enable) begin
68  fork
69  parent.add_item_mutexed(this.queue_name, this.producer, t);
70  join_none
71  end else begin
72  parent.add_item(this.queue_name, this.producer, t);
73  end
74 endfunction
75 
76 /// <b>Subscriber API</b>: Returns the name of the queue which this subscriber is connected to.
78  return(this.queue_name);
79 endfunction: get_queue_name
80 
81 /// <b>Subscriber API</b>: Sets the name of the queue which this subscriber is connected to.
82 function void cl_syoscb_subscriber::set_queue_name(string qn);
83  this.queue_name = qn;
84 endfunction: set_queue_name
85 
86 /// <b>Subscriber API</b>: Returns the name of the produer which this subscriber is connected to.
88  return(this.producer);
89 endfunction: get_producer
90 
91 /// <b>Subscriber API</b>: Sets the name of the producer which this subscriber is connected to.
92 function void cl_syoscb_subscriber::set_producer(string p);
93  this.producer = p;
94 endfunction: set_producer
95 
96 /// <b>Subscriber API</b>: Controls whether items should be added in a mutexed fashion or not.
97 /// Must be called during cl_syoscb#build_phase
99  this.mutexed_add_item_enable = maie;
100 endfunction: set_mutexed_add_item_enable
bit mutexed_add_item_enable
Whether to use mutexed add_item calls (1) or non-mutexed (0)
string queue_name
The name of the queue this subscriber writes data to.
virtual string get_queue_name()
Subscriber API: Returns the name of the queue which this subscriber is connected to.
Top level class implementing the root of the SyoSil UVM scoreboard.
Definition: cl_syoscb.svh:2
virtual void set_mutexed_add_item_enable(bit maie)
Subscriber API: Controls whether items should be added in a mutexed fashion or not.
virtual void set_queue_name(string qn)
Subscriber API: Sets the name of the queue which this subscriber is connected to. ...
void write(uvm_sequence_item t)
Implementation of the write method which must be implemented when extending uvm_subscriber.
string producer
The name of the producer that this is subscribed to.
virtual string get_producer()
Subscriber API: Returns the name of the produer which this subscriber is connected to...
Generic subscriber for the scoreboard.
virtual void set_producer(string p)
Subscriber API: Sets the name of the producer which this subscriber is connected to.

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