54 `uvm_component_utils_begin(cl_syoscb_queue_base)
55 `uvm_field_object(cfg, UVM_DEFAULT | UVM_REFERENCE)
56 `uvm_field_aa_int_string(cnt_producer, UVM_DEFAULT | UVM_DEC)
57 `uvm_field_int(cnt_add_item, UVM_DEFAULT | UVM_DEC)
58 `uvm_field_int(max_items, UVM_DEFAULT | UVM_DEC)
59 `uvm_field_object(last_inserted_item, UVM_DEFAULT)
60 `uvm_field_queue_object(shadow_items, UVM_DEFAULT)
61 `uvm_field_int(nbr_items_dumped, UVM_DEFAULT | UVM_DEC)
62 `uvm_field_aa_int_string(total_cnt_producer, UVM_DEFAULT | UVM_DEC)
63 `uvm_field_aa_int_string(total_cnt_flushed_producer, UVM_DEFAULT | UVM_DEC)
64 `uvm_field_aa_string_string(failed_checks, UVM_DEFAULT)
65 `uvm_field_int(num_iters_created, UVM_DEFAULT | UVM_DEC)
66 `uvm_component_utils_end
71 function new(string name, uvm_component parent);
72 super.new(name, parent);
87 extern
virtual function bit
add_item(string producer, uvm_sequence_item item);
88 extern
virtual function bit
delete_item(cl_syoscb_proxy_item_base proxy_item);
89 extern
virtual function void
dump(uvm_printer printer = null, int fd = UVM_STDOUT);
91 extern
virtual function int unsigned
get_size();
92 extern
virtual function bit
empty();
93 extern
virtual function bit
insert_item(string producer,
94 uvm_sequence_item item,
101 extern
virtual function bit
delete_iterator(cl_syoscb_queue_iterator_base iterator);
117 int unsigned first_column_width);
123 extern
protected virtual function void
post_add_item(cl_syoscb_item item);
130 int unsigned first_column_width);
135 extern
virtual function void do_print(uvm_printer printer);
136 extern
virtual function bit do_compare(uvm_object rhs, uvm_comparer comparer);
137 extern
virtual function void do_copy(uvm_object rhs);
138 extern
virtual function void pre_abort();
143 if (!uvm_config_db #(cl_syoscb_cfg)::get(this, "", "cfg", this.cfg)) begin
144 `uvm_fatal("CFG_ERROR", $sformatf("[%s]: Configuration object not passed.", this.cfg.get_scb_name()))
152 if(!this.empty()) begin
155 this.
failed_checks["QUEUE_NOT_EMPTY"] = $sformatf("Queue %s not empty, orphans: %0d",
156 this.get_name(), this.get_size());
159 if(this.cfg.get_max_print_orphans() >= 0) begin
162 if(this.cfg.get_dump_orphans_to_files()) begin
169 if (this.cfg.get_enable_no_insert_check && this.get_cnt_add_item === 0) begin
170 this.
failed_checks["QUEUE_NO_INSERTS"] = $sformatf("Queue %s had no insertions", this.get_name());
187 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::add_item() *MUST* be overwritten", this.cfg.get_scb_name()));
201 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::delete_item() *MUST* be overwritten", this.cfg.get_scb_name()));
217 new_item.set_name({producer,"-item-", $psprintf("%0d", new_item.get_inst_id())});
220 new_item.set_item(item);
221 new_item.set_producer(producer);
222 new_item.set_insertion_index(this.cnt_add_item);
231 if(this.cfg.get_full_scb_dump()) begin
237 if(this.get_size() > this.
max_items) begin
249 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::get_item() *MUST* be overwritten", this.cfg.get_scb_name()));
258 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::get_size() *MUST* be overwritten", this.cfg.get_scb_name()));
267 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::empty() *MUST* be overwritten", this.cfg.get_scb_name()));
282 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::insert_item() *MUST* be overwritten", this.cfg.get_scb_name()));
291 this.
cfg.get_producers(producers);
293 foreach (producers[i]) begin
294 if(this.cnt_producer.exists(producers[i])) begin
301 while(this.iter_sem.try_get() == 0);
302 foreach(this.iterators[i]) begin
303 void'(this.iterators[i].first());
311 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue::do_flush_queue() *MUST* be overwritten", this.cfg.get_scb_name()));
321 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::create_iterator() *MUST* be overwritten", this.cfg.get_scb_name()));
332 f = this.
iterators.find_index() with (item.get_name() == name);
333 if(f.size() > 1) begin
334 `uvm_error("ITERATOR_ERROR", $sformatf("[%0s]: Found %0d iterators with the same name (%0s), don't know what to do", this.cfg.get_scb_name(), f.size(), name))
335 end else if (f.size() == 1) begin
346 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::delete_item() *MUST* be overwritten", this.cfg.get_scb_name()));
353 `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_queue_base::get_locator() *MUST* be overwritten", this.cfg.get_scb_name()));
365 if(!this.cnt_producer.exists(producer)) begin
381 if(!this.cnt_producer.exists(producer)) begin
382 `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: Trying to decrement a non-existing producer: %s ", this.cfg.get_scb_name(), producer));
385 if(this.cnt_producer[producer] == 0) begin
386 `uvm_fatal("QUEUE_ERROR", $sformatf("[%s]: Trying to decrement the producer: %s which has count 0", this.cfg.get_scb_name(), producer));
424 return this.
cnt_add_item - (this.get_cnt_flushed_item()+this.get_size());
442 uvm_printer printer_used;
444 if(this.cfg.get_full_scb_dump() == 1'b0) begin
445 `uvm_fatal("CFG_ERROR", "Cannot dump queue contents when get_full_scb_dump is disabled")
449 if(this.cfg.get_full_scb_dump_type() == pk_syoscb::XML) begin
454 foreach(this.shadow_items[i])begin
457 case (this.cfg.get_full_scb_dump_type())
458 pk_syoscb::TXT: begin
459 $fwrite (fd, $sformatf("\n
462 printer_used = (printer != null) ? printer : this.cfg.get_printer(this.get_name(), this.shadow_items[i].get_producer());
463 if(printer_used == null) begin
464 printer_used = this.cfg.get_default_printer();
467 pk_syoscb::XML: begin
468 $fwrite (fd, $sformatf("\n<!-- item: %9d -->\n",this.nbr_items_dumped++));
471 cl_syoscb_printer_config::set_file_descriptor(printer_used, fd);
473 if(this.cfg.get_full_scb_dump_type() == pk_syoscb::TXT && this.cfg.get_enable_c2s_full_scb_dump()) begin
474 $fwrite(fd, {this.shadow_items[i].convert2string(), "\n"});
476 this.shadow_items[i].print(printer_used);
479 this.shadow_items.delete();
484 function void cl_syoscb_queue_base::dump_orphans_to_stdout();
485 cl_syoscb_queue_iterator_base l_iterator;
486 cl_syoscb_item l_scb_item;
487 cl_syoscb_proxy_item_base l_proxy_item;
491 if(this.cfg.get_max_print_orphans() < 0) begin
495 l_iterator = this.create_iterator();
496 void'(l_iterator.first());
499 while(l_iterator.has_next() &&
500 (this.cfg.get_max_print_orphans() > 0 -> (l_iterator.next_index() < this.cfg.get_max_print_orphans()))) begin
502 l_proxy_item = l_iterator.next();
503 l_scb_item = l_proxy_item.get_item();
504 l_scb_item.set_queue_index(l_iterator.previous_index());
507 if(this.cfg.get_orphans_as_errors()) begin
508 `uvm_error(this.get_name(), $sformatf("\n%s", l_scb_item.sprint()))
511 `uvm_info(this.get_name(), $sformatf("\n%s", l_scb_item.sprint()), UVM_NONE)
515 void'(this.delete_iterator(l_iterator));
517 endfunction: dump_orphans_to_stdout
521 function void cl_syoscb_queue_base::dump_orphans_to_file();
522 cl_syoscb_queue_iterator_base l_iterator;
523 cl_syoscb_item l_scb_item;
524 cl_syoscb_proxy_item_base l_proxy_item;
529 if(this.cfg.get_max_print_orphans() < 0) begin
533 ext = this.get_dump_extension(this.cfg.get_orphan_dump_type());
534 fd = $fopen($sformatf("%s.%s.%s_orphans.%s", this.cfg.get_scb_name(), this.cfg.get_orphan_dump_file_name(), this.get_name(), ext), "w");
537 if(this.cfg.get_orphan_dump_type() == pk_syoscb::XML) begin
538 uvm_xml_printer xp = new;
540 cl_syoscb_printer_config::set_file_descriptor(printer, fd);
541 this.print_orphan_xml_header(fd);
544 l_iterator = this.create_iterator();
545 void'(l_iterator.first());
547 while(l_iterator.has_next() &&
548 (this.cfg.get_max_print_orphans() > 0 -> (l_iterator.next_index() < this.cfg.get_max_print_orphans()))) begin
550 l_proxy_item = l_iterator.next();
551 l_scb_item = l_proxy_item.get_item();
552 l_scb_item.set_queue_index(l_iterator.previous_index());
556 if(this.cfg.get_orphan_dump_type() == pk_syoscb::TXT) begin
557 printer = this.cfg.get_printer(this.get_name(), l_scb_item.get_producer());
559 printer = (printer != null) ? printer : this.cfg.get_default_printer();
560 cl_syoscb_printer_config::set_file_descriptor(printer, fd);
563 l_scb_item.print(printer);
566 if(this.cfg.get_orphan_dump_type() == pk_syoscb::XML) begin
567 this.print_orphan_xml_footer(fd);
571 void'(this.delete_iterator(l_iterator));
572 endfunction: dump_orphans_to_file
577 function string cl_syoscb_queue_base::get_failed_checks();
578 if(this.failed_checks.size() == 0) begin
581 string failed_checks_str;
583 foreach(this.failed_checks[str]) begin
584 failed_checks_str = { failed_checks_str, " ", str, ": ", failed_checks[str], "\n"};
587 return failed_checks_str;
589 endfunction: get_failed_checks
597 function string cl_syoscb_queue_base::create_producer_stats(int unsigned offset, int unsigned first_column_width);
599 string producer_stats;
601 this.cfg.get_producers(producers);
603 foreach (producers[i]) begin
604 if(this.total_cnt_producer.exists(producers[i])) begin
605 producer_stats = { producer_stats,
607 $sformatf("%s%s | %8d | %8d | %8d | %8d |",
608 cl_syoscb_string_library::pad_str("", offset),
609 cl_syoscb_string_library::pad_str(producers[i], first_column_width, " ", 1'b1),
610 this.total_cnt_producer[producers[i]],
611 this.total_cnt_producer[producers[i]]-(this.total_cnt_flushed_producer[producers[i]]+this.cnt_producer[producers[i]]),
612 this.total_cnt_flushed_producer[producers[i]],
613 this.cnt_producer[producers[i]])};
615 producer_stats = { producer_stats,
617 $sformatf("%s%s | %8d | %8d | %8d | %8d |",
618 cl_syoscb_string_library::pad_str("", offset),
619 cl_syoscb_string_library::pad_str(producers[i], first_column_width, " ", 1'b1),
627 return producer_stats;
628 endfunction: create_producer_stats
638 function string cl_syoscb_queue_base::create_queue_report(int unsigned offset, int unsigned first_column_width);
640 stats_str = { stats_str,
642 $sformatf("%s%s | %8d | %8d | %8d | %8d |",
643 cl_syoscb_string_library::pad_str("", offset),
644 cl_syoscb_string_library::pad_str(this.get_name(), first_column_width, " ", 1'b1),
645 this.get_cnt_add_item(),
646 this.get_cnt_matched_item(),
647 this.get_cnt_flushed_item(),
649 if(this.cfg.get_enable_queue_stats(this.get_name())) begin
650 stats_str = {stats_str, this.create_producer_stats(offset+pk_syoscb::GLOBAL_REPORT_INDENTION, first_column_width-pk_syoscb::GLOBAL_REPORT_INDENTION)};
654 endfunction: create_queue_report
659 function string cl_syoscb_queue_base::get_dump_extension(t_dump_type dump_type);
662 pk_syoscb::TXT: r = "txt";
663 pk_syoscb::XML: r = "xml";
664 default: `uvm_fatal("CFG_ERROR", $sformatf("No file extension associated with dump type %0s/%0d", dump_type.name(), dump_type))
667 endfunction: get_dump_extension
672 function void cl_syoscb_queue_base::print_orphan_xml_header(int fd);
675 "<?xml version='1.0' encoding='UTF-8'?>\n",
676 "<scb name='", this.cfg.get_scb_name(), " orphans'>\n",
678 "<queue name='", this.get_name(), "'>\n",
683 endfunction: print_orphan_xml_header
688 function void cl_syoscb_queue_base::print_orphan_xml_footer(int fd);
697 endfunction: print_orphan_xml_footer
701 function void cl_syoscb_queue_base::do_print(uvm_printer printer);
702 cl_syoscb_queue_iterator_base l_iterator;
704 if(this.iterators.first(l_iterator)) begin
705 printer.print_generic(.name("iterators"),
707 .size(this.iterators.size()),
710 printer.print_generic(.name($sformatf(" [%s]", l_iterator.get_name())),
711 .type_name("cl_syoscb_iterator"),
712 .size(l_iterator == null ? 0 :1),
713 .value(l_iterator == null? "<null>" : $sformatf("<%0d>",
714 l_iterator.get_inst_id())));
716 while(this.iterators.next(l_iterator));
719 super.do_print(printer);
720 endfunction: do_print
723 function bit cl_syoscb_queue_base::do_compare(uvm_object rhs, uvm_comparer comparer);
724 cl_syoscb_queue_base rhs_cast;
725 bit compare_result = super.do_compare(rhs, comparer);
727 if(!$cast(rhs_cast, rhs))begin
728 `uvm_fatal("do_compare",
729 $sformatf("The given object argument is not %0p type", rhs_cast.get_type()))
734 if(rhs_cast.iterators.size() != this.iterators.size()) begin
741 foreach(this.iterators[i]) begin
742 compare_result &= comparer.compare_object($sformatf("%0s", this.iterators[i].get_name()),
744 rhs_cast.iterators[i]);
748 return compare_result;
749 endfunction: do_compare
753 function void cl_syoscb_queue_base::do_copy(uvm_object rhs);
754 cl_syoscb_queue_base rhs_cast;
756 if(!$cast(rhs_cast, rhs))begin
757 `uvm_fatal("do_copy",
758 $sformatf("The given object argument is not %0p type", rhs_cast.get_type()))
764 this.iterators.delete();
766 foreach(rhs_cast.iterators[i]) begin
767 cl_syoscb_queue_iterator_base l_iterator;
770 if(!$cast(l_iterator, rhs_cast.iterators[i].clone())) begin
771 `uvm_fatal("do_copy",
772 $sformatf("Clone of iterator: '%0s' failed!", rhs_cast.iterators[i].get_name()))
775 this.iterators[l_iterator] = l_iterator;
783 function void cl_syoscb_queue_base::pre_abort();
784 if(this.cfg.get_dump_orphans_to_files()) begin
785 this.dump_orphans_to_file();
787 endfunction: pre_abort
virtual cl_syoscb_item get_last_inserted_item()
Queue API: Gets the last inserted item in the queue
cl_syoscb_item shadow_items[$]
Shadow queue tracking all items inserted into the queue, used for scoreboard dumps.
virtual string create_producer_stats(int unsigned offset, int unsigned first_column_width)
Returns a table with statistics for all producers in this queue.
cl_syoscb_queue_iterator_base iterators[cl_syoscb_queue_iterator_base]
List of iterators registered with this queue.
virtual void incr_cnt_producer(string producer)
Increment the producer counter for a given producer.
virtual void dump(uvm_printer printer=null, int fd=UVM_STDOUT)
Queue API: Loop over all the items in the shadow queue and dump them.
virtual void post_add_item(cl_syoscb_item item)
Perform some basic bookkeping that is the same for all sequence items after insertion.
The UVM scoreboard item which wraps uvm_sequence_item .
virtual cl_syoscb_queue_iterator_base get_iterator(string name)
Queue API: Gets the iterator from this queue with a given name.
virtual void dump_orphans_to_stdout()
Prints orphans remaining in the queue to stdout.
virtual bit delete_item(cl_syoscb_proxy_item_base proxy_item)
Queue API: Deletes the item indicated by the proxy item from the queue.
cl_syoscb_item last_inserted_item
The most recently inserted item in this queue.
virtual bit exists_cnt_producer(string producer)
Queue API: Check if a given producer exists in the producer counter for this queue ...
An XML printer for cl_syoscb_items.
int unsigned cnt_add_item
Number of items that have been inserted into this queue.
virtual void flush_queue()
Queue API: Deletes all elements from the queue.
virtual void do_flush_queue()
Performs the actual element deletion from the queue when called by flush_queue.
virtual int unsigned get_cnt_matched_item()
Queue API: Returns the total number of elements matched in this queue
virtual void dump_orphans_to_file()
Dumps orphans remaining in the queue into a logfile.
virtual void decr_cnt_producer(string producer)
Decrement the producer counter for a given producer.
virtual int unsigned get_cnt_add_item()
Queue API: Returns the number of items that have been inserted in this queue
Locator base class defining the locator API used for searching in queues.
virtual string get_failed_checks()
Queue API: Gets a string containing all queue checks that this queue have failed. ...
virtual string create_queue_report(int unsigned offset, int unsigned first_column_width)
Queue API: Returns a string with overall queues statistics.
semaphore iter_sem
Semaphore guarding exclusive access to the queue when multiple iterators are in play.
virtual bit insert_item(string producer, uvm_sequence_item item, int unsigned idx)
Queue API: Inserts a uvm_sequence_item at index idx.
Queue iterator base class defining the iterator API used for iterating over queues.
virtual cl_syoscb_item pre_add_item(string producer, uvm_sequence_item item)
Perform some basic bookkeeping that is the same for all sequence items before insertion.
int unsigned nbr_items_dumped
Number of items that have been dumped from this queue when performing a scoreboard dump...
virtual void print_orphan_xml_header(int fd)
Prints the header for an XML orphan dump.
Class which represents the base concept of a queue.
virtual int unsigned get_cnt_flushed_item()
Queue API: Returns the total number of elements flushed from this queue.
void build_phase(uvm_phase phase)
UVM Build Phase. Gets the scoreboard configuration for this SCB.
virtual cl_syoscb_queue_iterator_base create_iterator(string name="")
Queue API: Creates an iterator for this queue.
virtual string get_dump_extension(t_dump_type dump_type)
Gets the file extension to be used for a dump file.
virtual int unsigned get_max_items()
Queue API: Returns the maximum number of elements that have been in the queue.
virtual int unsigned get_cnt_producer(string producer)
Queue API: Get the producer count for a given producer.
int num_iters_created
The number of iterators that have been created for this queue so far.
void check_phase(uvm_phase phase)
UVM check phase.
string failed_checks[string]
AA for storing queue debug checks during the UVM check phase.
virtual bit delete_iterator(cl_syoscb_queue_iterator_base iterator)
Queue API: Deletes an iterator from this queue.
virtual bit empty()
Queue API: Returns whether or not the queue is empty.
cl_syoscb_cfg cfg
Handle to the configuration.
virtual cl_syoscb_queue_locator_base get_locator()
Queue API: Creates a locator for this queue.
virtual bit add_item(string producer, uvm_sequence_item item)
Queue API: Adds a uvm_sequence_item to this queue.
Configuration class for the SyoSil UVM scoreboard.
int unsigned max_items
Maximum number of items that have been in this queue so far.
virtual void print_orphan_xml_footer(int fd)
Prints the footer for an XML orphan dump.
virtual cl_syoscb_item get_item(cl_syoscb_proxy_item_base proxy_item)
Queue API: Gets the item pointed to by the proxy item from the queue.
int unsigned cnt_producer[string]
Associative array counting the number of items by a given producer that currently exist in the queue...
int unsigned total_cnt_flushed_producer[string]
Associative array counter the total number of items by a given producer that have been flused form th...
virtual int unsigned get_size()
Queue API: Returns the current size of the queue.
int unsigned total_cnt_producer[string]
Associative array counting the total number of items by a given producer that have been inserted in t...