cl_syoscb.svh

00001 /// Top level class implementing the root of the SyoSil UVM scoreboard
00002 class cl_syoscb extends uvm_scoreboard;
00003   //-------------------------------------
00004   // Non randomizable variables
00005   //-------------------------------------
00006   /// Handle to the global UVM scoreboard configuration
00007   local cl_syoscb_cfg cfg;
00008 
00009   /// Array holding handles to all queues
00010   local cl_syoscb_queue queues[];
00011 
00012   // Handle to the compare startegy
00013   local cl_syoscb_compare compare_strategy;
00014 
00015   // Assoc array holding each uvm_subscriber
00016   local cl_syoscb_subscriber subscribers[string];
00017 
00018   //-------------------------------------
00019   // UVM Macros
00020   //-------------------------------------
00021   `uvm_component_utils_begin(cl_syoscb)
00022     `uvm_field_object(cfg, UVM_ALL_ON)
00023     `uvm_field_array_object(queues, UVM_ALL_ON)
00024     `uvm_field_object(compare_strategy, UVM_ALL_ON)
00025   `uvm_component_utils_end
00026 
00027   //-------------------------------------
00028   // Constructor
00029   //-------------------------------------
00030   extern function new(string name = "cl_syoscb", uvm_component parent = null);
00031 
00032   //-------------------------------------
00033   // UVM Phase methods
00034   //-------------------------------------
00035   extern function void build_phase(uvm_phase phase);
00036 
00037   //-------------------------------------
00038   // Function based API
00039   //-------------------------------------
00040   extern function void add_item(string queue_name, string producer, uvm_sequence_item item);
00041   extern function void compare();
00042 
00043   //-------------------------------------
00044   // Transaction based API
00045   //-------------------------------------
00046   extern function cl_syoscb_subscriber get_subscriber(string queue_name, string producer);
00047 endclass: cl_syoscb
00048 
00049 function cl_syoscb::new(string name = "cl_syoscb", uvm_component parent = null);
00050    super.new(name, parent);
00051 endfunction : new
00052 
00053 /// The build_phase gets the scoreboard configuration and forwards it to the child components (cl_syoscb_queue
00054 /// and cl_syoscb_compare). Additionally, it creates all of the queues defined in the configuration object. Finally,
00055 /// it also creates the compare strategy via a factory create call.
00056 function void cl_syoscb::build_phase(uvm_phase phase);
00057   if (!uvm_config_db #(cl_syoscb_cfg)::get(this, "", "cfg", this.cfg)) begin
00058     `uvm_fatal("CFG_ERROR", "Configuration object not passed.")
00059   end
00060 
00061   // Create list of queues
00062   this.queues = new[this.cfg.size_queues()];
00063 
00064   // Create the queues as defined in the configuration
00065   begin
00066     string queue_names[];
00067 
00068     // Get teh list of queue names
00069     this.cfg.get_queues(queue_names);
00070 
00071     foreach(queue_names[i]) begin
00072       this.queues[i] = cl_syoscb_queue::type_id::create(queue_names[i], this);
00073       this.cfg.set_queue(queue_names[i], this.queues[i]);
00074 
00075       // Forward the configuration to the queue
00076       uvm_config_db #(cl_syoscb_cfg)::set(this, queue_names[i], "cfg", this.cfg); 
00077     end
00078   end
00079 
00080   // Forward the configuration to the compare_strategy
00081   uvm_config_db #(cl_syoscb_cfg)::set(this, "compare_strategy", "cfg", this.cfg); 
00082 
00083   // Create the compare strategy
00084   this.compare_strategy = cl_syoscb_compare::type_id::create(.name("compare_strategy"), .parent(this));
00085 
00086   begin
00087     cl_syoscb_report_catcher catcher = new();
00088     uvm_report_cb::add(null, catcher);
00089   end
00090 
00091   begin
00092     string producers[];
00093 
00094     this.cfg.get_producers(producers);
00095 
00096     foreach(producers[i]) begin
00097       cl_syoscb_cfg_pl pl = this.cfg.get_producer(producers[i]);
00098 
00099       foreach(pl.list[j]) begin
00100         cl_syoscb_subscriber subscriber;
00101 
00102         subscriber = cl_syoscb_subscriber::type_id::create({producers[i], "_", pl.list[j], "_subscr"}, this);
00103         subscriber.set_queue_name(pl.list[j]);
00104         subscriber.set_producer(producers[i]);
00105         this.subscribers[{pl.list[j], producers[i]}] = subscriber;
00106       end
00107     end
00108   end
00109 endfunction: build_phase
00110 
00111 /// Method for adding a uvm_sequence_item to a given queue for a given producer.
00112 /// The method will check if the queue and producer exists before adding it to the queue.
00113 /// 
00114 /// The uvm_sequence_item will be wrapped by a cl_syoscb_item along with some META data
00115 /// Thus, it is the cl_syoscb_item which will be added to the queue and not the uvm_sequence_item
00116 /// directly.
00117 ///
00118 /// This ensures that the scoreboard can easily be added to an existing testbench with already defined
00119 /// sequence items etc.
00120 function void cl_syoscb::add_item(string queue_name, string producer, uvm_sequence_item item);
00121   uvm_sequence_item item_clone;
00122 
00123   // Check queue
00124   if(!this.cfg.exist_queue(queue_name)) begin
00125     `uvm_fatal("CFG_ERROR", $sformatf("Queue: %0s is not found", queue_name));
00126   end
00127 
00128   // Check producer
00129   if(!this.cfg.exist_producer(producer)) begin
00130     `uvm_fatal("CFG_ERROR", $sformatf("Producer: %0s is not found", producer));
00131   end
00132 
00133   // Clone the item if not disabled
00134   // Clone the item in order to isolate the UVM scb from the rest of the TB
00135   if(this.cfg.get_disable_clone() == 1'b0) begin
00136     if(!$cast(item_clone, item.clone())) begin
00137       `uvm_fatal("QUEUE_ERROR", "Unable to cast cloned item to uvm_sequence_item");
00138     end
00139   end else begin
00140     item_clone = item;
00141   end
00142 
00143   // Add the uvm_sequence_item to the queue for the given producer
00144   begin
00145     cl_syoscb_queue queue;
00146 
00147     queue = this.cfg.get_queue(queue_name);
00148    
00149     if(queue == null) begin
00150       `uvm_fatal("QUEUE_ERROR", $sformatf("Queue: %s not found by add_item method", queue_name));
00151     end
00152 
00153     if(!queue.add_item(producer, item_clone)) begin
00154       `uvm_fatal("QUEUE_ERROR", $sformatf("Unable to add item to queue: %s", queue_name));
00155     end
00156   end
00157 
00158   // Invoke the compare algorithm
00159   void'(this.compare());
00160 endfunction: add_item
00161 
00162 /// Invokes the compare strategy
00163 function void cl_syoscb::compare();
00164   this.compare_strategy.compare();
00165 endfunction: compare
00166 
00167 /// Returns a UVM subscriber for a given combination of queue and producer
00168 /// The retrurned UVM subscriber can then be connected to a UVM monitor or similar
00169 /// which produces transactions which should be scoreboarded.
00170 function cl_syoscb_subscriber cl_syoscb::get_subscriber(string queue_name, string producer);
00171     return(this.subscribers[{queue_name, producer}]);
00172 endfunction: get_subscriber
 All Classes Functions Variables

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.2.3

Copyright 2014-2015 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.6.1
IDV SV Filter Version: 2.6.2
Mon Sep 28 02:57:58 2015
Find a documentation bug? Report bugs to: bugs.intelligentdv.com Project: DoxygenFilterSV