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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [bench/] [vc_ht_tunnel_l1_tb/] [InterfaceLayer.h] - Blame information for rev 21

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

Line No. Rev Author Line
1 2 acastong
//InterfaceLayer.h
2
 
3
/* ***** BEGIN LICENSE BLOCK *****
4
 * Version: MPL 1.1
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version
7
 * 1.1 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at
9
 * http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the
14
 * License.
15
 *
16
 * The Original Code is HyperTransport Tunnel IP Core.
17
 *
18
 * The Initial Developer of the Original Code is
19
 * Ecole Polytechnique de Montreal.
20
 * Portions created by the Initial Developer are Copyright (C) 2005
21
 * the Initial Developer. All Rights Reserved.
22
 *
23
 * Contributor(s):
24
 *   Ami Castonguay <acastong@grm.polymtl.ca>
25
 *
26
 * Alternatively, the contents of this file may be used under the terms
27
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
28
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
29
 * provisions of PHTICSCL License are applicable instead of those
30
 * above. If you wish to allow use of your version of this file only
31
 * under the terms of the PHTICSCL License and not to allow others to use
32
 * your version of this file under the MPL, indicate your decision by
33
 * deleting the provisions above and replace them with the notice and
34
 * other provisions required by the PHTICSCL License. If you do not delete
35
 * the provisions above, a recipient may use your version of this file
36
 * under either the MPL or the PHTICSCL License."
37
 *
38
 * ***** END LICENSE BLOCK ***** */
39
 
40
#ifndef InterfaceLayer_H
41
#define InterfaceLayer_H
42
 
43
#include "systemc.h"
44
#include <deque>
45
 
46
///forward declaration
47
class InterfaceLayer;
48
 
49
///Event handler class for received packet from the InterfaceLayer
50
class InterfaceLayerEventHandler{
51
public:
52
        ///Called when the InterfaceLayer receives a packet
53
        /**
54
                @param packet The received packet
55
                @param data The data associated with the packet.  If it does not contain data, it is
56
                        null.  Every int represents a dword of data
57
                @param directRoute If the packet was directRoute traffic
58
                @param side from which came the packet
59
                @param origin The InterfaceLayer that fired the event
60
        */
61
        virtual void receivedInterfacePacketEvent(const ControlPacket * packet,const int * data,
62
                bool directRoute,bool side,InterfaceLayer* origin)=0;
63
};
64
 
