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

Subversion Repositories djpeg

[/] [djpeg/] [trunk/] [testbench/] [jpeg_test.v] - Blame information for rev 10

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

Line No. Rev Author Line
1 2 hidemi
//---------------------------------------------------------------------------
2
// File Name   : jpeg_test.v
3
// Module Name : jpeg_test
4
// Description : TestBench
5
// Project     : JPEG Decoder
6
// Belong to   : 
7
// Author      : H.Ishihara
8
// E-Mail      : hidemi@sweetcafe.jp
9
// HomePage    : http://www.sweetcafe.jp/
10
// Date        : 2006/10/01
11
// Rev.        : 1.1
12
//---------------------------------------------------------------------------
13
// Rev. Date       Description
14
//---------------------------------------------------------------------------
15
// 1.01 2006/10/01 1st Release
16
//---------------------------------------------------------------------------
17
// $Id: 
18
//---------------------------------------------------------------------------
19
`timescale 1ps / 1ps
20
 
21
module jpeg_test;
22
   reg rst;
23
   reg clk;
24
 
25
   reg [31:0] JPEG_MEM [0:1*1024*1024-1];
26
 
27
   integer    DATA_COUNT;
28
 
29
   parameter clkP = 10000; // 100MHz
30
   parameter clkH = clkP /2;
31
   parameter clkL = clkP - clkH;
32
 
33
   wire [31:0] JPEG_DATA;
34
   reg         DATA_ENABLE;
35
   wire        READ_ENABLE;
36
   wire        JPEG_IDLE;
37
 
38
   wire        OutEnable;
39
   wire [15:0] OutWidth;
40
   wire [15:0] OutHeight;
41
   wire [15:0] OutPixelX;
42
   wire [15:0] OutPixelY;
43
   wire [7:0]  OutR;
44
   wire [7:0]  OutG;
45
   wire [7:0]  OutB;
46
 
47
   integer     count;
48
   reg [23:0]  rgb_mem [0:1920*1080-1];
49
 
50
   initial begin
51
      count = 0;
52
      while(1) begin
53
         @(posedge clk);
54
         count = count +1;
55
      end
56
   end
57
 
58
   jpeg_decode u_jpeg_decode
59
     (
60
      .rst(rst),
61
      .clk(clk),
62
 
63
      .DataIn          (JPEG_DATA),
64
      .DataInEnable    (DATA_ENABLE),
65
      .DataInRead      (READ_ENABLE),
66
      .JpegDecodeIdle  (JPEG_IDLE),
67
 
68
      .OutEnable ( OutEnable ),
69
      .OutWidth  ( OutWidth  ),
70
      .OutHeight ( OutHeight ),
71
      .OutPixelX ( OutPixelX ),
72
      .OutPixelY ( OutPixelY ),
73
      .OutR      ( OutR      ),
74
      .OutG      ( OutG      ),
75
      .OutB      ( OutB      )
76
      );
77
 
78
 
79
   // Clock
80
   always begin
81
      #clkH clk = 0;
82
      #clkL clk = 1;
83
   end
84
 
85
   initial begin
86
      rst = 1'b0;
87
      repeat (3) @(posedge clk);
88
      rst = 1'b1;
89
   end
90
 
91
   // Read JPEG File
92
   initial begin
93
      $readmemh("test.mem",JPEG_MEM);
94
   end
95
 
96
   // Initial
97
   initial begin
98
      DATA_COUNT  <= 0;
99
      DATA_ENABLE <= 1'b0;
100
      wait (rst == 1'b1);
101
      @(posedge clk);
102
      $display(" Start Clock: %d",count);
103
      @(posedge clk);
104
      @(posedge clk);
105
      DATA_ENABLE <= 1'b1;
106
      forever begin
107
         if(READ_ENABLE == 1'b1) begin
108
            DATA_COUNT  <= DATA_COUNT +1;
109
         end
110
         @(posedge clk);
111
      end
112
   end // initial begin
113
 
114
   assign JPEG_DATA = JPEG_MEM[DATA_COUNT];
115
 
116
   integer i;
117
 
118
/*
119
   initial begin
120
      @(posedge u_jpeg_decode.ImageEnable);
121
 
122
      $display("------------------------------");
123
      $display("Image Run");
124
      $display("------------------------------");
125
      $display(" DQT Y Table");
126
      for(i=0;i<64;i=i+1) begin
127
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dqt.DQT_Y[i]);
128
      end
129
 
130
      $display("------------------------------");
131
      $display(" DQT Cb/Cr Table");
132
      for(i=0;i<64;i=i+1) begin
133
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dqt.DQT_C[i]);
134
      end
135
      $display("------------------------------");
136
 
137
      $display("------------------------------");
138
      $display(" Haffuman Y-DC Code/Number");
139
      for(i=0;i<16;i=i+1) begin
140
         $display(" %2d: %2x,%2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanTable0r[i],u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanNumber0r[i]);
141
      end
142
      $display("------------------------------");
143
 
144
      $display("------------------------------");
145
      $display(" Haffuman Y-DC Table");
146
      for(i=0;i<16;i=i+1) begin
147
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dht.DHT_Ydc[i]);
148
      end
149
      $display("------------------------------");
150
 
151
      $display("------------------------------");
152
      $display(" Haffuman Y-AC Code/Number");
153
      for(i=0;i<16;i=i+1) begin
154
         $display(" %2d: %2x,%2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanTable1r[i],u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanNumber1r[i]);
155
      end
156
      $display("------------------------------");
157
 
158
      $display("------------------------------");
159
      $display(" Haffuman Y-AC Table");
160
      for(i=0;i<162;i=i+1) begin
161
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dht.DHT_Yac[i]);
162
      end
163
      $display("------------------------------");
164
 
165
      $display("------------------------------");
166
      $display(" Haffuman C-DC Table");
167
      for(i=0;i<16;i=i+1) begin
168
         $display(" %2d: %2x,%2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanTable2r[i],u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanNumber2r[i]);
169
      end
170
      $display("------------------------------");
171
 
172
      $display("------------------------------");
173
      $display(" Haffuman C-DC Table");
174
      for(i=0;i<16;i=i+1) begin
175
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dht.DHT_Cdc[i]);
176
      end
177
      $display("------------------------------");
178
 
179
      $display("------------------------------");
180
      $display(" Haffuman C-AC Table");
181
      for(i=0;i<16;i=i+1) begin
182
         $display(" %2d: %2x,%2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanTable3r[i],u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanNumber3r[i]);
183
      end
184
      $display("------------------------------");
185
 
186
      $display("------------------------------");
187
      $display(" Haffuman C-AC Table");
188
      for(i=0;i<162;i=i+1) begin
189
         $display(" %2d: %2x",i,u_jpeg_decode.u_jpeg_haffuman.u_jpeg_dht.DHT_Cac[i]);
190
      end
191
      $display("------------------------------");
192
   end
193
*/
194
/*
195
   initial begin
196
      while(1) begin
197
         @(posedge clk);
198
         if(u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.Process == 4'h2)
199
           $display(" Color: %d,%d",u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.ProcessColor,
200
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.ProcessCount);
201
      end
202
   end
203
 
204
 
205
   initial begin
206
      while(1) begin
207
         @(posedge clk);
208
         if(u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.Process == 4'h4)
209
           for(i=0;i<16;i=i+1) begin
210
              $display(" Data Code: %8x,%8x",u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanTable[i],u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.HaffumanNumber[i]);
211
           end
212
      end
213
   end
214
*/
215
 
216
/*
217
   initial begin
218
      while(1) begin
219
         @(posedge clk);
220
         if(u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.Process == 4'h6)
221
           $display(" Wait for RAM");
222
      end
223
   end
224
*/
225
/*
226
   initial begin
227
      while(1) begin
228
         @(posedge clk);
229
         if(u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.Process == 4'h4)
230
           $display(" Data Code: %8x",u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.ProcessData);
231
      end
232
   end
233
*/
234
/*
235
   initial begin
236
      while(1) begin
237
         @(posedge clk);
238
         if(u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.Process == 4'hB)
239
           $display(" Data Code: %d,%d,%4x,%4x,%4x,%4x,%2x,%4x,%4x,%4x,%8x",
240
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.CodeNumber,
241
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.ProcessCount,
242
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.DhtNumber,
243
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.DhtZero,
244
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.DataNumber,
245
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.TableCode,
246
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.NumberCode,
247
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.DqtData,
248
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.OutCode,
249
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.OutData,
250
                    u_jpeg_decode.u_jpeg_haffuman.u_jpeg_hm_decode.ProcessData);
251
      end
252
   end
253
 
254
 
255
 
256
   initial begin
257
      while(1) begin
258
         @(posedge clk);
259
         if(u_jpeg_decode.u_jpeg_haffuman.HmDecEnable == 1'b1)
260
              $display(" HmDec Code: %d,%4x",
261
                       u_jpeg_decode.u_jpeg_haffuman.HmDecCount,
262
                       u_jpeg_decode.u_jpeg_haffuman.HmDecData);
263
      end
264
   end
265
*/
266
 
267
/*
268
   initial begin
269
      while(1) begin
270
         @(posedge clk);
271
         if(u_jpeg_decode.u_jpeg_haffuman.HmOutEnable == 1'b1)
272
           for(i=0;i<64;i=i+1) begin
273
              $display(" Data Code: %d,%4x",i,
274
                       u_jpeg_decode.u_jpeg_haffuman.u_jpeg_ziguzagu.RegData[i]);
275
           end
276
      end
277
   end
278
*/
279
 
280
/*
281
   initial begin
282
      while(1) begin
283
         @(posedge clk);
284
         if(u_jpeg_decode.u_jpeg_idct.DctXEnable == 1'b1)
285
           $display(" Dct Data[X]: %d,%4x,%4x",u_jpeg_decode.u_jpeg_idct.DctXCount,u_jpeg_decode.u_jpeg_idct.DctXData0r,u_jpeg_decode.u_jpeg_idct.DctXData1r);
286
      end
287
   end
288
 
289
   initial begin
290
      while(1) begin
291
         @(posedge clk);
292
         if(u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Enable == 1'b1)
293
           $display(" Dct Data[Y2]: %d,%8x,%8x,%8x,%8x,%8x,%8x,%8x,%8x",u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Count,u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[0],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[1],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[2],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[3],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[4],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[5],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[6],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase2Reg[7]);
294
      end
295
   end
296
 
297
   initial begin
298
      while(1) begin
299
         @(posedge clk);
300
         if(u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase5Enable == 1'b1)
301
           $display(" Dct Data[Y5]: %d,%8x,%8x,%8x,%8x,%8x,%8x,%8x,%8x,%8x,%8x",u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase5Count,u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase5R0w,u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase5R1w,u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[0],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[1],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[2],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[3],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[4],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[5],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[6],u_jpeg_decode.u_jpeg_idct.u_jpeg_idcty.Phase3Reg[7]);
302
      end
303
   end
304
 
305
 
306
 
307
   initial begin
308
      while(1) begin
309
         @(posedge clk);
310
         if(u_jpeg_decode.DctEnable == 1'b1)
311
           $display(" Dct Data[Y]: %d,%4x,%4x",u_jpeg_decode.DctCount,u_jpeg_decode.Dct0Data,u_jpeg_decode.Dct1Data);
312
      end
313
   end
314
*/
315
 
316
   integer address;
317
   integer fp;
318
 
319
   initial begin
320
 
321
      while(1) begin
322
         if(u_jpeg_decode.OutEnable == 1'b1) begin
323 5 hidemi
            address = u_jpeg_decode.OutWidth * u_jpeg_decode.OutPixelY +
324 2 hidemi
                      u_jpeg_decode.OutPixelX;
325 5 hidemi
            /*
326 2 hidemi
            $display(" RGB[%4d,%4d,%4d,%4d](%d): %3x,%3x,%3x = %2x,%2x,%2x",OutPixelX,OutPixelY,u_jpeg_decode.OutWidth,u_jpeg_decode.OutHeight,
327 5 hidemi
                    address,
328
                    u_jpeg_decode.u_jpeg_ycbcr.u_jpeg_ycbcr2rgb.Phase3Y,
329
                    u_jpeg_decode.u_jpeg_ycbcr.u_jpeg_ycbcr2rgb.Phase3Cb,
330
                    u_jpeg_decode.u_jpeg_ycbcr.u_jpeg_ycbcr2rgb.Phase3Cr,
331 2 hidemi
                    OutR,OutG,OutB);
332 5 hidemi
             */
333 2 hidemi
            rgb_mem[address] = {OutR,OutG,OutB};
334
         end
335
         @(posedge clk);
336
      end
337
   end
338
 
339
 
340
   initial begin
341 5 hidemi
      wait(!JPEG_IDLE);
342
      wait(JPEG_IDLE);
343
 
344 2 hidemi
      $display(" End Clock %d",count);
345
      fp = $fopen("sim.dat");
346
      $fwrite(fp,"%0d\n",OutWidth);
347
      $fwrite(fp,"%0d\n",OutHeight);
348
 
349
      for(i=0;i<OutWidth*OutHeight;i=i+1) begin
350
         $fwrite(fp,"%06x\n",rgb_mem[i]);
351
      end
352
      $fclose(fp);
353
 
354
      $finish();
355
   end
356
 
357
 
358
 
359
 
360
endmodule // jpeg_test

powered by: WebSVN 2.1.0

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