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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [sim/] [tests/] [legacy/] [tb_axis_gear_box/] [tests_pkg.sv] - Blame information for rev 50

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 50 qaztronic
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
//// Copyright (C) 2017 Authors and OPENCORES.ORG                 ////
4
////                                                              ////
5
//// This source file may be used and distributed without         ////
6
//// restriction provided that this copyright statement is not    ////
7
//// removed from the file and that any derivative work contains  ////
8
//// the original copyright notice and the associated disclaimer. ////
9
////                                                              ////
10
//// This source file is free software; you can redistribute it   ////
11
//// and/or modify it under the terms of the GNU Lesser General   ////
12
//// Public License as published by the Free Software Foundation; ////
13
//// either version 2.1 of the License, or (at your option) any   ////
14
//// later version.                                               ////
15
////                                                              ////
16
//// This source is distributed in the hope that it will be       ////
17
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
18
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
19
//// PURPOSE.  See the GNU Lesser General Public License for more ////
20
//// details.                                                     ////
21
////                                                              ////
22
//// You should have received a copy of the GNU Lesser General    ////
23
//// Public License along with this source; if not, download it   ////
24
//// from http://www.opencores.org/lgpl.shtml                     ////
25
////                                                              ////
26
//////////////////////////////////////////////////////////////////////
27
 
28
// --------------------------------------------------------------------
29
//
30
package tests_pkg;
31
 
32
  // --------------------------------------------------------------------
33
  //
34
  import uvm_pkg::*;
35
  `include "uvm_macros.svh"
36
  import axis_pkg::*;
37
  import tb_axis_gear_box_pkg::*;
38
  import tests_base_pkg::*;
39
 
40
  // --------------------------------------------------------------------
41
  //
42
  class t_counting extends test_base;
43
     `uvm_component_utils(t_counting)
44
 
45
    // --------------------------------------------------------------------
46
    //
47
    function new(string name = "my_test", uvm_component parent);
48
      super.new(name, parent);
49
    endfunction
50
 
51
    // --------------------------------------------------------------------
52
    //
53
    virtual function void end_of_elaboration_phase(uvm_phase phase);
54
      uvm_phase run_phase = uvm_run_phase::get();
55
      run_phase.phase_done.set_drain_time(this, 300ns);
56
    endfunction
57
 
58
    // --------------------------------------------------------------------
59
    //
60
    virtual task run_phase(uvm_phase phase);
61
      axis_counting_sequence #(dut_cfg.axis_cfg_in) seq_h;
62
      super.run_phase(phase);
63
      phase.raise_objection(this);
64
      fork
65
        repeat(3)
66
        begin
67
          seq_h = axis_counting_sequence #(dut_cfg.axis_cfg_in)::type_id::create("seq_h");
68
          seq_h.start(env_h.agent_h.sequencer);
69
        end
70
      join
71
      phase.drop_objection(this);
72
    endtask : run_phase
73
 
74
  // --------------------------------------------------------------------
75
  //
76
  endclass : t_counting
77
  // --------------------------------------------------------------------
78
  //
79
 
80
  // --------------------------------------------------------------------
81
  //
82
  class gear_box_sequence #(dut_config_t dut_cfg)
83
    extends uvm_sequence #(axis_sequence_item #(dut_cfg.axis_cfg_in));
84
    `uvm_object_param_utils(gear_box_sequence #(dut_cfg))
85
 
86
    rand int length = 7 * 3;
87
 
88
    // --------------------------------------------------------------------
89
    //
90
    typedef logic [15:0] packed_data_t[7];
91
 
92
    function packed_data_t next_data(int init);
93
      static logic [15:0] previous_value;
94
      logic [13:0] unpacked_data[8];
95
      logic [15:0] packed_data[7];
96
 
97
      if(init == 0)
98
        previous_value = 0;
99
 
100
      foreach(unpacked_data[i])
101
      begin
102
        unpacked_data[i] = previous_value;
103
        // $display("^^^ %16.t | unpacked_data[%0.d] = %h", $time, i, unpacked_data[i]);
104
        previous_value++;
105
      end
106
 
107
      packed_data = {<<16{{<<14{unpacked_data}}}};
108
 
109
      // $display("^^^ %16.t | %p", $time, packed_data);
110
 
111
      // foreach(packed_data[i])
112
        // $display("^^^ %16.t | packed_data[%0.d] = %h", $time, i, packed_data[i]);
113
 
114
      next_data = packed_data;
115
    endfunction
116
 
117
 
118
    // --------------------------------------------------------------------
119
    //
120
    virtual task body();
121
      localparam CHUNKS = 3;
122
      axis_sequence_item #(dut_cfg.axis_cfg_in) item;
123
      logic [15:0] data[7];
124
 
125
      item = axis_sequence_item #(dut_cfg.axis_cfg_in)::type_id::create("axis_sequence_item");
126
 
127
      for(int i = 0; i < CHUNKS; i++)
128
      begin
129
        data = next_data(i);
130
 
131
        foreach(data[k])
132
        begin
133
          start_item(item);
134
          item.tdata = data[k];
135
          item.tlast = (i == CHUNKS - 1) & (k == 0);
136
          item.tuser = 0;
137
          finish_item(item);
138
          // $display("^^^ %16.t | %d | %x", $time, (i * 7) + k, item.tdata);
139
        end
140
      end
141
 
142
    endtask
143
 
144
    // --------------------------------------------------------------------
145
    //
146
    function new(string name = "gear_box_sequence");
147
      super.new(name);
148
    endfunction
149
 
150
  // --------------------------------------------------------------------
151
  //
152
  endclass : gear_box_sequence
153
 
154
  // --------------------------------------------------------------------
155
  //
156
  class t_debug extends test_debug_base;
157
     `uvm_component_utils(t_debug)
158
 
159
    // --------------------------------------------------------------------
160
    //
161
    function new(string name = "t_debug", uvm_component parent);
162
      super.new(name, parent);
163
    endfunction
164
 
165
    // --------------------------------------------------------------------
166
    //
167
    function void end_of_elaboration_phase(uvm_phase phase);
168
      uvm_phase run_phase = uvm_run_phase::get();
169
      run_phase.phase_done.set_drain_time(this, 300ns);
170
    endfunction
171
 
172
    // --------------------------------------------------------------------
173
    //
174
    virtual task run_phase(uvm_phase phase);
175
      gear_box_sequence #(dut_cfg) seq_h;
176
      super.run_phase(phase);
177
      phase.raise_objection(this);
178
 
179
      fork
180
        repeat(3)
181
        begin
182
          seq_h = gear_box_sequence #(dut_cfg)::type_id::create("seq_h");
183
          seq_h.start(env_h.agent_h.sequencer);
184
        end
185
      join
186
 
187
      phase.drop_objection(this);
188
    endtask : run_phase
189
 
190
  // --------------------------------------------------------------------
191
  //
192
  endclass : t_debug
193
 
194
// --------------------------------------------------------------------
195
//
196
endpackage: tests_pkg

powered by: WebSVN 2.1.0

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