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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [tags/] [START/] [bench/] [databuffer_l2/] [databuffer_l2_tb.h] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 acastong
//databuffer_l2_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 DATABUFFER_L2_TB_H
40
#define DATABUFFER_L2_TB_H
41
 
42
#include "../../rtl/systemc/core_synth/synth_datatypes.h"
43
#include "../../rtl/systemc/core_synth/constants.h"
44
 
45
///Testbench for the the databuffer_l2 module
46
/**
47
        @class databuffer_l2_tb
48
        @author Ami Castonguay
49
        @description Testbench for the databuffer.  The testbench is seperated in
50
                several processes :
51
                 - Generating random data buffer packets
52
                 - Randomly read entries from the read ports
53
                 - Generate nop received signals and verify validity of nop requests
54
                 - simulate the memories that the databuffer uses
55
*/
56
class databuffer_l2_tb : public sc_module {
57
 
58
public:
59
 
60
        /// Global system cold reset signal.
61
        sc_out< bool >                                                          resetx;
62
        /// LDTSTOP (power saving mode)
63
        sc_out< bool >                                                          ldtstopx;
64
        /// Global system clock signal.
65
        sc_in_clk                                                                       clk;
66
 
67
        /// Command Decoder data.
68
    sc_out< sc_bv<32> >                                                         cd_data_db;
69
        /// Command Decoder data length in dword, minus 1.
70
        sc_out< sc_uint<4> >                                            cd_datalen_db;
71
        /// Command Decoder virtual channel of the data
72
        sc_out< VirtualChannel >                                                cd_vctype_db;
73
        /// Command Decoder write request flag
74
        sc_out< bool >                                                          cd_write_db;
75
        /// Command Decoder flag for getting the address of the data
76
        sc_out< bool >                                                          cd_getaddr_db;
77
 
78
#ifdef RETRY_MODE_ENABLED
79
        /// Command Decoder flag for erasing data
80
        sc_out< bool >                                                          cd_drop_db;
81
        ///Link initiates retry disconnect (must reset buffer count)
82
        sc_out< bool >                                                          lk_initiate_retry_disconnect;
83
        ///Command decoder initiates retry disconnect (must reset buffer count)
84
        sc_out< bool >                                                          cd_initiate_retry_disconnect;
85
        ///If the retry mode is activated
86
        sc_out< bool >                                                          csr_retry;
87
#endif
88
        /// Command Decoder return address of the sent data
89
        sc_in< sc_uint<BUFFERS_ADDRESS_WIDTH> > db_address_cd;
90
 
91
        /// Error Handler address of the data to drop
92
        sc_out< sc_uint<BUFFERS_ADDRESS_WIDTH> >                eh_address_db;
93
        /// Error Handler virtual channel of the data to drop
94
        sc_out< VirtualChannel >                                                eh_vctype_db;
95
        /// Error Handler flag for erasing data
96
        sc_out< bool >                                                          eh_erase_db;
97
 
98
        /// CSR address of data to read
99
        sc_out< sc_uint<BUFFERS_ADDRESS_WIDTH> >                csr_address_db;
100
        /// CSR flag to read data
101
        sc_out< bool >                                                          csr_read_db;
102
        /// CSR virtual channel of data to read
103
        sc_out< VirtualChannel >                                        csr_vctype_db;
104
 
105
        /// User Interface address of data to read
106
        sc_out< sc_uint<BUFFERS_ADDRESS_WIDTH> >                ui_address_db;
107
        /// User Interface flag to read data
108
        sc_out< bool >                                                          ui_read_db;
109
        /// User Interface virtual channel of data to read
110
        sc_out< VirtualChannel >                                                ui_vctype_db;
111
 
112
        /// Data for the accepted destination (shared CSR and UI output)
113
        /** The output is selected by the ui_grant_csr_access_db signal*/
114
        sc_in< sc_bv<32> >                                                      db_data_accepted;
115
        ///CSR has done reading the packet and it can be erased
116
        sc_out< bool >                                                          csr_erase_db;
117
        ///UI has done reading the packet and it can be erased
118
        sc_out< bool >                                                          ui_erase_db;
119
 
120
 
121
        /// Forward address of data to read
122
        sc_out< sc_uint<BUFFERS_ADDRESS_WIDTH> >                fwd_address_db;
123
        /// Forward flag to read data
124
        sc_out< bool >                                                          fwd_read_db;
125
        /// Forward virtual channel of data to read
126
        sc_out< VirtualChannel >                                                fwd_vctype_db;
127
        /// Forward return data 
128
        sc_in< sc_bv<32> >                                                      db_data_fwd;
129
        /// Forward return flag meaning the last data forming the packet
130
        sc_out< bool >                                                          fwd_erase_db;
131
 
132
        /// Flow Control flag meaning a NOP packet was sent
133
        sc_out< bool >                                                          fc_nop_sent;
134
        /// Flow Control return free buffers counters since last NOP request
135
        /** [5,4]: nonposted; [3,2]: posted; [1,0]: response.*/
136
        sc_in< sc_bv<6> >                                                       db_buffer_cnt_fc;
137
        /// Flow Control return flag for a request of a NOP packet.
138
        sc_in< bool >                                                           db_nop_req_fc;
139
        ///Activated when we receive more data than we can store
140
        sc_in< bool >                                                           db_overflow_csr;
141
 
142
        ///UI grants databuffer access to CSR (accepted port is shared)
143
        /**By default, the accepted port is for the UI.  When the UI grants the right
144
           of access to the CSR, it becomes the CSR's right.  The grant signal is read
145
          to know what data to output.*/
146
        sc_out<bool> ui_grant_csr_access_db;
147
 
148
        ///When an error is detected in the testbench
149
        sc_out<bool> error;
150
 
151
        ////////////////////////////////////
152
        //Interface to memory - synchronous
153
        ////////////////////////////////////
154
 
155
        ///Interface to databuffer memories.  See databuffer_l2 documentation for more details
156
        //@{
157
        sc_in<bool> memory_write;
158
        sc_in<sc_uint<2> > memory_write_address_vc;
159
        sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> > memory_write_address_buffer;
160
        sc_in<sc_uint<4> > memory_write_address_pos;
161
        sc_in<sc_bv<32> > memory_write_data;
162
 
163
        sc_in<sc_uint<2> > memory_read_address_vc[2];
164
        sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> >memory_read_address_buffer[2];
165
        sc_in<sc_uint<4> > memory_read_address_pos[2];
166
 
167
        sc_out<sc_bv<32> > memory_output[2];
168
        //@}
169
 
170
        ///SystemC Macro
171
        SC_HAS_PROCESS(databuffer_l2_tb);
172
 
173
        ///This is the memory used by the databuffer
174
        int memory[3][DATABUFFER_NB_BUFFERS][16];
175
 
176
        ///Actual data entries to keep track of what is stored in the databuffers
177
        int data_packets[3][DATABUFFER_NB_BUFFERS][16];
178
        ///  A size of 0 means no data in the buffer
179
        int data_packets_size[3][DATABUFFER_NB_BUFFERS];
180
        ///The count of packets in the three virtual channels
181
        int data_packets_count[3];
182
        ///The number of packets that can be sent to the databuffer for every VirtualChannel
183
        /**Changes by nops sent, packet sent and received, reset and disconenct sequences*/
184
        int data_packets_allowed[3];
185
        ///If the testbench is allowed to overflow the databuffer
186
        bool allow_overflow;
187
 
188
        ///Constructor
189
        databuffer_l2_tb(sc_module_name name);
190
 
191
        ///Process to read the data available at the databuffer output
192
        /**
193
                Test reading the ports of the databuffer.  Check that the data matches
194
                what was sent in the databuffer.  There are four read ports tested, the
195
                port for the FWD, CSR and UI to read data.  The CSR and UI ports are shared,
196
                meaning that only one can read at the time.  The last port is a "drop" port for
197
                the error handler, to simply erase a complete packet when it's not needed.
198
        */
199
        void read_data();
200
 
201
        ///Process to generate data packets for the databuffer
202
        /**
203
                Send data to the databuffer.  Generate data packets, random data and
204
                sometime drop the data.  The data being pushed in is stored in
205
                the variable data_packets so it can be checked at the outout.
206
        */
207
        void store_data();
208
        ///Process that simulates the memories used by the databuffer
209
        void manage_memories();
210
        ///Process that
211
        void manage_nops();
212
        ///Drives reset at the beggining of the simulation
213
        void manage_reset();
214
        ///Convert VC signals to traceable signals
215
        /** Signals like cd_vctype_db are not traceable by default because they use the
216
                VirtualChannel enum type.  This process converts thos enums to ints so they
217
                can be traced.
218
        */
219
        void convert_vcs();
220
 
221
        /** Traceable signals created by ::convert_vcs() */
222
        ///@{
223
        sc_signal<sc_uint<2> > cd_vctype_db_trace;
224
        sc_signal<sc_uint<2> > eh_vctype_db_trace;
225
        sc_signal<sc_uint<2> > csr_vctype_db_trace;
226
        sc_signal<sc_uint<2> > ui_vctype_db_trace;
227
        sc_signal<sc_uint<2> > fwd_vctype_db_trace;
228
        ///@}
229
};
230
 
231
#endif

powered by: WebSVN 2.1.0

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