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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [tags/] [START/] [bench/] [link_l2/] [link_frame_tx_l3_tb/] [link_frame_tx_l3_tb.cpp] - Blame information for rev 21

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//link_frame_tx_l3_tb.cpp
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is HyperTransport Tunnel IP Core.
16
 *
17
 * The Initial Developer of the Original Code is
18
 * Ecole Polytechnique de Montreal.
19
 * Portions created by the Initial Developer are Copyright (C) 2005
20
 * the Initial Developer. All Rights Reserved.
21
 *
22
 * Contributor(s):
23
 *   Ami Castonguay <acastong@grm.polymtl.ca>
24
 *
25
 * Alternatively, the contents of this file may be used under the terms
26
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
27
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
28
 * provisions of PHTICSCL License are applicable instead of those
29
 * above. If you wish to allow use of your version of this file only
30
 * under the terms of the PHTICSCL License and not to allow others to use
31
 * your version of this file under the MPL, indicate your decision by
32
 * deleting the provisions above and replace them with the notice and
33
 * other provisions required by the PHTICSCL License. If you do not delete
34
 * the provisions above, a recipient may use your version of this file
35
 * under either the MPL or the PHTICSCL License."
36
 *
37
 * ***** END LICENSE BLOCK ***** */
38
 
39
#include <cstdlib>
40
 
41
#include "link_frame_tx_l3_tb.h"
42
#include "../../core/require.h"
43
 
44
using namespace std;
45
 
46
link_frame_tx_l3_tb::link_frame_tx_l3_tb(sc_module_name name): sc_module(name){
47
        SC_THREAD(stimulate_inputs);
48
        sensitive_pos   <<      clk;
49
 
50
        validator = new link_tx_validator("link_tx_validator");
51
 
52
        validator->clk(clk);
53
 
54
        validator->lk_ctl_phy(lk_ctl_phy);
55
        for(int n = 0; n < CAD_OUT_WIDTH; n++){
56
                validator->lk_cad_phy[n](lk_cad_phy[n]);
57
        }
58
 
59
        validator->tx_consume_data(tx_consume_data);
60
 
61
        validator->phy_consume_lk(phy_consume_lk);
62
        validator->cad_to_frame(cad_to_frame);
63
        validator->lctl_to_frame(lctl_to_frame);
64
        validator->hctl_to_frame(hctl_to_frame);
65
}
66
 
67
void link_frame_tx_l3_tb::init(){
68
        cout << "TB Init" << endl;
69
 
70
        csr_tx_link_width_lk = "000";
71
        validator->bit_width = 8;
72
        if(validator->bit_width > CAD_OUT_WIDTH) validator->bit_width = CAD_OUT_WIDTH;
73
 
74
        csr_end_of_chain = false;
75
 
76
        ///Link commands a ltdstop disconnect
77
        ldtstop_disconnect_tx = false;
78
        rx_waiting_for_ctl_tx = false;
79
 
80
 
81
        resetx = false;
82
        pwrok = false;
83
        ldtstopx = false;
84
 
85
 
86
#ifdef RETRY_MODE_ENABLED
87
        ///The flow control asks us to disconnect the link
88
        fc_disconnect_lk = false;
89
#endif
90
 
91
        validator->expect_tx_consume_data = 0;
92
        srand(389);
93
}
94
 
