1 |
2 |
acastong |
//link_frame_rx_l3_tb.h
|
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 |
|
|
#ifndef LINK_FRAME_RX_L3_TB_H
|
40 |
|
|
#define LINK_FRAME_RX_L3_TB_H
|
41 |
|
|
|
42 |
|
|
#include "../../../rtl/systemc/core_synth/synth_datatypes.h"
|
43 |
|
|
#include "../../../rtl/systemc/core_synth/constants.h"
|
44 |
|
|
#include <queue>
|
45 |
|
|
|
46 |
|
|
///struct regrouping dword and CTL values to send on link
|
47 |
|
|
struct LinkTransmission{
|
48 |
|
|
sc_bv<32> dword;
|
49 |
|
|
bool lctl;
|
50 |
|
|
bool hctl;
|
51 |
|
|
};
|
52 |
|
|
|
53 |
|
|
//Forward declaration
|
54 |
|
|
class link_rx_transmitter;
|
55 |
|
|
|
56 |
|
|
///Testbench for the link_frame_rx_l3 module
|
57 |
|
|
/**
|
58 |
|
|
@class link_frame_rx_l3_tb
|
59 |
|
|
@author Ami Castonguay
|
60 |
|
|
@description
|
61 |
|
|
Using the link_rx_transmitter to send traffic, this
|
62 |
|
|
testbench setups different sequences to test the
|
63 |
|
|
reception and initialization of the RX part of the
|
64 |
|
|
link
|
65 |
|
|
|
66 |
|
|
There are multiple signals coming from the link
|
67 |
|
|
that must be verified. To verify them, member variables
|
68 |
|
|
named expect_* are used. These expect variables are
|
69 |
|
|
ints. When the variable is supposed to be false, it is
|
70 |
|
|
0. When it should be 1, it has the value of 1. When the
|
71 |
|
|
variable is 0 and is expected to become 1 within n cycles, it has
|
72 |
|
|
the value n. When it is 1 and is expected to become
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
*/
|
76 |
|
|
class link_frame_rx_l3_tb : public sc_module{
|
77 |
|
|
|
78 |
|
|
public:
|
79 |
|
|
|
80 |
|
|
///Main clock of the system
|
81 |
|
|
sc_in<bool > clk;
|
82 |
|
|
|
83 |
|
|
///CTL value sent to the HT tunnel
|
84 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy_ctl_lk;
|
85 |
|
|
/** Every element of the array represent one input of the tunnel
|
86 |
|
|
that was deserialized to a factor of CAD_IN_DEPTH*/
|
87 |
|
|
sc_out<sc_bv<CAD_IN_DEPTH> > phy_cad_lk[CAD_IN_WIDTH];
|
88 |
|
|
///If CAD and CTL values are available to be consumed
|
89 |
|
|
/** True when a dword is sent through the transmitter, false
|
90 |
|
|
otherwise*/
|
91 |
|
|
sc_out<bool> phy_available_lk;
|
92 |
|
|
///Allows to disable receivers to save power and prevent problems when driver is tristate
|
93 |
|
|
sc_in<bool> lk_disable_receivers_phy;
|
94 |
|
|
|
95 |
|
|
///The framed cad bits produced by the link_frame_rx_l3
|
96 |
|
|
sc_in<sc_bv<32> > framed_cad;
|
97 |
|
|
///The framed lctl produced by the link_frame_rx_l3
|
98 |
|
|
sc_in<bool> framed_lctl;
|
99 |
|
|
///The framed hctl produced by the link_frame_rx_l3
|
100 |
|
|
sc_in<bool > framed_hctl;
|
101 |
|
|
///If there is framed data available
|
102 |
|
|
sc_in<bool> framed_data_available;
|
103 |
|
|
///If the RX part of the link is connected
|
104 |
|
|
sc_in<bool> lk_rx_connected;
|
105 |
|
|
|
106 |
|
|
///Reset signal
|
107 |
|
|
sc_out<bool> resetx;
|
108 |
|
|
///PowerOK signal (cold reset and to sample the link)
|
109 |
|
|
sc_out<bool> pwrok;
|
110 |
|
|
///If in a LDTSTOP sequence (power saving mode)
|
111 |
|
|
sc_out<bool> ldtstopx;
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
|
|
Link widths
|
115 |
|
|
|
116 |
|
|
000 8 bits
|
117 |
|
|
100 2 bits
|
118 |
|
|
101 4 bits
|
119 |
|
|
111 Link physically not connected
|
120 |
|
|
*/
|
121 |
|
|
sc_out<sc_bv<3> > csr_rx_link_width_lk;
|
122 |
|
|
|
123 |
|
|
///If we are the last element of the chain (input should be ignored)
|
124 |
|
|
sc_out<bool > csr_end_of_chain;
|
125 |
|
|
///If we are in a sync flood (input should be ignored)
|
126 |
|
|
sc_out<bool > csr_sync;
|
127 |
|
|
///If the timout period before generating a CTL low error is extended
|
128 |
|
|
sc_out<bool > csr_extended_ctl_timeout_lk;
|
129 |
|
|
|
130 |
|
|
///To update the link width registered in the CSR with the new value
|
131 |
|
|
sc_in<bool> lk_update_link_width_csr;
|
132 |
|
|
///The link width that is being sampled
|
133 |
|
|
sc_in<sc_bv<3> > lk_sampled_link_width_csr;
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
///Update the link failure flag in CSR with the lk_link_failure_csr signal
|
137 |
|
|
sc_in<bool> lk_update_link_failure_property_csr;
|
138 |
|
|
///This signal should only be evaluated at lk_update_link_failure_property_csr
|
139 |
|
|
sc_in<bool> lk_link_failure_csr;
|
140 |
|
|
|
141 |
|
|
///Link commands a ltdstop disconnect
|
142 |
|
|
sc_out<bool> ldtstop_disconnect_rx;
|
143 |
|
|
|
144 |
|
|
#ifdef RETRY_MODE_ENABLED
|
145 |
|
|
///If we are in retry mode
|
146 |
|
|
sc_out<bool> csr_retry;
|
147 |
|
|
///Start a retry sequence
|
148 |
|
|
sc_in<bool> lk_initiate_retry_disconnect;
|
149 |
|
|
///Command decoder commands a retry disconnect
|
150 |
|
|
sc_out<bool> cd_initiate_retry_disconnect;
|
151 |
|
|
#endif
|
152 |
|
|
|
153 |
|
|
///If a transition error in the CTL input was detected
|
154 |
|
|
sc_in<bool> ctl_transition_error;
|
155 |
|
|
///Active when the RX part is waiting for the CTL to become asserted
|
156 |
|
|
sc_in<bool> rx_waiting_for_ctl_tx;
|
157 |
|
|
|
158 |
|
|
#ifndef INTERNAL_SHIFTER_ALIGNMENT
|
159 |
|
|
///High speed deserializer should stall shifting bits for lk_deser_stall_cycles_phy cycles
|
160 |
|
|
/** Cannot be asserted with a lk_deser_stall_cycles_phy value of 0*/
|
161 |
|
|
sc_in<bool > lk_deser_stall_phy;
|
162 |
|
|
///Number of bit times to stall deserializing incoming data when lk_deser_stall_phy is asserted
|
163 |
|
|
sc_in<sc_uint<LOG2_CAD_IN_DEPTH> > lk_deser_stall_cycles_phy;
|
164 |
|
|
#endif
|
165 |
|
|
|
166 |
|
|
///The transmitter module that formats the traffic
|
167 |
|
|
link_rx_transmitter * transmitter;
|
168 |
|
|
///Framed transmissions that we are expected to receive
|
169 |
|
|
std::queue< LinkTransmission > expected_transmission;
|
170 |
|
|
|
171 |
|
|
///Expected behavior of lk_rx_connected
|
172 |
|
|
int expect_connected;
|
173 |
|
|
///Expected behavior of lk_disable_receivers_phy
|
174 |
|
|
int expect_disable_receivers_phy;
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
///Expected behavior of lk_update_link_width_csr
|
178 |
|
|
int expect_link_width_update;
|
179 |
|
|
///Expected value of lk_sampled_link_width_csr when update becomes true
|
180 |
|
|
sc_bv<3> expected_link_width;
|
181 |
|
|
|
182 |
|
|
///Expected behavior of lk_link_failure_csr
|
183 |
|
|
int expect_link_failure;
|
184 |
|
|
///Expected behavior of ctl_transition_error
|
185 |
|
|
int expect_ctl_transition_error;
|
186 |
|
|
///Expected behavior of lk_initiate_retry_disconnect
|
187 |
|
|
int expect_lk_initiate_retry_disconnect;
|
188 |
|
|
|
189 |
|
|
///If the value of the received framed data is verified from expected list
|
190 |
|
|
bool check_dword_reception;
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
///SystemC Macro
|
194 |
|
|
SC_HAS_PROCESS(link_frame_rx_l3_tb);
|
195 |
|
|
|
196 |
|
|
///Constructor
|
197 |
|
|
link_frame_rx_l3_tb(sc_module_name name);
|
198 |
|
|
|
199 |
|
|
///Generates traffic to test the design
|
200 |
|
|
void stimulate_inputs();
|
201 |
|
|
|
202 |
|
|
///Checks that the output are valid in function of the inputs sent
|
203 |
|
|
void validate_outputs();
|
204 |
|
|
|
205 |
|
|
///Resets the internal state of the TB to start a new test
|
206 |
|
|
void init();
|
207 |
|
|
|
208 |
|
|
///Desctructor
|
209 |
|
|
~link_frame_rx_l3_tb();
|
210 |
|
|
|
211 |
|
|
};
|
212 |
|
|
|
213 |
|
|
#endif
|