OpenCores
URL https://opencores.org/ocsvn/lpffir/lpffir/trunk

Subversion Repositories lpffir

[/] [lpffir/] [trunk/] [uvm/] [tools/] [uvm_syoscb/] [tb/] [test/] [cl_scbtest_test_ooo_tlm_ap.svh] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
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_ap_monitor extends uvm_monitor;
25
  //-------------------------------------
26
  // Non randomizable variables
27
  //-------------------------------------
28
//  uvm_analysis_port #(uvm_sequence_item) anls_port;
29
  uvm_analysis_port #(cl_scbtest_seq_item) anls_port;
30
 
31
  //-------------------------------------
32
  // UVM Macros
33
  //-------------------------------------
34
  `uvm_component_utils(cl_ooo_tlm_ap_monitor)
35
 
36
  //-------------------------------------
37
  // Constructor
38
  //-------------------------------------
39
  extern function new(string name, uvm_component p = null);
40
 
41
  //-------------------------------------
42
  // UVM Phase methods
43
  //-------------------------------------
44
  extern function void build_phase(uvm_phase phase);
45
  extern task run_phase(uvm_phase phase);
46
endclass: cl_ooo_tlm_ap_monitor
47
 
48
function cl_ooo_tlm_ap_monitor::new(string name, uvm_component p = null);
49
  super.new(name,p);
50
endfunction
51
 
52
function void cl_ooo_tlm_ap_monitor::build_phase(uvm_phase phase);
53
  super.build_phase(phase);
54
  this.anls_port = new("anls_port", this);
55
endfunction: build_phase
56
 
57
task cl_ooo_tlm_ap_monitor::run_phase(uvm_phase phase);
58
  cl_scbtest_seq_item a;
59
 
60
  // Raise objection
61
  phase.raise_objection(this);
62
 
63
  super.run_phase(phase);
64
 
65
  // Create UVM sequence item
66
  a = new();
67
 
68
  // Produce 100 writes
69
  for(int i=0; i<100; i++) begin
70
    int unsigned ws;
71
 
72
    // Generate random wait
73
    ws = $urandom_range(100, 10);
74
 
75
    `uvm_info("OOO_TLM_AP_MON", $sformatf("[%0d]: Waiting %0d time units", i, ws), UVM_NONE);
76
 
77
    // Do the wait
78
    #(ws);
79
 
80
    `uvm_info("OOO_TLM_AP_MON", $sformatf("[%0d]: Wait done", i), UVM_NONE);
81
 
82
    // Use increasing values. This will work since we have an OOO compare
83
    a.int_a = i;
84
 
85
    // Write to the analysis port. This will mimic e.g. a monitor instantiated inside a UVM agent
86
    // which samples transactions and writres them to its subscribers
87
    anls_port.write(a);
88
  end
89
 
90
  // Drop objection
91
  phase.drop_objection(this);
92
endtask: run_phase
93
 
94
class cl_scbtest_test_ooo_tlm_ap extends cl_scbtest_test_base;
95
  //-------------------------------------
96
  // Non randomizable variables
97
  //-------------------------------------
98
  cl_ooo_tlm_ap_monitor monQ1P1;
99
  cl_ooo_tlm_ap_monitor monQ2P1;
100
 
101
  //-------------------------------------
102
  // UVM Macros
103
  //-------------------------------------
104
  `uvm_component_utils(cl_scbtest_test_ooo_tlm_ap)
105
 
106
  //-------------------------------------
107
  // Constructor
108
  //-------------------------------------
109
  extern function new(string name = "cl_scbtest_test_ooo_tlm_ap", uvm_component parent = null);
110
 
111
  //-------------------------------------
112
  // UVM Phase methods
113
  //-------------------------------------
114
  extern function void build_phase(uvm_phase phase);
115
  extern function void connect_phase(uvm_phase phase);
116
  extern task run_phase(uvm_phase phase);
117
endclass : cl_scbtest_test_ooo_tlm_ap
118
 
119
function cl_scbtest_test_ooo_tlm_ap::new(string name = "cl_scbtest_test_ooo_tlm_ap", uvm_component parent = null);
120
  super.new(name, parent);
121
endfunction : new
122
 
123
function void cl_scbtest_test_ooo_tlm_ap::build_phase(uvm_phase phase);
124
  super.build_phase(phase);
125
 
126
  cl_syoscb_queue::set_type_override_by_type(cl_syoscb_queue::get_type(),
127
      cl_syoscb_queue_std::get_type(),
128
      "*");
129
 
130
  this.set_type_override_by_type(cl_syoscb_compare_base::get_type(),
131
      cl_syoscb_compare_ooo::get_type(),
132
      "*");
133
 
