1 |
4 |
vladimirar |
//----------------------------------------------------------------------
|
2 |
|
|
// Copyright 2014-2015 SyoSil ApS
|
3 |
|
|
// All Rights Reserved Worldwide
|
4 |
|
|
//
|
5 |
|
|
// Licensed under the Apache License, Version 2.0 (the
|
6 |
|
|
// "License"); you may not use this file except in
|
7 |
|
|
// compliance with the License. You may obtain a copy of
|
8 |
|
|
// the License at
|
9 |
|
|
//
|
10 |
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
11 |
|
|
//
|
12 |
|
|
// Unless required by applicable law or agreed to in
|
13 |
|
|
// writing, software distributed under the License is
|
14 |
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
15 |
|
|
// CONDITIONS OF ANY KIND, either express or implied. See
|
16 |
|
|
// the License for the specific language governing
|
17 |
|
|
// permissions and limitations under the License.
|
18 |
|
|
//----------------------------------------------------------------------
|
19 |
|
|
// *NOTES*:
|
20 |
|
|
// Simple OOO compare test using the TLM based API
|
21 |
|
|
|
22 |
|
|
// This class implements a monitor which does a sequence of
|
23 |
|
|
// writes on it's analysis port with random waits in between
|
24 |
|
|
class cl_ooo_tlm_monitor extends uvm_monitor;
|
25 |
|
|
//-------------------------------------
|
26 |
|
|
// Non randomizable variables
|
27 |
|
|
//-------------------------------------
|
28 |
|
|
uvm_analysis_port #(uvm_sequence_item) anls_port;
|
29 |
|
|
|
30 |
|
|
//-------------------------------------
|
31 |
|
|
// UVM Macros
|
32 |
|
|
//-------------------------------------
|
33 |
|
|
`uvm_component_utils(cl_ooo_tlm_monitor)
|
34 |
|
|
|
35 |
|
|
//-------------------------------------
|
36 |
|
|
// Constructor
|
37 |
|
|
//-------------------------------------
|
38 |
|
|
extern function new(string name, uvm_component p = null);
|
39 |
|
|
|
40 |
|
|
//-------------------------------------
|
41 |
|
|
// UVM Phase methods
|
42 |
|
|
//-------------------------------------
|
43 |
|
|
extern function void build_phase(uvm_phase phase);
|
44 |
|
|
extern task run_phase(uvm_phase phase);
|
45 |
|
|
endclass: cl_ooo_tlm_monitor
|
46 |
|
|
|
47 |
|
|
function cl_ooo_tlm_monitor::new(string name, uvm_component p = null);
|
48 |
|
|
super.new(name,p);
|
49 |
|
|
endfunction
|
50 |
|
|
|
51 |
|
|
function void cl_ooo_tlm_monitor::build_phase(uvm_phase phase);
|
52 |
|
|
cl_syoscb_queue::set_type_override_by_type(cl_syoscb_queue::get_type(),
|
53 |
|
|
cl_syoscb_queue_std::get_type(),
|
54 |
|
|
"*");
|
55 |
|
|
|
56 |
|
|
this.set_type_override_by_type(cl_syoscb_compare_base::get_type(),
|
57 |
|
|
cl_syoscb_compare_iop::get_type(),
|
58 |
|
|
"*");
|
59 |
|
|
|
60 |
|
|
super.build_phase(phase);
|
61 |
|
|
this.anls_port = new("anls_port", this);
|
62 |
|
|
endfunction: build_phase
|
63 |
|
|
|
64 |
|
|
task cl_ooo_tlm_monitor::run_phase(uvm_phase phase);
|
65 |
|
|
cl_scbtest_seq_item a;
|
66 |
|
|
|
67 |
|
|
// Raise objection
|
68 |
|
|
phase.raise_objection(this);
|
69 |
|
|
|
70 |
|
|
super.run_phase(phase);
|
71 |
|
|
|
72 |
|
|
// Create UVM sequence item
|
73 |
|
|
a = new();
|
74 |
|
|
|
75 |
|
|
// Produce 100 writes
|
76 |
|
|
for(int i=0; i<100; i++) begin
|
77 |
|
|
int unsigned ws;
|
78 |
|
|
|
79 |
|
|
// Generate random wait
|
80 |
|
|
ws = $urandom_range(100, 10);
|
81 |
|
|
|
82 |
|
|
`uvm_info("OOO_TLM_MON", $sformatf("[%0d]: Waiting %0d time units", i, ws), UVM_NONE);
|
83 |
|
|
|
84 |
|
|
// Do the wait
|
85 |
|
|
#(ws);
|
86 |
|
|
|
87 |
|
|
`uvm_info("OOO_TLM_MON", $sformatf("[%0d]: Wait done", i), UVM_NONE);
|
88 |
|
|
|
89 |
|
|
// Use increasing values. This will work since we have an OOO compare
|
90 |
|
|
a.int_a = i;
|
91 |
|
|
|
92 |
|
|
// Write to the analysis port. This will mimic e.g. a monitor instantiated inside a UVM agent
|
93 |
|
|
// which samples transactions and writres them to its subscribers
|
94 |
|
|
anls_port.write(a);
|
95 |
|
|
end
|
96 |
|
|
|
97 |
|
|
// Drop objection
|
98 |
|
|
phase.drop_objection(this);
|
99 |
|
|
endtask: run_phase
|
100 |
|
|
|
101 |
|
|
class cl_scbtest_test_ooo_tlm extends cl_scbtest_test_base;
|
102 |
|
|
//-------------------------------------
|
103 |
|
|
// Non randomizable variables
|
104 |
|
|
//-------------------------------------
|
105 |
|
|
cl_ooo_tlm_monitor monQ1P1;
|
106 |
|
|
cl_ooo_tlm_monitor monQ2P1;
|
107 |
|
|
|
108 |
|
|
//-------------------------------------
|
109 |
|
|
// UVM Macros
|
110 |
|
|
//-------------------------------------
|
111 |
|
|
`uvm_component_utils(cl_scbtest_test_ooo_tlm)
|
112 |
|
|
|
113 |
|
|
//-------------------------------------
|
114 |
|
|
// Constructor
|
115 |
|
|
//-------------------------------------
|
116 |
|
|
extern function new(string name = "cl_scbtest_test_ooo_tlm", uvm_component parent = null);
|
117 |
|
|
|
118 |
|
|
//-------------------------------------
|
119 |
|
|
// UVM Phase methods
|
120 |
|
|
//-------------------------------------
|
121 |
|
|
extern function void build_phase(uvm_phase phase);
|
122 |
|
|
extern function void connect_phase(uvm_phase phase);
|
123 |
|
|
extern task run_phase(uvm_phase phase);
|
124 |
|
|
endclass : cl_scbtest_test_ooo_tlm
|
125 |
|
|
|
126 |
|
|
function cl_scbtest_test_ooo_tlm::new(string name = "cl_scbtest_test_ooo_tlm", uvm_component parent = null);
|
127 |
|
|
super.new(name, parent);
|
128 |
|
|
endfunction : new
|
129 |
|
|
|
130 |
|
|
function void cl_scbtest_test_ooo_tlm::build_phase(uvm_phase phase);
|
131 |
|
|
super.build_phase(phase);
|
132 |
|
|
|
133 |
|
|
this.monQ1P1 = new("monQ1P1", this);
|
134 |
|
|
this.monQ2P1 = new("monQ2P1", this);
|
135 |
|
|
endfunction: build_phase
|
136 |
|
|
|
137 |
|
|
function void cl_scbtest_test_ooo_tlm::connect_phase(uvm_phase phase);
|
138 |
|
|
super.connect_phase(phase);
|
139 |
|
|
|
140 |
|
|
// *NOTE*: This will hook up the TLM monitors with the TLM API of the
|
141 |
|
|
// scoreboard. Normally, this would not be done here but in the
|
142 |
|
|
// testbench environment which would have access to all of the
|
143 |
|
|
// montors and the scoreboard. However, these monitors only
|
144 |
|
|
// exists for this specific test. Thus, it is done here locally.
|
145 |
|
|
begin
|
146 |
|
|
cl_syoscb_subscriber subscriber;
|
147 |
|
|
|
148 |
|
|
// Get the subscriber for Producer: P1 for queue: Q1 and connect it
|
149 |
|
|
// to the UVM monitor producing transactions for this queue
|
150 |
|
|
subscriber = this.scbtest_env.syoscb[0].get_subscriber("Q1", "P1");
|
151 |
|
|
this.monQ1P1.anls_port.connect(subscriber.analysis_export);
|
152 |
|
|
|
153 |
|
|
// Get the subscriber for Producer: P1 for queue: Q2 and connect it
|
154 |
|
|
// to the UVM monitor producing transactions for this queue
|
155 |
|
|
subscriber = this.scbtest_env.syoscb[0].get_subscriber("Q2", "P1");
|
156 |
|
|
this.monQ2P1.anls_port.connect(subscriber.analysis_export);
|
157 |
|
|
end
|
158 |
|
|
endfunction: connect_phase
|
159 |
|
|
|
160 |
|
|
task cl_scbtest_test_ooo_tlm::run_phase(uvm_phase phase);
|
161 |
|
|
// Raise objection
|
162 |
|
|
phase.raise_objection(this);
|
163 |
|
|
|
164 |
|
|
super.run_phase(phase);
|
165 |
|
|
|
166 |
|
|
// *NOTE*: This test is intentionally empty since
|
167 |
|
|
// All of the stimulti is coming from the TLM monitors
|
168 |
|
|
|
169 |
|
|
// Drop objection
|
170 |
|
|
phase.drop_objection(this);
|
171 |
|
|
endtask: run_phase
|