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

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [rtl/] [systemc/] [flow_control_l2/] [history_buffer_l3.h] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//history_buffer_l3.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
 *   Jean-Francois Belanger
25
 *   Ami Castonguay <acastong@grm.polymtl.ca>
26
 *
27
 * Alternatively, the contents of this file may be used under the terms
28
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
29
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
30
 * provisions of PHTICSCL License are applicable instead of those
31
 * above. If you wish to allow use of your version of this file only
32
 * under the terms of the PHTICSCL License and not to allow others to use
33
 * your version of this file under the MPL, indicate your decision by
34
 * deleting the provisions above and replace them with the notice and
35
 * other provisions required by the PHTICSCL License. If you do not delete
36
 * the provisions above, a recipient may use your version of this file
37
 * under either the MPL or the PHTICSCL License."
38
 *
39
 * ***** END LICENSE BLOCK ***** */
40
 
41
#ifndef HISTORY_BUFFER_L3_H
42
#define HISTORY_BUFFER_L3_H
43
 
44
#include "../core_synth/synth_datatypes.h"      
45
#include "../core_synth/constants.h"
46
 
47
 
48
///Keeps track of the history of sent packets
49
/**
50
        @class history_buffer_l3
51
        @author Ami Castonguay
52
        @description
53
 
54
        The retry mode allows to attach a CRC to every packet.  If
55
        a packet is corrupted, the packet can simply be resent.  To
56
        be able to be resent, sent packets must be stored in a buffer.
57
 
58
        This sub-module takes care of managing the content of such
59
        a buffer.  This buffer is made to be used with a dual-port
60
        memory (one read port, one write port).
61
 
62
        To keep track of the content of the buffer, a simple read pointer
63
        and a write pointer is kept.  When a new entry is created, a first
64
        dword is written in the memory which containes the tracking number
65
        and the size of the entry : this is the entry header.
66
 
67
        When a ack is received, the read pointer jumps from entry headers to
68
        the next entry header until either the ack number is reached or
69
        that the read pointer has reached the write pointer.
70
 
71
        The content of a header is :
72
                dword[7..0]  : ack value
73
                dword[12..8] : size of entry
74
 
75
        During retry playback, all that is stored in the history buffer will
76
        simply be resent.
77
*/
78
class history_buffer_l3 : public sc_module
79
{
80
        public:
81
 
82
        ///The possible internal state of the history buffer
83
        enum HISTORY_STATES {
84
                IDLE_STATE,     HISTORY_PLAYBACK};
85
 
86
 
87
        ///The write pointer in the buffer
88
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > write_pointer;
89
        ///Next value of ::write_pointer
90
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > next_write_pointer;
91
 
92
        ///The write stop pointer is the last position of the current entry.
93
        /**When the write pointer reaches the write_stop_pointer and the last
94
                dword is written, the NextPktToAck is incremented*/
95
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > write_stop_pointer;
96
        ///Next value of ::write_stop_pointer
97
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > next_write_stop_pointer;
98
 
99
        ///The begginning of the current entry
100
        /** If a packet entry is cancelled, it will revert to this pos.*/
101
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > entry_write_start_pointer;
102
        ///Next value of ::entry_write_start_pointer
103
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > next_entry_write_start_pointer;
104
 
105
        ///The pointer to keep track of where to start reading if a playback is started
106
        /** When acks are received, this read pointer will be updated to a correct position*/
107
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > idle_read_pointer;
108
        ///Next value of ::idle_read_pointer
109
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > next_idle_read_pointer;
110
 
111
        ///Read pointer that will increment during history playback
112
        /** When history playback is started, it is set at idle_read_pointer value, then it is
113
                incremented until entry_write_start_pointer is reached */
114
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > playback_read_pointer;
115
        ///Next value of ::playback_read_pointer
116
        sc_signal<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > next_playback_read_pointer;
117
 
118
        ///The count value we are waiting to be acknoledged
119
        /**
120
                The best way to understand this is to read the HT doc on this.
121
                This is initialized at 0 at reset, so the first packet to be stored
122
                in the history is tagged with the value 1 and TxNextPktToAck takes
123
                on that same value.
124
 
125
                So in that example, #1 is the next packet that needs to be acked, hence the
126
                name TxNextPktToAck.  When we receive an ack value of 1, we can free
127
                that packet's entry.
128
        */
129
        sc_signal<sc_uint<8> >  TxNextPktToAck;
130
        ///Next value of ::TxNextPktToAck
131
        sc_signal<sc_uint<8> >  next_TxNextPktToAck;
132
 
133
        ///Registered value of what is received from nop
134
        /** This will not be identical to the value coming from the decoder
135
                since this variable is only updated when the nop is validated, while
136
                the value from the nop is updated as soon as */
137
        sc_signal<sc_uint<8> >  received_RxNextPktToAck;
138
        ///Next value of ::received_RxNextPktToAck
139
        sc_signal<sc_uint<8> >  next_received_RxNextPktToAck;
140
 
141
        ///Tracks how many reads are left to an entry during playback
142
        /** This is necessary to be able to recognize where are the headers and not
143
                send them as normal data*/
144
        sc_signal<sc_uint<5> > playback_count;
145
        ///Next value of ::playback_count
146
        sc_signal<sc_uint<5> > next_playback_count;
147
 
148
 
149
        ///The state of the state machine
150
        sc_signal<HISTORY_STATES>       state;
151
        ///Next value of ::state
152
        sc_signal<HISTORY_STATES>       next_state;
153
 
154
        ///Next value of ::history_playback_ready
155
        sc_signal<bool> next_history_playback_ready;
156
        ///Next value of ::history_playback_done
157
        sc_signal<bool> next_history_playback_done;
158
 
159
        /**If the data from memory corresponds to the content in memory.
160
          It has value false when something is written to memory at the read pointer.*/
161
        sc_signal<bool> valid_memory_data;
162
 
163
        sc_signal<bool> last_cycle_new_history_entry;
164
        sc_signal<sc_uint<5> >  last_cycle_new_history_entry_size_m1;
165
 
166
        ///The output dword when playing back history
167
        sc_out <sc_bv<32> > history_packet;
168
        ///When the complete history has finished playing back
169
        sc_out <bool > history_playback_done;
170
        ///To begin the playback of the history from the last acked packet
171
        sc_in <bool > begin_history_playback;
172
        ///To stop the playback of the history if the retry sequence is aborted
173
        sc_in <bool > stop_history_playback;
174
        ///If the playback of the history is ready, begin will be ignored when not asserted
175
        sc_out <bool > history_playback_ready;
176
        ///To consume the data produced by the history buffer
177
        /**A minimum pause of 1 cycle must be left between entries (to allow
178
                history entry header to be read) before starting to read a next entry.
179
                An entry is composed of the command and it's data.  Usually this should
180
                be natural since the CRC must be sent after an entry is sent.*/
181
        sc_in <bool > consume_history;
182
        ///If there is enough room left in the history for another maximum size packet
183
        /*to allow the flow control to know if a packet can be sent, maximum size is 18 dwords*/
184
        sc_out <bool > room_available_in_history;
185
        ///To add a dword to the history
186
        sc_in <bool > add_to_history;
187
#ifdef PERMIT_CANCEL_HISTORY
188
        ///To cancel a history_entry (like when there's an stomped packet sent)
189
        /** An entry MUST be canceled before a new one can be started.  Since this
190
                is only necessary in a cut-through implementation, which at the time of
191
                making this module was not an option for the HT design, it is only enable
192
                by using a preprocessor define
193
        */
194
        sc_in <bool > cancel_history_entry;
195
#endif
196
        ///To add a new entry to the history, to be done before starting to add to the history
197
        sc_in <bool > new_history_entry;
198
        ///The size (minus 1) of the new history entry
199
        sc_in <sc_uint<5> > new_history_entry_size_m1;
200
 
201
        ///dword being sent to the link, so it can be stored in the buffer
202 14 acastong
        sc_in<sc_bv<32> > mux_registered_output;
203 2 acastong
 
204
        ///When a nop was received : read the new ack_value
205
        sc_in<bool>     nop_received;
206
        ///The value acked from the next HT node
207
        sc_in<sc_uint<8> >      ack_value;
208
 
209
        ///Reset
210
        sc_in<bool>     resetx;
211
        ///Clock
212
        sc_in<bool> clk;
213
 
214
        //////////////////////////////////////////
215
        //      Memory interface - synchronous
216
        /////////////////////////////////////////
217
 
218
        sc_out<bool> history_memory_write;///<Write to history memory
219
        sc_out<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_write_address;///<Address where to write in history memory
220
        sc_out<sc_bv<32> > history_memory_write_data;///<Data to write to history memory
221
        sc_out<sc_uint<LOG2_HISTORY_MEMORY_SIZE> > history_memory_read_address;///<Address where to read in history memory
222
        sc_in<sc_bv<32> > history_memory_output;///<Data read in history memory
223
 
224
        ///SystemC Macro
225
        SC_HAS_PROCESS(history_buffer_l3);
226
 
227
        //Constructor
228
        history_buffer_l3(sc_module_name name);
229
        ///Everything that is registered
230
        void clocked_process();
231
 
232
        ///Process that handle writing to the memory to store retry entries
233
        void write_in_memory();
234
        ///Process that handles reading the memory for playback and to delete acked entries
235
        void read_in_memory();
236
};
237
 
238
#endif

powered by: WebSVN 2.1.0

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