1 |
2 |
issei |
//===================================================================
|
2 |
|
|
// Module Name : RsDecodeDelay
|
3 |
|
|
// File Name : RsDecodeDelay.cpp
|
4 |
|
|
// Function : RTL Decoder Delay Module generation
|
5 |
|
|
//
|
6 |
|
|
// Revision History:
|
7 |
|
|
// Date By Version Change Description
|
8 |
|
|
//===================================================================
|
9 |
|
|
// 2009/02/03 Gael Sapience 1.0 Original
|
10 |
|
|
//
|
11 |
|
|
//===================================================================
|
12 |
|
|
// (C) COPYRIGHT 2009 SYSTEM LSI CO., Ltd.
|
13 |
|
|
//
|
14 |
|
|
#include <stdio.h>
|
15 |
|
|
#include <stdlib.h>
|
16 |
|
|
#include <iostream>
|
17 |
|
|
#include<windows.h>
|
18 |
|
|
#include<fstream>
|
19 |
|
|
#include <string.h>
|
20 |
|
|
|
21 |
|
|
using namespace std;
|
22 |
|
|
|
23 |
|
|
FILE *OutFileDelay;
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
void RsDecodeDelay(int DataSize, int TotalSize, int PrimPoly, int ErasureOption, int bitSymbol, int pathFlag, int lengthPath, char *rootFolderPath) {
|
27 |
|
|
|
28 |
|
|
//---------------------------------------------------------------
|
29 |
|
|
// C++ variables
|
30 |
|
|
//---------------------------------------------------------------
|
31 |
|
|
int syndromeLength;
|
32 |
|
|
syndromeLength = TotalSize - DataSize;
|
33 |
|
|
|
34 |
|
|
int ii;
|
35 |
|
|
int Delay;
|
36 |
|
|
int *euclideTab;
|
37 |
|
|
char *strRsDecodeDelay;
|
38 |
|
|
|
39 |
|
|
euclideTab =new int[(syndromeLength+1)];
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
//---------------------------------------------------------------
|
43 |
|
|
// open file
|
44 |
|
|
//---------------------------------------------------------------
|
45 |
|
|
strRsDecodeDelay = (char *)calloc(lengthPath + 21, sizeof(char));
|
46 |
|
|
if (pathFlag == 0) {
|
47 |
|
|
strRsDecodeDelay[0] = '.';
|
48 |
|
|
}else{
|
49 |
|
|
for(ii=0; ii<lengthPath; ii++){
|
50 |
|
|
strRsDecodeDelay[ii] = rootFolderPath[ii];
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
strcat(strRsDecodeDelay, "/rtl/RsDecodeDelay.v");
|
54 |
|
|
|
55 |
|
|
OutFileDelay = fopen(strRsDecodeDelay,"w");
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
//---------------------------------------------------------------
|
61 |
|
|
// write Header File
|
62 |
|
|
//---------------------------------------------------------------
|
63 |
|
|
fprintf(OutFileDelay, "//===================================================================\n");
|
64 |
|
|
fprintf(OutFileDelay, "// Module Name : RsDecodeDelay\n");
|
65 |
|
|
fprintf(OutFileDelay, "// File Name : RsDecodeDelay.v\n");
|
66 |
|
|
fprintf(OutFileDelay, "// Function : Rs DpRam Memory controller Module\n");
|
67 |
|
|
fprintf(OutFileDelay, "// \n");
|
68 |
|
|
fprintf(OutFileDelay, "// Revision History:\n");
|
69 |
|
|
fprintf(OutFileDelay, "// Date By Version Change Description\n");
|
70 |
|
|
fprintf(OutFileDelay, "//===================================================================\n");
|
71 |
|
|
fprintf(OutFileDelay, "// 2009/02/03 Gael Sapience 1.0 Original\n");
|
72 |
|
|
fprintf(OutFileDelay, "//\n");
|
73 |
|
|
fprintf(OutFileDelay, "//===================================================================\n");
|
74 |
|
|
fprintf(OutFileDelay, "// (C) COPYRIGHT 2009 SYSTEM LSI CO., Ltd.\n");
|
75 |
|
|
fprintf(OutFileDelay, "//\n\n\n");
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
//---------------------------------------------------------------
|
79 |
|
|
// Ports Declaration
|
80 |
|
|
//---------------------------------------------------------------
|
81 |
|
|
fprintf(OutFileDelay, "module RsDecodeDelay(\n");
|
82 |
|
|
fprintf(OutFileDelay, " CLK, // system clock\n");
|
83 |
|
|
fprintf(OutFileDelay, " RESET, // system reset\n");
|
84 |
|
|
fprintf(OutFileDelay, " enable, // enable signal\n");
|
85 |
|
|
fprintf(OutFileDelay, " dataIn, // data input\n");
|
86 |
|
|
fprintf(OutFileDelay, " dataOut // data output\n");
|
87 |
|
|
fprintf(OutFileDelay, ");\n");
|
88 |
|
|
fprintf(OutFileDelay, "\n");
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
//---------------------------------------------------------------
|
92 |
|
|
// I/O instantiation
|
93 |
|
|
//---------------------------------------------------------------
|
94 |
|
|
fprintf(OutFileDelay, " input CLK; // system clock\n");
|
95 |
|
|
fprintf(OutFileDelay, " input RESET; // system reset\n");
|
96 |
|
|
fprintf(OutFileDelay, " input enable; // enable signal\n");
|
97 |
|
|
if (ErasureOption == 1) {
|
98 |
|
|
fprintf(OutFileDelay, " input [%d:0] dataIn; // data input\n", bitSymbol);
|
99 |
|
|
fprintf(OutFileDelay, " output [%d:0] dataOut; // data output\n", bitSymbol);
|
100 |
|
|
} else {
|
101 |
|
|
fprintf(OutFileDelay, " input [%d:0] dataIn; // data input\n", bitSymbol-1);
|
102 |
|
|
fprintf(OutFileDelay, " output [%d:0] dataOut; // data output\n", bitSymbol-1);
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
//------------------------------------------------------------------------
|
109 |
|
|
//- euclideTab calculation
|
110 |
|
|
//------------------------------------------------------------------------
|
111 |
|
|
euclideTab [syndromeLength] = 3;
|
112 |
|
|
euclideTab [syndromeLength-1] = 3;
|
113 |
|
|
|
114 |
|
|
for(ii=(syndromeLength-2); ii>0; ii=ii-2){
|
115 |
|
|
euclideTab [ii] = euclideTab [ii+2] + 6;
|
116 |
|
|
euclideTab [ii-1] = euclideTab [ii+1] + 6;
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
euclideTab [0] = euclideTab [2] + 6;
|
120 |
|
|
|
121 |
|
|
if (ErasureOption == 1) {
|
122 |
|
|
Delay = TotalSize + syndromeLength + 1 + euclideTab [0] + 5;
|
123 |
|
|
}else{
|
124 |
|
|
Delay = TotalSize + euclideTab [0] + 5;
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
//------------------------------------------------------------------------
|
129 |
|
|
//- registers
|
130 |
|
|
//------------------------------------------------------------------------
|
131 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
132 |
|
|
fprintf(OutFileDelay, " //- registers\n");
|
133 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
134 |
|
|
|
135 |
|
|
if (Delay < 4) {
|
136 |
|
|
fprintf(OutFileDelay, " reg [1:0] writePointer;\n");
|
137 |
|
|
fprintf(OutFileDelay, " reg [1:0] readPointer;\n");
|
138 |
|
|
}
|
139 |
|
|
else if (Delay < 8) {
|
140 |
|
|
fprintf(OutFileDelay, " reg [2:0] writePointer;\n");
|
141 |
|
|
fprintf(OutFileDelay, " reg [2:0] readPointer;\n");
|
142 |
|
|
}
|
143 |
|
|
else if (Delay < 16) {
|
144 |
|
|
fprintf(OutFileDelay, " reg [3:0] writePointer;\n");
|
145 |
|
|
fprintf(OutFileDelay, " reg [3:0] readPointer;\n");
|
146 |
|
|
}
|
147 |
|
|
else if (Delay < 32) {
|
148 |
|
|
fprintf(OutFileDelay, " reg [4:0] writePointer;\n");
|
149 |
|
|
fprintf(OutFileDelay, " reg [4:0] readPointer;\n");
|
150 |
|
|
}
|
151 |
|
|
else if (Delay < 64) {
|
152 |
|
|
fprintf(OutFileDelay, " reg [5:0] writePointer;\n");
|
153 |
|
|
fprintf(OutFileDelay, " reg [5:0] readPointer;\n");
|
154 |
|
|
}
|
155 |
|
|
else if (Delay < 128) {
|
156 |
|
|
fprintf(OutFileDelay, " reg [6:0] writePointer;\n");
|
157 |
|
|
fprintf(OutFileDelay, " reg [6:0] readPointer;\n");
|
158 |
|
|
}
|
159 |
|
|
else if (Delay < 256) {
|
160 |
|
|
fprintf(OutFileDelay, " reg [7:0] writePointer;\n");
|
161 |
|
|
fprintf(OutFileDelay, " reg [7:0] readPointer;\n");
|
162 |
|
|
}
|
163 |
|
|
else if (Delay < 512) {
|
164 |
|
|
fprintf(OutFileDelay, " reg [8:0] writePointer;\n");
|
165 |
|
|
fprintf(OutFileDelay, " reg [8:0] readPointer;\n");
|
166 |
|
|
}
|
167 |
|
|
else if (Delay < 1024) {
|
168 |
|
|
fprintf(OutFileDelay, " reg [9:0] writePointer;\n");
|
169 |
|
|
fprintf(OutFileDelay, " reg [9:0] readPointer;\n");
|
170 |
|
|
}
|
171 |
|
|
else if (Delay < 2048) {
|
172 |
|
|
fprintf(OutFileDelay, " reg [10:0] writePointer;\n");
|
173 |
|
|
fprintf(OutFileDelay, " reg [10:0] readPointer;\n");
|
174 |
|
|
}
|
175 |
|
|
else if (Delay < 4096) {
|
176 |
|
|
fprintf(OutFileDelay, " reg [11:0] writePointer;\n");
|
177 |
|
|
fprintf(OutFileDelay, " reg [11:0] readPointer;\n");
|
178 |
|
|
}
|
179 |
|
|
else if (Delay < 8192) {
|
180 |
|
|
fprintf(OutFileDelay, " reg [12:0] writePointer;\n");
|
181 |
|
|
fprintf(OutFileDelay, " reg [12:0] readPointer;\n");
|
182 |
|
|
}
|
183 |
|
|
else if (Delay < 16384) {
|
184 |
|
|
fprintf(OutFileDelay, " reg [13:0] writePointer;\n");
|
185 |
|
|
fprintf(OutFileDelay, " reg [13:0] readPointer;\n");
|
186 |
|
|
}
|
187 |
|
|
else if (Delay < 32768) {
|
188 |
|
|
fprintf(OutFileDelay, " reg [14:0] writePointer;\n");
|
189 |
|
|
fprintf(OutFileDelay, " reg [14:0] readPointer;\n");
|
190 |
|
|
}
|
191 |
|
|
else if (Delay < 65536) {
|
192 |
|
|
fprintf(OutFileDelay, " reg [15:0] writePointer;\n");
|
193 |
|
|
fprintf(OutFileDelay, " reg [15:0] readPointer;\n");
|
194 |
|
|
}
|
195 |
|
|
else {
|
196 |
|
|
fprintf(OutFileDelay, " reg [16:0] writePointer;\n");
|
197 |
|
|
fprintf(OutFileDelay, " reg [16:0] readPointer;\n");
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
if (ErasureOption == 1) {
|
202 |
|
|
fprintf(OutFileDelay, " wire [%d:0] dpramRdData;\n", bitSymbol);
|
203 |
|
|
} else {
|
204 |
|
|
fprintf(OutFileDelay, " wire [%d:0] dpramRdData;\n", bitSymbol-1);
|
205 |
|
|
}
|
206 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
//------------------------------------------------------------------------
|
210 |
|
|
//- RAM memory instantiation
|
211 |
|
|
//------------------------------------------------------------------------
|
212 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
213 |
|
|
fprintf(OutFileDelay, " //- RAM memory instantiation\n");
|
214 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
215 |
|
|
fprintf(OutFileDelay, " RsDecodeDpRam RsDecodeDpRam(\n");
|
216 |
|
|
fprintf(OutFileDelay, " // Outputs\n");
|
217 |
|
|
fprintf(OutFileDelay, " .q(dpramRdData),\n");
|
218 |
|
|
fprintf(OutFileDelay, " // Inputs\n");
|
219 |
|
|
fprintf(OutFileDelay, " .clock(CLK),\n");
|
220 |
|
|
if (ErasureOption == 1) {
|
221 |
|
|
fprintf(OutFileDelay, " .data(dataIn [%d:0]),\n", bitSymbol);
|
222 |
|
|
} else {
|
223 |
|
|
fprintf(OutFileDelay, " .data(dataIn [%d:0]),\n", bitSymbol-1);
|
224 |
|
|
}
|
225 |
|
|
fprintf(OutFileDelay, " .rdaddress(readPointer),\n");
|
226 |
|
|
fprintf(OutFileDelay, " .rden(enable),\n");
|
227 |
|
|
fprintf(OutFileDelay, " .wraddress(writePointer),\n");
|
228 |
|
|
fprintf(OutFileDelay, " .wren(enable)\n");
|
229 |
|
|
fprintf(OutFileDelay, " );\n");
|
230 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
//------------------------------------------------------------------------
|
234 |
|
|
//- dataOut
|
235 |
|
|
//------------------------------------------------------------------------
|
236 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
237 |
|
|
fprintf(OutFileDelay, " //+ dataOut\n");
|
238 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
239 |
|
|
if (ErasureOption == 1) {
|
240 |
|
|
fprintf(OutFileDelay, " assign dataOut[%d:0] = dpramRdData;\n", bitSymbol);
|
241 |
|
|
} else {
|
242 |
|
|
fprintf(OutFileDelay, " assign dataOut[%d:0] = dpramRdData;\n", bitSymbol-1);
|
243 |
|
|
}
|
244 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
//------------------------------------------------------------------------
|
248 |
|
|
//- Write Pointer
|
249 |
|
|
//------------------------------------------------------------------------
|
250 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
251 |
|
|
fprintf(OutFileDelay, " //- Write Pointer\n");
|
252 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
253 |
|
|
fprintf(OutFileDelay, " always @(posedge CLK or negedge RESET) begin\n");
|
254 |
|
|
fprintf(OutFileDelay, " if (~RESET) begin\n");
|
255 |
|
|
|
256 |
|
|
if (Delay < 4) {
|
257 |
|
|
fprintf(OutFileDelay, " writePointer <= 2'd%d;\n", (Delay-1));
|
258 |
|
|
}
|
259 |
|
|
else if (Delay < 8) {
|
260 |
|
|
fprintf(OutFileDelay, " writePointer <= 3'd%d;\n", (Delay-1));
|
261 |
|
|
}
|
262 |
|
|
else if (Delay < 16) {
|
263 |
|
|
fprintf(OutFileDelay, " writePointer <= 4'd%d;\n", (Delay-1));
|
264 |
|
|
}
|
265 |
|
|
else if (Delay < 32) {
|
266 |
|
|
fprintf(OutFileDelay, " writePointer <= 5'd%d;\n", (Delay-1));
|
267 |
|
|
}
|
268 |
|
|
else if (Delay < 64) {
|
269 |
|
|
fprintf(OutFileDelay, " writePointer <= 6'd%d;\n", (Delay-1));
|
270 |
|
|
}
|
271 |
|
|
else if (Delay < 128) {
|
272 |
|
|
fprintf(OutFileDelay, " writePointer <= 7'd%d;\n", (Delay-1));
|
273 |
|
|
}
|
274 |
|
|
else if (Delay < 256) {
|
275 |
|
|
fprintf(OutFileDelay, " writePointer <= 8'd%d;\n", (Delay-1));
|
276 |
|
|
}
|
277 |
|
|
else if (Delay < 512) {
|
278 |
|
|
fprintf(OutFileDelay, " writePointer <= 9'd%d;\n", (Delay-1));
|
279 |
|
|
}
|
280 |
|
|
else if (Delay < 1024) {
|
281 |
|
|
fprintf(OutFileDelay, " writePointer <= 10'd%d;\n", (Delay-1));
|
282 |
|
|
}
|
283 |
|
|
else if (Delay < 2048) {
|
284 |
|
|
fprintf(OutFileDelay, " writePointer <= 11'd%d;\n", (Delay-1));
|
285 |
|
|
}
|
286 |
|
|
else if (Delay < 4096) {
|
287 |
|
|
fprintf(OutFileDelay, " writePointer <= 12'd%d;\n", (Delay-1));
|
288 |
|
|
}
|
289 |
|
|
else if (Delay < 8192) {
|
290 |
|
|
fprintf(OutFileDelay, " writePointer <= 13'd%d;\n", (Delay-1));
|
291 |
|
|
}
|
292 |
|
|
else if (Delay < 16384) {
|
293 |
|
|
fprintf(OutFileDelay, " writePointer <= 14'd%d;\n", (Delay-1));
|
294 |
|
|
}
|
295 |
|
|
else if (Delay < 32768) {
|
296 |
|
|
fprintf(OutFileDelay, " writePointer <= 14'd%d;\n", (Delay-1));
|
297 |
|
|
}
|
298 |
|
|
else if (Delay < 65536) {
|
299 |
|
|
fprintf(OutFileDelay, " writePointer <= 15'd%d;\n", (Delay-1));
|
300 |
|
|
}
|
301 |
|
|
else {
|
302 |
|
|
fprintf(OutFileDelay, " writePointer <= 16'd%d;\n", (Delay-1));
|
303 |
|
|
}
|
304 |
|
|
fprintf(OutFileDelay, " end\n");
|
305 |
|
|
fprintf(OutFileDelay, " else if (enable == 1'b1) begin\n");
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
if (Delay < 4) {
|
309 |
|
|
fprintf(OutFileDelay, " if (writePointer == 2'd%d) begin\n", (Delay-1));
|
310 |
|
|
fprintf(OutFileDelay, " writePointer <= 2'd0;\n");
|
311 |
|
|
fprintf(OutFileDelay, " end\n");
|
312 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
313 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 2'd1;\n");
|
314 |
|
|
}
|
315 |
|
|
else if (Delay < 8) {
|
316 |
|
|
fprintf(OutFileDelay, " if (writePointer == 3'd%d) begin\n", (Delay-1));
|
317 |
|
|
fprintf(OutFileDelay, " writePointer <= 3'd0;\n");
|
318 |
|
|
fprintf(OutFileDelay, " end\n");
|
319 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
320 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 3'd1;\n");
|
321 |
|
|
}
|
322 |
|
|
else if (Delay < 16) {
|
323 |
|
|
fprintf(OutFileDelay, " if (writePointer == 4'd%d) begin\n", (Delay-1));
|
324 |
|
|
fprintf(OutFileDelay, " writePointer <= 4'd0;\n");
|
325 |
|
|
fprintf(OutFileDelay, " end\n");
|
326 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
327 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 4'd1;\n");
|
328 |
|
|
}
|
329 |
|
|
else if (Delay < 32) {
|
330 |
|
|
fprintf(OutFileDelay, " if (writePointer == 5'd%d) begin\n", (Delay-1));
|
331 |
|
|
fprintf(OutFileDelay, " writePointer <= 5'd0;\n");
|
332 |
|
|
fprintf(OutFileDelay, " end\n");
|
333 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
334 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 5'd1;\n");
|
335 |
|
|
}
|
336 |
|
|
else if (Delay < 64) {
|
337 |
|
|
fprintf(OutFileDelay, " if (writePointer == 6'd%d) begin\n", (Delay-1));
|
338 |
|
|
fprintf(OutFileDelay, " writePointer <= 6'd0;\n");
|
339 |
|
|
fprintf(OutFileDelay, " end\n");
|
340 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
341 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 6'd1;\n");
|
342 |
|
|
}
|
343 |
|
|
else if (Delay < 128) {
|
344 |
|
|
fprintf(OutFileDelay, " if (writePointer == 7'd%d) begin\n", (Delay-1));
|
345 |
|
|
fprintf(OutFileDelay, " writePointer <= 7'd0;\n");
|
346 |
|
|
fprintf(OutFileDelay, " end\n");
|
347 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
348 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 7'd1;\n");
|
349 |
|
|
}
|
350 |
|
|
else if (Delay < 256) {
|
351 |
|
|
fprintf(OutFileDelay, " if (writePointer == 8'd%d) begin\n", (Delay-1));
|
352 |
|
|
fprintf(OutFileDelay, " writePointer <= 8'd0;\n");
|
353 |
|
|
fprintf(OutFileDelay, " end\n");
|
354 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
355 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 8'd1;\n");
|
356 |
|
|
}
|
357 |
|
|
else if (Delay < 512) {
|
358 |
|
|
fprintf(OutFileDelay, " if (writePointer == 9'd%d) begin\n", (Delay-1));
|
359 |
|
|
fprintf(OutFileDelay, " writePointer <= 9'd0;\n");
|
360 |
|
|
fprintf(OutFileDelay, " end\n");
|
361 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
362 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 9'd1;\n");
|
363 |
|
|
}
|
364 |
|
|
else if (Delay < 1024) {
|
365 |
|
|
fprintf(OutFileDelay, " if (writePointer == 10'd%d) begin\n", (Delay-1));
|
366 |
|
|
fprintf(OutFileDelay, " writePointer <= 10'd0;\n");
|
367 |
|
|
fprintf(OutFileDelay, " end\n");
|
368 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
369 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 10'd1;\n");
|
370 |
|
|
}
|
371 |
|
|
else if (Delay < 2048) {
|
372 |
|
|
fprintf(OutFileDelay, " if (writePointer == 11'd%d) begin\n", (Delay-1));
|
373 |
|
|
fprintf(OutFileDelay, " writePointer <= 11'd0;\n");
|
374 |
|
|
fprintf(OutFileDelay, " end\n");
|
375 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
376 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 11'd1;\n");
|
377 |
|
|
}
|
378 |
|
|
else if (Delay < 4096) {
|
379 |
|
|
fprintf(OutFileDelay, " if (writePointer == 12'd%d) begin\n", (Delay-1));
|
380 |
|
|
fprintf(OutFileDelay, " writePointer <= 12'd0;\n");
|
381 |
|
|
fprintf(OutFileDelay, " end\n");
|
382 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
383 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 12'd1;\n");
|
384 |
|
|
}
|
385 |
|
|
else if (Delay < 8192) {
|
386 |
|
|
fprintf(OutFileDelay, " if (writePointer == 13'd%d) begin\n", (Delay-1));
|
387 |
|
|
fprintf(OutFileDelay, " writePointer <= 13'd0;\n");
|
388 |
|
|
fprintf(OutFileDelay, " end\n");
|
389 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
390 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 13'd1;\n");
|
391 |
|
|
}
|
392 |
|
|
else if (Delay < 16384) {
|
393 |
|
|
fprintf(OutFileDelay, " if (writePointer == 14'd%d) begin\n", (Delay-1));
|
394 |
|
|
fprintf(OutFileDelay, " writePointer <= 14'd0;\n");
|
395 |
|
|
fprintf(OutFileDelay, " end\n");
|
396 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
397 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 14'd1;\n");
|
398 |
|
|
}
|
399 |
|
|
else if (Delay < 32768) {
|
400 |
|
|
fprintf(OutFileDelay, " if (writePointer == 15'd%d) begin\n", (Delay-1));
|
401 |
|
|
fprintf(OutFileDelay, " writePointer <= 15'd0;\n");
|
402 |
|
|
fprintf(OutFileDelay, " end\n");
|
403 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
404 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 15'd1;\n");
|
405 |
|
|
}
|
406 |
|
|
else if (Delay < 65536) {
|
407 |
|
|
fprintf(OutFileDelay, " if (writePointer == 16'd%d) begin\n", (Delay-1));
|
408 |
|
|
fprintf(OutFileDelay, " writePointer <= 16'd0;\n");
|
409 |
|
|
fprintf(OutFileDelay, " end\n");
|
410 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
411 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 16'd1;\n");
|
412 |
|
|
}
|
413 |
|
|
else {
|
414 |
|
|
fprintf(OutFileDelay, " if (writePointer == 17'd%d) begin\n", (Delay-1));
|
415 |
|
|
fprintf(OutFileDelay, " writePointer <= 17'd0;\n");
|
416 |
|
|
fprintf(OutFileDelay, " end\n");
|
417 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
418 |
|
|
fprintf(OutFileDelay, " writePointer <= writePointer + 17'd1;\n");
|
419 |
|
|
}
|
420 |
|
|
|
421 |
|
|
fprintf(OutFileDelay, " end\n");
|
422 |
|
|
fprintf(OutFileDelay, " end\n");
|
423 |
|
|
fprintf(OutFileDelay, " end\n");
|
424 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
//------------------------------------------------------------------------
|
428 |
|
|
//- Read Pointer
|
429 |
|
|
//------------------------------------------------------------------------
|
430 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
431 |
|
|
fprintf(OutFileDelay, " //- Read Pointer\n");
|
432 |
|
|
fprintf(OutFileDelay, " //------------------------------------------------------------------------\n");
|
433 |
|
|
fprintf(OutFileDelay, " always @(posedge CLK or negedge RESET) begin\n");
|
434 |
|
|
fprintf(OutFileDelay, " if (~RESET) begin\n");
|
435 |
|
|
|
436 |
|
|
if (Delay < 4) {
|
437 |
|
|
fprintf(OutFileDelay, " readPointer [1:0] <= 2'd0;\n");
|
438 |
|
|
}
|
439 |
|
|
else if (Delay < 8) {
|
440 |
|
|
fprintf(OutFileDelay, " readPointer [2:0] <= 3'd0;\n");
|
441 |
|
|
}
|
442 |
|
|
else if (Delay < 16) {
|
443 |
|
|
fprintf(OutFileDelay, " readPointer [3:0] <= 4'd0;\n");
|
444 |
|
|
}
|
445 |
|
|
else if (Delay < 32) {
|
446 |
|
|
fprintf(OutFileDelay, " readPointer [4:0] <= 5'd0;\n");
|
447 |
|
|
}
|
448 |
|
|
else if (Delay < 64) {
|
449 |
|
|
fprintf(OutFileDelay, " readPointer [5:0] <= 6'd0;\n");
|
450 |
|
|
}
|
451 |
|
|
else if (Delay < 128) {
|
452 |
|
|
fprintf(OutFileDelay, " readPointer [6:0] <= 7'd0;\n");
|
453 |
|
|
}
|
454 |
|
|
else if (Delay < 256) {
|
455 |
|
|
fprintf(OutFileDelay, " readPointer [7:0] <= 8'd0;\n");
|
456 |
|
|
}
|
457 |
|
|
else if (Delay < 512) {
|
458 |
|
|
fprintf(OutFileDelay, " readPointer [8:0] <= 9'd0;\n");
|
459 |
|
|
}
|
460 |
|
|
else if (Delay < 1024) {
|
461 |
|
|
fprintf(OutFileDelay, " readPointer [9:0] <= 10'd0;\n");
|
462 |
|
|
}
|
463 |
|
|
else if (Delay < 2048) {
|
464 |
|
|
fprintf(OutFileDelay, " readPointer [10:0] <= 11'd0;\n");
|
465 |
|
|
}
|
466 |
|
|
else if (Delay < 4096) {
|
467 |
|
|
fprintf(OutFileDelay, " readPointer [11:0] <= 12'd0;\n");
|
468 |
|
|
}
|
469 |
|
|
else if (Delay < 8192) {
|
470 |
|
|
fprintf(OutFileDelay, " readPointer [12:0] <= 13'd0;\n");
|
471 |
|
|
}
|
472 |
|
|
else if (Delay < 16384) {
|
473 |
|
|
fprintf(OutFileDelay, " readPointer [13:0] <= 14'd0;\n");
|
474 |
|
|
}
|
475 |
|
|
else if (Delay < 32768) {
|
476 |
|
|
fprintf(OutFileDelay, " readPointer [14:0] <= 15'd0;\n");
|
477 |
|
|
}
|
478 |
|
|
else if (Delay < 65536) {
|
479 |
|
|
fprintf(OutFileDelay, " readPointer [15:0] <= 16'd0;\n");
|
480 |
|
|
}
|
481 |
|
|
else {
|
482 |
|
|
fprintf(OutFileDelay, " readPointer [16:0] <= 17'd0;\n");
|
483 |
|
|
}
|
484 |
|
|
|
485 |
|
|
fprintf(OutFileDelay, " end \n");
|
486 |
|
|
fprintf(OutFileDelay, " else if (enable == 1'b1) begin\n");
|
487 |
|
|
|
488 |
|
|
if (Delay < 4) {
|
489 |
|
|
fprintf(OutFileDelay, " if (readPointer == 2'd%d) begin\n", (Delay-1));
|
490 |
|
|
fprintf(OutFileDelay, " readPointer <= 2'd0;\n");
|
491 |
|
|
fprintf(OutFileDelay, " end\n");
|
492 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
493 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 2'd1;\n");
|
494 |
|
|
}
|
495 |
|
|
else if (Delay < 8) {
|
496 |
|
|
fprintf(OutFileDelay, " if (readPointer == 3'd%d) begin\n", (Delay-1));
|
497 |
|
|
fprintf(OutFileDelay, " readPointer <= 3'd0;\n");
|
498 |
|
|
fprintf(OutFileDelay, " end\n");
|
499 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
500 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 3'd1;\n");
|
501 |
|
|
}
|
502 |
|
|
else if (Delay < 16) {
|
503 |
|
|
fprintf(OutFileDelay, " if (readPointer == 4'd%d) begin\n", (Delay-1));
|
504 |
|
|
fprintf(OutFileDelay, " readPointer <= 4'd0;\n");
|
505 |
|
|
fprintf(OutFileDelay, " end\n");
|
506 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
507 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 4'd1;\n");
|
508 |
|
|
}
|
509 |
|
|
else if (Delay < 32) {
|
510 |
|
|
fprintf(OutFileDelay, " if (readPointer == 5'd%d) begin\n", (Delay-1));
|
511 |
|
|
fprintf(OutFileDelay, " readPointer <= 5'd0;\n");
|
512 |
|
|
fprintf(OutFileDelay, " end\n");
|
513 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
514 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 5'd1;\n");
|
515 |
|
|
}
|
516 |
|
|
else if (Delay < 64) {
|
517 |
|
|
fprintf(OutFileDelay, " if (readPointer == 6'd%d) begin\n", (Delay-1));
|
518 |
|
|
fprintf(OutFileDelay, " readPointer <= 6'd0;\n");
|
519 |
|
|
fprintf(OutFileDelay, " end\n");
|
520 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
521 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 6'd1;\n");
|
522 |
|
|
}
|
523 |
|
|
else if (Delay < 128) {
|
524 |
|
|
fprintf(OutFileDelay, " if (readPointer == 7'd%d) begin\n", (Delay-1));
|
525 |
|
|
fprintf(OutFileDelay, " readPointer <= 7'd0;\n");
|
526 |
|
|
fprintf(OutFileDelay, " end\n");
|
527 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
528 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 7'd1;\n");
|
529 |
|
|
}
|
530 |
|
|
else if (Delay < 256) {
|
531 |
|
|
fprintf(OutFileDelay, " if (readPointer == 8'd%d) begin\n", (Delay-1));
|
532 |
|
|
fprintf(OutFileDelay, " readPointer <= 8'd0;\n");
|
533 |
|
|
fprintf(OutFileDelay, " end\n");
|
534 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
535 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 8'd1;\n");
|
536 |
|
|
}
|
537 |
|
|
else if (Delay < 512) {
|
538 |
|
|
fprintf(OutFileDelay, " if (readPointer == 9'd%d) begin\n", (Delay-1));
|
539 |
|
|
fprintf(OutFileDelay, " readPointer <= 9'd0;\n");
|
540 |
|
|
fprintf(OutFileDelay, " end\n");
|
541 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
542 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 9'd1;\n");
|
543 |
|
|
}
|
544 |
|
|
else if (Delay < 1024) {
|
545 |
|
|
fprintf(OutFileDelay, " if (readPointer == 10'd%d) begin\n", (Delay-1));
|
546 |
|
|
fprintf(OutFileDelay, " readPointer <= 10'd0;\n");
|
547 |
|
|
fprintf(OutFileDelay, " end\n");
|
548 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
549 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 10'd1;\n");
|
550 |
|
|
}
|
551 |
|
|
else if (Delay < 2048) {
|
552 |
|
|
fprintf(OutFileDelay, " if (readPointer == 11'd%d) begin\n", (Delay-1));
|
553 |
|
|
fprintf(OutFileDelay, " readPointer <= 11'd0;\n");
|
554 |
|
|
fprintf(OutFileDelay, " end\n");
|
555 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
556 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 11'd1;\n");
|
557 |
|
|
}
|
558 |
|
|
else if (Delay < 4096) {
|
559 |
|
|
fprintf(OutFileDelay, " if (readPointer == 12'd%d) begin\n", (Delay-1));
|
560 |
|
|
fprintf(OutFileDelay, " readPointer <= 12'd0;\n");
|
561 |
|
|
fprintf(OutFileDelay, " end\n");
|
562 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
563 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 12'd1;\n");
|
564 |
|
|
}
|
565 |
|
|
else if (Delay < 8192) {
|
566 |
|
|
fprintf(OutFileDelay, " if (readPointer == 13'd%d) begin\n", (Delay-1));
|
567 |
|
|
fprintf(OutFileDelay, " readPointer <= 13'd0;\n");
|
568 |
|
|
fprintf(OutFileDelay, " end\n");
|
569 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
570 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 13'd1;\n");
|
571 |
|
|
}
|
572 |
|
|
else if (Delay < 16384) {
|
573 |
|
|
fprintf(OutFileDelay, " if (readPointer == 14'd%d) begin\n", (Delay-1));
|
574 |
|
|
fprintf(OutFileDelay, " readPointer <= 14'd0;\n");
|
575 |
|
|
fprintf(OutFileDelay, " end\n");
|
576 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
577 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 14'd1;\n");
|
578 |
|
|
}
|
579 |
|
|
else if (Delay < 32768) {
|
580 |
|
|
fprintf(OutFileDelay, " if (readPointer == 15'd%d) begin\n", (Delay-1));
|
581 |
|
|
fprintf(OutFileDelay, " readPointer <= 15'd0;\n");
|
582 |
|
|
fprintf(OutFileDelay, " end\n");
|
583 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
584 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 15'd1;\n");
|
585 |
|
|
}
|
586 |
|
|
else if (Delay < 65536) {
|
587 |
|
|
fprintf(OutFileDelay, " if (readPointer == 16'd%d) begin\n", (Delay-1));
|
588 |
|
|
fprintf(OutFileDelay, " readPointer <= 16'd0;\n");
|
589 |
|
|
fprintf(OutFileDelay, " end\n");
|
590 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
591 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 16'd1;\n");
|
592 |
|
|
}
|
593 |
|
|
else {
|
594 |
|
|
fprintf(OutFileDelay, " if (readPointer == 17'd%d) begin\n", (Delay-1));
|
595 |
|
|
fprintf(OutFileDelay, " readPointer <= 17'd0;\n");
|
596 |
|
|
fprintf(OutFileDelay, " end\n");
|
597 |
|
|
fprintf(OutFileDelay, " else begin\n");
|
598 |
|
|
fprintf(OutFileDelay, " readPointer <= readPointer + 17'd1;\n");
|
599 |
|
|
}
|
600 |
|
|
|
601 |
|
|
fprintf(OutFileDelay, " end\n");
|
602 |
|
|
fprintf(OutFileDelay, " end\n");
|
603 |
|
|
fprintf(OutFileDelay, " end\n");
|
604 |
|
|
fprintf(OutFileDelay, "\n\n\n");
|
605 |
|
|
fprintf(OutFileDelay, "endmodule\n");
|
606 |
|
|
|
607 |
|
|
|
608 |
|
|
//---------------------------------------------------------------
|
609 |
|
|
// close file
|
610 |
|
|
//---------------------------------------------------------------
|
611 |
|
|
fclose(OutFileDelay);
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
//---------------------------------------------------------------
|
615 |
|
|
// Free memory
|
616 |
|
|
//---------------------------------------------------------------
|
617 |
|
|
delete[] euclideTab;
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
|
621 |
|
|
//---------------------------------------------------------------
|
622 |
|
|
// automatically convert Dos mode To Unix mode
|
623 |
|
|
//---------------------------------------------------------------
|
624 |
|
|
char ch;
|
625 |
|
|
char temp[MAX_PATH]="\0";
|
626 |
|
|
|
627 |
|
|
//Open the file for reading in binarymode.
|
628 |
|
|
ifstream fp_read(strRsDecodeDelay, ios_base::in | ios_base::binary);
|
629 |
|
|
sprintf(temp, "%s.temp", strRsDecodeDelay);
|
630 |
|
|
//Create a temporary file for writing in the binary mode. This
|
631 |
|
|
//file will be created in the same directory as the input file.
|
632 |
|
|
ofstream fp_write(temp, ios_base::out | ios_base::trunc | ios_base::binary);
|
633 |
|
|
|
634 |
|
|
while(fp_read.eof() != true)
|
635 |
|
|
{
|
636 |
|
|
fp_read.get(ch);
|
637 |
|
|
//Check for CR (carriage return)
|
638 |
|
|
if((int)ch == 0x0D)
|
639 |
|
|
continue;
|
640 |
|
|
if (!fp_read.eof())fp_write.put(ch);
|
641 |
|
|
}
|
642 |
|
|
|
643 |
|
|
fp_read.close();
|
644 |
|
|
fp_write.close();
|
645 |
|
|
//Delete the existing input file.
|
646 |
|
|
remove(strRsDecodeDelay);
|
647 |
|
|
//Rename the temporary file to the input file.
|
648 |
|
|
rename(temp, strRsDecodeDelay);
|
649 |
|
|
//Delete the temporary file.
|
650 |
|
|
remove(temp);
|
651 |
|
|
|
652 |
|
|
|
653 |
|
|
//---------------------------------------------------------------
|
654 |
|
|
// clean string
|
655 |
|
|
//---------------------------------------------------------------
|
656 |
|
|
free(strRsDecodeDelay);
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
}
|