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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [bench/] [vc_ht_tunnel_l1_tb/] [PhysicalLayer.h] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//PhysicalLayer.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 PhysicalLayer_H
41
#define PhysicalLayer_H
42
 
43
#include "systemc.h"
44
#include "../../rtl/systemc/core_synth/constants.h"
45
 
46
//Forward decleration
47
class PhysicalLayer;
48
 
49
///Event handler interface for the PhysicalLayer module
50
class PhysicalLayerInterface{
51
public:
52
        /**
53
                @description Called by the PhysicalLayer when a dword is received.
54
                @param dword The dword that was received
55
                @param lctl The CTL value for the lower part of the dword transmission
56
                @param hctl The CTL value for the higher part of the dword transmission
57
        */
58
        virtual void receivedDwordEvent(sc_bv<32> &dword,bool lctl,bool hctl)=0;
59
        /**
60
                @description Called by the PhysicalLayer when a dword is needed to be sent out.
61
                @param dword The dword to send (return by address)
62
                @param lctl The CTL value for the lower part of the dword transmission (return by address)
63
                @param hctl The CTL value for the higher part of the dword transmission (return by address)
64
        */
65
    virtual void dwordToSendRequested(sc_bv<32> &dword,bool &lctl,bool &hctl)=0;
66
        /**
67
                @description This is a PhysicalLayerInterface function called by the PhysicalLayer
68
                when periodic CRC error occurs
69
        */
70
    virtual void crcErrorDetected()=0;
71
};
72
 
73
///Handles low level communication with an HT link
74
/**
75
        @class PhysicalLayer
76
        @author Ami Castonguay
77
        @description This SystemC module handles very low level communication of a HT link.
78
                It does the initialization of the link, serialization and de-serialization.  It
79
                also handles periodic CRC insertions.
80
 
81
                When a valid dword is received which is not part of an init sequence or a periodic
82
                CRC, an event is generated.  Since every cycle, the link must output valid data,
83
                an event is also generated whenever a dword to send is requested.
84
 
85
                This physical layer is not complete in terms of HT (it would not work with a
86
                variety of HT links) but is compatible with the current HT core being tested.
87
*/
88
class PhysicalLayer : public sc_module{
89
 
90
        ///The event handler for when dwords are received and needs to be sent
91
        PhysicalLayerInterface * inter;
92
 
93
        ///The periodic CRC polynomial to use
94
        static const int PHYSICAL_LAYER_CRC_POLY;
95
 
96
public:
97
        // ***************************************************
98
        //  Signals
99
        // ***************************************************  
100
        /// Clock signal
101
        sc_in<bool>                     clk;
102
        ///Reset signal
103
        sc_in<bool>                     resetx;
104
 
105
        ///When we have data available for the link
106
        sc_out<bool>                                            phy_available_lk;
107
        ///TX CTL Higher is sent later (MSB), lower is sent first (LSB)
108
        sc_out<sc_bv<CAD_IN_DEPTH> >            phy_ctl_lk;
109
        ///TX CAD Higher is sent later (MSB), lower is sent first (LSB)
110
        sc_out<sc_bv<CAD_IN_DEPTH> >            phy_cad_lk[CAD_IN_WIDTH];
111
 
112
        ///RX CTL - Higher is newer (MSB), lower is older (LSB)
113
        sc_in<sc_bv<CAD_OUT_DEPTH> >    lk_ctl_phy;
114
        ///RX CAD - Higher is newer (MSB), lower is older (LSB)
115
        sc_in<sc_bv<CAD_OUT_DEPTH> >    lk_cad_phy[CAD_OUT_WIDTH];
116
        ///When there is data available for us
117
        sc_out<bool>                                    phy_consume_lk;
118
 
119
        ///If the tested link wants the drivers to be disabled
120
        sc_in<bool>             lk_disable_drivers_phy;
121
        ///If the tested link wants the receivers to be disabled
122
        sc_in<bool>             lk_disable_receivers_phy;
123
 
124
        ///SystemC Macro
125
        SC_HAS_PROCESS(PhysicalLayer);
126
 
127
        ///Constructor
128
        PhysicalLayer(sc_module_name name);
129
        ///Destructor
130
        virtual ~PhysicalLayer(){};
131
 
132
        ///Will disconnect when the CRC windows is done
133
        void ldtstopDisconnect();
134
        ///Reconnect the link ASAP
135
        void ldtstopConnect();
136
 
137
        ///Causes an immediate disconnect, no further dwords are sent out
138
        void retryDisconnectAndReconnect();
139
 
140
        ///The interface to connect to the physical layer
141
        void setInterface(PhysicalLayerInterface * inter){this->inter = inter;};
142
 
143
private:
144
 
145
        ///If the TX side of the link is connected
146
        bool tx_connected;
147
        ///The current calculated TX periodic CRC
148
        int current_tx_crc;
149
        ///The value of the TX CRC for the last window of operation
150
        int last_tx_crc;
151
        ///If the current TX window is the first CRC window since init
152
        bool tx_firstCrcWindow;
153
        ///The count of where where are in the TX CRC window (in dwords)
154
        int tx_crc_count;
155
 
156
        ///If the RX side of the link is connected
157
        bool rx_connected;
158
        ///The current calculated RX periodic CRC
159
        int current_rx_crc;
160
        ///The value of the RX CRC for the last window of operation
161
        int last_rx_crc;
162
        ///If the current RX window is the first CRC window since init
163
        bool rx_firstCrcWindow;
164
        ///The count of where where are in the RX CRC window (in dwords)
165
        int rx_crc_count;
166
 
167
        ///Vector of only zeroes
168
        sc_bv<CAD_IN_DEPTH> v0;
169
        ///Vector of only ones
170
        sc_bv<CAD_IN_DEPTH> v1;
171
 
172
        ///If we are currently in a ldtstop sequence (ignore inputs and output discon nop until end of window)
173
        bool ldtstop_sequence;
174
        ///If done sending ldtstop packets
175
        bool ldtstop_sequence_complete;
176
        ///After sending the last CRC, the sequence will be complete
177
        bool ltdstop_last_crc_window;
178
        ///If a discon nop was received on the rx
179
        bool ltdstop_rx_received_disconnect;
180
 
181
        ///The number of cycles that the TX must stay disconnected for a retry sequence
182
        int retryDisconnectCountTX;
183
        ///The number of cycles that the RX must stay disconnected for a retry sequence
184
        int retryDisconnectCountRX;
185
 
186
        ///Process that handles receiving the data and generated events
187
        void receiveThread();
188
        ///Process that handles transmiting data
189
        void transmitThread();
190
        ///Keeps sending reset signaling until conditions have passed.
191
        void holdResetSignaling();
192
        ///Initiate the connect sequence for the TX
193
        void tx_connect();
194
 
195
        ///Calculate the periodic CRC for a send dword
196
        void calculateCrc(int &crc,int dword,bool lctl,bool hctl);
197
        ///Sends next dword, either data or the window CRC if at the correct time
198
        void sendNextDwordOrCrc();
199
        ///Sends the specified dword and CTL value on the outputs
200
        void sendDword(sc_bv<32> &dword,bool lctl,bool hctl);
201
        ///Initiate the connect sequence for the RX
202
        void rx_connect();
203
        ///If at the correct pos in the window, CRC is checked.  Otherwise, data is received
204
        void receiveDwordOrCrc();
205
        ///IExtracts the dword received from the input
206
        void receiveDword(sc_bv<32> &dword,bool &lctl,bool &hctl);
207
};
208
 
209
 
210
#endif
211
 

powered by: WebSVN 2.1.0

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