134
  this.monQ1P1 = new("monQ1P1", this);
135
  this.monQ2P1 = new("monQ2P1", this);
136
 
137
  begin
138
    cl_syoscb_cfg scb_cfg;
139
 
140
    scb_cfg = cl_syoscb_cfg::type_id::create("scb_cfg");
141
 
142
    // Set queues Q1 and Q2
143
    scb_cfg.set_queues({"Q1", "Q2"});
144
 
145
    // Set the maximum queue size for Q1 to 100 elements
146
    scb_cfg.set_max_queue_size("Q1", 100);
147
 
148
    // Set the primary queue
149
    if(!scb_cfg.set_primary_queue("Q1")) begin
150
      `uvm_fatal("CFG_ERROR", "scb_cfg.set_primary_queue call failed!")
151
    end
152
 
153
    // Set producer "P1" for queues: "Q1" and "Q2"
154
    if(!scb_cfg.set_producer("P1", {"Q1", "Q2"}, cl_syoscb_subscriber#(cl_scbtest_seq_item)::get_type())) begin
155
      `uvm_fatal("CFG_ERROR", "scb_cfg.set_producer call failed!")
156
    end
157
 
158
    // Set producer "P2" for queues: "Q1" and "Q2"
159
    if(!scb_cfg.set_producer("P2", {"Q1", "Q2"}, cl_syoscb_subscriber#(cl_scbtest_seq_item)::get_type())) begin
160
      `uvm_fatal("CFG_ERROR", "scb_cfg.set_producer call failed!")
161
    end
162
 
163
    uvm_config_db #(cl_syoscb_cfg)::set(this, "scbtest_env", "scb_cfg", scb_cfg);
164
  end
165
endfunction: build_phase
166
 
167
function void cl_scbtest_test_ooo_tlm_ap::connect_phase(uvm_phase phase);
168
  super.connect_phase(phase);
169
 
170
  // *NOTE*: This will hook up the TLM monitors with the TLM API of the
171
  //         scoreboard. Normally, this would not be done here but in the
172
  //         testbench environment which would have access to all of the
173
  //         montors and the scoreboard. However, these monitors only
174
  //         exists for this specific test. Thus, it is done here locally.
175
  begin
176
//    cl_syoscb_subscriber subscriber;
177
    cl_syoscb_subscriber#(cl_scbtest_seq_item) subscriber;
178
 
179
    // Get the subscriber for Producer: P1 for queue: Q1 and connect it
180
    // to the UVM monitor producing transactions for this queue
181
//    subscriber = this.scbtest_env.syoscb.get_subscriber("Q1", "P1");
182
 
183
    begin
184
      uvm_component tmp = this.scbtest_env.scb.get_subscriber("Q1", "P1");
185
//      uvm_object_wrapper tmp2 = tmp.get_type();
186
      uvm_object_wrapper tmp3 = tmp.get_object_type();
187
 
188
      $display("JACOB: %s, %s, %s\n%s", tmp.get_full_name(), tmp.get_type_name(), tmp3.get_type_name(), tmp.sprint());
189
    end
190
 
191
    begin
192
      cl_syoscb_subscriber#(uvm_sequence_item) subscriber2;
193
 
194
      if(!$cast(subscriber2, this.scbtest_env.scb.get_subscriber("Q1", "P1"))) begin
195
        `uvm_fatal("Bla2", "Unable to cast");
196
      end
197
    end
198
 
199
    if(!$cast(subscriber, this.scbtest_env.scb.get_subscriber("Q1", "P1"))) begin
200
      `uvm_fatal("Bla", "Unable to cast");
201
    end
202
    this.monQ1P1.anls_port.connect(subscriber.analysis_export);
203
 
204
    // Get the subscriber for Producer: P1 for queue: Q2 and connect it
205
    // to the UVM monitor producing transactions for this queue
206
//    subscriber = this.scbtest_env.scb.get_subscriber("Q2", "P1");
207
    if(!$cast(subscriber, this.scbtest_env.scb.get_subscriber("Q2", "P1"))) begin
208
      `uvm_fatal("Bla", "Unable to cast");
209
    end
210
    this.monQ2P1.anls_port.connect(subscriber.analysis_export);
211
  end
212
endfunction: connect_phase
213
 
214
task cl_scbtest_test_ooo_tlm_ap::run_phase(uvm_phase phase);
215
  // Raise objection
216
  phase.raise_objection(this);
217
 
218
  super.run_phase(phase);
219
 
220
  // *NOTE*: This test is intentionally empty since
221
  //         All of the stimulti is coming from the TLM monitors
222
 
223
  // Drop objection
224
  phase.drop_objection(this);
225
endtask: run_phase

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.