95
void link_frame_tx_l3_tb::stimulate_inputs(){
96
        cout << "TB Stimulate inputs" << endl;
97
        init();
98
 
99
        for(int n = 0; n < 5; n++) wait();
100
 
101
        //Enable power
102
        pwrok = true;
103
        ldtstopx = true;
104
 
105
        for(int n = 0; n < 5; n++) wait();
106
 
107
        //End reset
108
        resetx = true;
109
 
110
        cout << "Test connection 8 BIT" << endl;
111
        cout << "TB: Wait for connection" << endl;
112
 
113
        int max_count = 4300/CAD_OUT_DEPTH;
114
 
115
        //Give a first dword before being connected so that it's ready when
116
        //the link gets connected
117
        link_tx_validator::LinkTransmission_TX t;
118
        t.dword = "0x9812ABF4";
119
        t.lctl = true;
120
        t.hctl = true;
121
        validator->expected_transmission.push(t);
122
        validator->to_transmit.push(t);
123
 
124
        //Wait until the validator says that we are in the normal RUN mode(init is done)
125
        while(validator->state != link_tx_validator::LinkTBState_RUN){
126
                max_count--;
127
                if(max_count == 0)
128
                        cout << "*** ERROR: Link didn't initialize" << endl;
129
                wait();
130
        }
131
        cout << "TB: Connection established" << endl;
132
 
133
 
134
        t.dword = "0x94FF32D2";
135
        t.lctl = true;
136
        t.hctl = false;
137
        validator->expected_transmission.push(t);
138
        validator->to_transmit.push(t);
139
 
140
        t.dword = "0x9DE3AC01";
141
        t.lctl = false;
142
        t.hctl = true;
143
        validator->expected_transmission.push(t);
144
        validator->to_transmit.push(t);
145
 
146
        validator->expect_tx_consume_data = 50;
147
 
148
        //We are testing for an 8 bit link width, so if link is initialized
149
        //with full width, it should take 3 cycles to send 3 dwords.  If
150
        //the link is 4 bits, it will take 6 cycles, and if 2 it will take
151
        //12 cycles.  The formula is simple : 24/width.  If the link is
152
        //smaller than 8 bits, there will be an additional delay for the first
153
        //packet to be output, hence the added 8/width - 1 cycles.
154
        for(int n = 32 / validator->bit_width - 1; n > 0; n--){
155
                wait();
156
        }
157
 
158
        validator->expect_tx_consume_data = -20;
159
        resetx = false;
160
        validator->state = link_tx_validator::LinkTBState_INACTIVE;
161
 
162
        for(int n = 0; n < 5; n++) wait();
163
 
164
        csr_tx_link_width_lk = "101";
165
        validator->bit_width = 4;
166
        //End reset
167
        resetx = true;
168
 
169
        cout << "Test connection 4 BIT" << endl;
170
        cout << "TB: Wait for connection" << endl;
171
 
172
        max_count = 4300/CAD_OUT_DEPTH;
173
 
174
        t.dword = "0x9812ABF4";
175
        t.lctl = true;
176
        t.hctl = true;
177
        validator->expected_transmission.push(t);
178
        validator->to_transmit.push(t);
179
 
180
        while(validator->state != link_tx_validator::LinkTBState_RUN){
181
                max_count--;
182
                if(max_count == 0)
183
                        cout << "*** ERROR: Link didn't initialize" << endl;
184
                wait();
185
        }
186
        cout << "TB: Connection established" << endl;
187
 
188
 
189
        t.dword = "0x94FF32D2";
190
        t.lctl = true;
191
        t.hctl = false;
192
        validator->expected_transmission.push(t);
193
        validator->to_transmit.push(t);
194
 
195
        t.dword = "0x9DE3AC01";
196
        t.lctl = false;
197
        t.hctl = true;
198
        validator->expected_transmission.push(t);
199
        validator->to_transmit.push(t);
200
 
201
        validator->expect_tx_consume_data = 50;
202
 
203
        //Same as before
204
        for(int n = 32 / validator->bit_width - 1; n > 0; n--){
205
                wait();
206
        }
207
 
208
        validator->expect_tx_consume_data = -20;
209
        resetx = false;
210
        validator->state = link_tx_validator::LinkTBState_INACTIVE;
211
 
212
        for(int n = 0; n < 5; n++) wait();
213
 
214
        csr_tx_link_width_lk = "100";
215
        validator->bit_width = 2;
216
        //End reset
217
        resetx = true;
218
 
219
        cout << "Test connection 2 BIT" << endl;
220
        cout << "TB: Wait for connection" << endl;
221
 
222
        max_count = 4300/CAD_OUT_DEPTH;
223
 
224
        t.dword = "0x9812ABF4";
225
        t.lctl = true;
226
        t.hctl = true;
227
        validator->expected_transmission.push(t);
228
        validator->to_transmit.push(t);
229
 
230
        while(validator->state != link_tx_validator::LinkTBState_RUN){
231
                max_count--;
232
                if(max_count == 0)
233
                        cout << "*** ERROR: Link didn't initialize" << endl;
234
                wait();
235
        }
236
        cout << "TB: Connection established" << endl;
237
 
238
 
239
        t.dword = "0x94FF32D2";
240
        t.lctl = true;
241
        t.hctl = false;
242
        validator->expected_transmission.push(t);
243
        validator->to_transmit.push(t);
244
 
245
        t.dword = "0x9DE3AC01";
246
        t.lctl = false;
247
        t.hctl = true;
248
        validator->expected_transmission.push(t);
249
        validator->to_transmit.push(t);
250
 
251
        validator->expect_tx_consume_data = 50;
252
 
253
        //Same as before
254
        for(int n = 32 / validator->bit_width - 1; n > 0; n--){
255
                wait();
256
        }
257
 
258
        validator->expect_tx_consume_data = -20;
259
        resetx = false;
260
        validator->state = link_tx_validator::LinkTBState_INACTIVE;
261
 
262
        while(true) wait();
263
 
264
}
265
 
266
 

powered by: WebSVN 2.1.0

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