1 |
50 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2015 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 |
|
|
package tb_axi4_to_axis_agent_class_pkg;
|
30 |
|
|
|
31 |
|
|
// --------------------------------------------------------------------
|
32 |
|
|
//
|
33 |
|
|
import axi4_memory_pkg::*;
|
34 |
|
|
import axis_bfm_pkg::*;
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
// --------------------------------------------------------------------
|
38 |
|
|
//
|
39 |
|
|
class tb_axi4_to_axis_agent_class #(N, A, I, D, U);
|
40 |
|
|
|
41 |
|
|
axi4_memory_class #(A, N, I) m_h;
|
42 |
|
|
axis_rx_bfm_class #(N, I, D, U) s_h;
|
43 |
|
|
memory_tr_class #(A, N, I) m_tr_h, m_tr_clone_h;
|
44 |
|
|
axis_tr_class #(N, I, D, U) s_tr_h;
|
45 |
|
|
|
46 |
|
|
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
|
47 |
|
|
virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out;
|
48 |
|
|
|
49 |
|
|
mailbox #(memory_tr_class #(A, N, I)) q;
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
// --------------------------------------------------------------------
|
53 |
|
|
//
|
54 |
|
|
task wait_for_sof;
|
55 |
|
|
@(posedge axis_out.cb_s.tuser);
|
56 |
|
|
$display("^^^ %16.t | %m", $time);
|
57 |
|
|
endtask: wait_for_sof
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
// --------------------------------------------------------------------
|
61 |
|
|
//
|
62 |
|
|
task random_transaction(int addr, int size);
|
63 |
|
|
m_tr_h = new();
|
64 |
|
|
m_tr_h.random(addr, size);
|
65 |
|
|
m_tr_clone_h = m_tr_h.clone();
|
66 |
|
|
q.put(m_tr_clone_h);
|
67 |
|
|
m_h.load_words(addr, m_tr_h.data);
|
68 |
|
|
endtask: random_transaction
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
// --------------------------------------------------------------------
|
72 |
|
|
//
|
73 |
|
|
task automatic
|
74 |
|
|
compare;
|
75 |
|
|
|
76 |
|
|
$display("^^^ %16.t | %m", $time);
|
77 |
|
|
$display("^^^ %16.t | q.num = %d", $time, q.num);
|
78 |
|
|
$display("^^^ %16.t | s_h.q.num = %d", $time, s_h.q.num);
|
79 |
|
|
$display("^^^ %16.t | m_tr_h.data.size = %d", $time, m_tr_h.data.size);
|
80 |
|
|
|
81 |
|
|
q.get(m_tr_h);
|
82 |
|
|
|
83 |
|
|
for(int i = 0; i < m_tr_h.data.size; i += N)
|
84 |
|
|
begin
|
85 |
|
|
if(s_h.q.try_get(s_tr_h) == 0)
|
86 |
|
|
begin
|
87 |
|
|
$display("!!! %16.t | ERROR!!! try_get(s_tr_h) == 0", $time);
|
88 |
|
|
break;
|
89 |
|
|
end
|
90 |
|
|
|
91 |
|
|
for(int k = 0; k < N; k++)
|
92 |
|
|
begin
|
93 |
|
|
if(s_tr_h.tdata[k*8 +: 8] != m_tr_h.data[i + k])
|
94 |
|
|
begin
|
95 |
|
|
$display("!!! %16.t | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", $time);
|
96 |
|
|
$display("!!! %16.t | ERROR!!! mismatch | i = %d | k = %d", $time, i, k);
|
97 |
|
|
$display("!!! %16.t | %x | %x |", $time, s_tr_h.tdata[k*8 +: 8], m_tr_h.data[i + k]);
|
98 |
|
|
$stop;
|
99 |
|
|
end
|
100 |
|
|
end
|
101 |
|
|
end
|
102 |
|
|
|
103 |
|
|
$display("^^^ %16.t | %m | done!", $time);
|
104 |
|
|
|
105 |
|
|
endtask: compare
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
//--------------------------------------------------------------------
|
109 |
|
|
//
|
110 |
|
|
function new
|
111 |
|
|
(
|
112 |
|
|
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m,
|
113 |
|
|
virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out
|
114 |
|
|
);
|
115 |
|
|
|
116 |
|
|
this.axi4_m = axi4_m;
|
117 |
|
|
this.axis_out = axis_out;
|
118 |
|
|
m_h = new(axi4_m);
|
119 |
|
|
s_h = new(axis_out);
|
120 |
|
|
q = new();
|
121 |
|
|
endfunction: new
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
// --------------------------------------------------------------------
|
125 |
|
|
//
|
126 |
|
|
endclass: tb_axi4_to_axis_agent_class
|
127 |
|
|
|
128 |
|
|
// --------------------------------------------------------------------
|
129 |
|
|
//
|
130 |
|
|
endpackage: tb_axi4_to_axis_agent_class_pkg
|