forked from verilator/verilator
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Krzysztof Boronski <[email protected]>
- Loading branch information
1 parent
a3389f6
commit 970b5fc
Showing
3 changed files
with
413 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//------------------------------------------------------------------------------ | ||
// Copyright 2007-2011 Mentor Graphics Corporation | ||
// Copyright 2017 Intel Corporation | ||
// Copyright 2010 Synopsys, Inc. | ||
// Copyright 2007-2018 Cadence Design Systems, Inc. | ||
// Copyright 2010 AMD | ||
// Copyright 2015-2018 NVIDIA Corporation | ||
// 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. | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
`ifndef UVM_QUEUE_SVH | ||
`define UVM_QUEUE_SVH | ||
|
||
//------------------------------------------------------------------------------ | ||
// | ||
// CLASS -- NODOCS -- uvm_queue #(T) | ||
// | ||
//------------------------------------------------------------------------------ | ||
// Implements a class-based dynamic queue. Allows queues to be allocated on | ||
// demand, and passed and stored by reference. | ||
//------------------------------------------------------------------------------ | ||
|
||
//-!!!- NOTICE -------------------------------------------------------------!!!- | ||
// This is a non-production-ready modified version of UVM intended for coverage | ||
// testing purpouses | ||
//-!!!----------------------------------------------------------------------!!!- | ||
|
||
//UVM ~ | ||
// @uvm-ieee 1800.2-2017 auto 11.3.1 | ||
class uvm_queue #(type T=int) extends uvm_object; | ||
|
||
typedef uvm_queue #(T) this_type; | ||
|
||
//UVM `uvm_object_param_utils(uvm_queue#(T)) | ||
//UVM `uvm_type_name_decl("uvm_queue") | ||
|
||
static local this_type m_global_queue; | ||
protected T queue[$]; | ||
|
||
//UVM | ||
static function void uvmt_drop_globals(); | ||
m_global_queue = null; | ||
endfunction | ||
//UVM | ||
|
||
// Function -- NODOCS -- new | ||
// | ||
// Creates a new queue with the given ~name~. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.1 | ||
function new (string name=""); | ||
super.new(name); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- get_global_queue | ||
// | ||
// Returns the singleton global queue for the item type, T. | ||
// | ||
// This allows items to be shared amongst components throughout the | ||
// verification environment. | ||
|
||
static function this_type get_global_queue (); | ||
if (m_global_queue==null) | ||
m_global_queue = new("global_queue"); | ||
return m_global_queue; | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- get_global | ||
// | ||
// Returns the specified item instance from the global item queue. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.3 | ||
static function T get_global (int index); | ||
this_type gqueue; | ||
gqueue = get_global_queue(); | ||
return gqueue.get(index); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- get | ||
// | ||
// Returns the item at the given ~index~. | ||
// | ||
// If no item exists by that key, a new item is created with that key | ||
// and returned. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.4 | ||
virtual function T get (int index); | ||
T default_value; | ||
if (index >= size() || index < 0) begin | ||
//UVM uvm_report_warning("QUEUEGET", | ||
//UVM $sformatf("get: given index out of range for queue of size %0d. Ignoring get request",size())); | ||
//UVM return default_value; | ||
$display("get: given index out of range for queue of size %0d. Ignoring get request",size()); | ||
return default_value; | ||
//UVM | ||
end | ||
return queue[index]; | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- size | ||
// | ||
// Returns the number of items stored in the queue. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.5 | ||
virtual function int size (); | ||
return queue.size(); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- insert | ||
// | ||
// Inserts the item at the given ~index~ in the queue. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.6 | ||
virtual function void insert (int index, T item); | ||
if (index >= size() || index < 0) begin | ||
//UVM uvm_report_warning("QUEUEINS", | ||
//UVM $sformatf("insert: given index out of range for queue of size %0d. Ignoring insert request",size())); | ||
$display("insert: given index out of range for queue of size %0d. Ignoring insert request", size()); | ||
//UVM | ||
return; | ||
end | ||
queue.insert(index,item); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- delete | ||
// | ||
// Removes the item at the given ~index~ from the queue; if ~index~ is | ||
// not provided, the entire contents of the queue are deleted. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.7 | ||
virtual function void delete (int index=-1); | ||
if (index >= size() || index < -1) begin | ||
//UVM uvm_report_warning("QUEUEDEL", | ||
//UVM $sformatf("delete: given index out of range for queue of size %0d. Ignoring delete request",size())); | ||
//UVM return; | ||
$display("delete: given index out of range for queue of size %0d. Ignoring delete request",size()); | ||
//UVM | ||
end | ||
if (index == -1) | ||
queue.delete(); | ||
else | ||
queue.delete(index); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- pop_front | ||
// | ||
// Returns the first element in the queue (index=0), | ||
// or ~null~ if the queue is empty. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.8 | ||
virtual function T pop_front(); | ||
return queue.pop_front(); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- pop_back | ||
// | ||
// Returns the last element in the queue (index=size()-1), | ||
// or ~null~ if the queue is empty. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.9 | ||
virtual function T pop_back(); | ||
return queue.pop_back(); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- push_front | ||
// | ||
// Inserts the given ~item~ at the front of the queue. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.10 | ||
virtual function void push_front(T item); | ||
queue.push_front(item); | ||
endfunction | ||
|
||
|
||
// Function -- NODOCS -- push_back | ||
// | ||
// Inserts the given ~item~ at the back of the queue. | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.11 | ||
virtual function void push_back(T item); | ||
queue.push_back(item); | ||
endfunction | ||
|
||
// Task -- NODOCS -- wait_until_not_empty | ||
// | ||
// Blocks until not empty | ||
|
||
// @uvm-ieee 1800.2-2017 auto 11.3.2.12 | ||
virtual task wait_until_not_empty(); | ||
wait(queue.size() > 0); | ||
endtask | ||
|
||
//UVM virtual function void do_copy (uvm_object rhs); | ||
//UVM this_type p; | ||
//UVM super.do_copy(rhs); | ||
//UVM if (rhs == null || !$cast(p, rhs)) | ||
//UVM return; | ||
//UVM queue = p.queue; | ||
//UVM endfunction | ||
|
||
virtual function string convert2string(); | ||
return $sformatf("%p",queue); | ||
endfunction | ||
|
||
endclass | ||
|
||
|
||
`endif // UVM_QUEUE_SVH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env perl | ||
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } | ||
# DESCRIPTION: Verilator: Verilog Test driver/expect definition | ||
# | ||
# Copyright 2023 by Wilson Snyder. This program is free software; you | ||
# can redistribute it and/or modify it under the terms of either the GNU | ||
# Lesser General Public License Version 3 or the Perl Artistic License | ||
# Version 2.0. | ||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 | ||
|
||
scenarios(simulator => 1); | ||
|
||
compile( | ||
verilator_flags2 => ["--binary", "--timing", | ||
"-Wno-PKGNODECL -Wno-IMPLICITSTATIC -Wno-CONSTRAINTIGN -Wno-MISINDENT", | ||
"-Wno-WIDTHEXPAND -Wno-WIDTHTRUNC -Wno-CASTCONST -Wno-REALCVT", | ||
"-It/t_uvm", "-DUVM_REGEX_NO_DPI"], | ||
verilator_make_gmake => 0, | ||
make_main => 0, | ||
); | ||
|
||
execute( | ||
check_finished => 1, | ||
); | ||
|
||
ok(1); | ||
1; |
Oops, something went wrong.