65
///Software interface to communication to HT hardware user interface
66
/**
67
        @class InterfaceLayer
68
        @author Ami Castonguay
69
        @description A software interface to send and received packets to a HT tunnel
70
                in hardware.  It breaks down packets queued to be sent into dwords that
71
                are sent to the tunnel.  Received dwords are reconstructed in packets.
72
*/
73
class InterfaceLayer : public sc_module {
74
 
75
        ///The packet, it's data and the side it came from 
76
        struct PacketAndData{
77
                ///Control packet
78
                ControlPacket * packet;
79
                ///Data associated with that control packet (NULL if none)
80
                int * data;
81
                ///Side the packet arrived from
82
                bool side;
83
        };
84
 
85
        ///State for packet transmission
86
        enum TransmitState{
87
                TX_SEND_DATA,
88
                TX_IDLE
89
        };
90
 
91
        ///State for packet reception
92
        enum ReceiveState{
93
                RX_RECEIVE_DATA,
94
                RX_IDLE
95
        };
96
 
97
public:
98
 
99
        ///Main clock of the system
100
        sc_in<bool>             clk;
101
        ///Main reset of the system (negative logic)
102
        sc_in<bool>             resetx;
103
 
104
        //******************************************
105
        //                      Signals to User
106
        //******************************************
107
        //------------------------------------------
108
        // Signals to send received packets to User
109
        //------------------------------------------
110
 
111
 
112
        /**The actual control/data packet to the user*/
113
        sc_in<sc_bv<64> >               ui_packet_usr;
114
 
115
        /**The virtual channel of the ctl/data packet*/
116
        sc_in<VirtualChannel>   ui_vc_usr;
117
 
118
        /**The side from which came the packet*/
119
        sc_in< bool >                   ui_side_usr;
120
 
121
        /**If the packet is a direct_route packet - only valid for
122
           requests (posted and non-posted) */
123
        sc_in<bool>                     ui_directroute_usr;
124
 
125
        /**If this is the last part of the packet*/
126
        sc_in< bool >                   ui_eop_usr;
127
 
128
        /**If there is another packet available*/
129
        sc_in< bool >                   ui_available_usr;
130
 
131
        /**If what is read is 64 bits or 32 bits*/
132
        sc_in< bool >                   ui_output_64bits_usr;
133
 
134
        /**To allow the user to consume the packets*/
135
        sc_out< bool >                  usr_consume_ui;
136
 
137
 
138
        //------------------------------------------
139
        // Signals to allow the User to send packets
140
        //------------------------------------------
141
 
142
        /**The actual control/data packet from the user*/
143
        sc_out<sc_bv<64> >              usr_packet_ui;
144
 
145
        /**If there is another packet available*/
146
        sc_out< bool >                  usr_available_ui;
147
 
148
        /**
149
        The side to send the packet if it is a response
150
        This bit is ignored if the packet is not a response
151
        since the side to send a request is determined automatically
152
        taking in acount DirectRoute functionnality.
153
        */
154
        sc_out< bool >                  usr_side_ui;
155
 
156
        /*
157
                Which what type of ctl packets can be sent
158
                bits.  Thos signals have the same value as
159
                the outputs, but they are here so that
160
                these signals can be used internally.
161
 
162
                5 POSTED,               no data
163
                4 POSTED,               data
164
                3 NON_POSTED,   no data
165
                2 NON_POSTED,   data
166
                1 RESPONSE,     no data
167
 
168
        */
169
        /**Which what type of ctl packets can be sent to side0*/
170
        sc_in<sc_bv<6> >                ui_freevc0_usr;
171
        /**Which what type of ctl packets can be sent to side0*/
172
        sc_in<sc_bv<6> >                ui_freevc1_usr;
173
 
174
 
175
        //------------------------------------------
176
        // Signals to affect CSR
177
        //------------------------------------------
178
        ///Activated when response error is received
179
        sc_out<bool> usr_receivedResponseError_csr;
180
 
181
        ///SystemC Macro
182
        SC_HAS_PROCESS(InterfaceLayer);
183
        ///Queue of packet to send on the interface
184
        std::deque<PacketAndData> packetQueue;
185
 
186
        ///Constructor
187
        InterfaceLayer(sc_module_name name);
188
        ///Destructor
189
        virtual ~InterfaceLayer();
190
 
191
        ///Set the interface handler that will be notified of received packet
192
        void setInterfaceLayerEventHandler(InterfaceLayerEventHandler *handler){
193
                this->handler = handler;
194
        };
195
 
196
        ///To send a packet (non-blocking, packet is simply buffered)
197
        void sendPacket(ControlPacket * packet,int * data,bool side = false);
198
        ///Blocks until all packets are sent out
199
    void flush();
200
 
201
protected:
202
        ///Process for reception of packets from the tunnel
203
        void rx_process();
204
        ///Process to send queued data to the tunnel
205
        void tx_process();
206
 
207
private:
208
 
209
        ///Event handler for received packet
210
        InterfaceLayerEventHandler * handler;
211
        ///The count of data sent
212
        int tx_data_sent;
213
        ///The count of data received
214
        int rx_received_data;
215
        ///State of packet transmission
216
        TransmitState tx_state;
217
        ///State of packet reception
218
        ReceiveState rx_state;
219
 
220
        ///Packet currently being received
221
        ControlPacket * receivePacket;
222
        ///Buffer for received data
223
        int receiveData[16];
224
        ///Side from which the packet was received
225
        bool receiveSide;
226
        ///If the packet is directRoute traffic
227
        bool receiveDirecRoute;
228
};
229
 
230
#endif
231
 
232
 

powered by: WebSVN 2.1.0

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