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

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [design/] [top/] [JpegEnc.vhd] - Blame information for rev 28

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

Line No. Rev Author Line
1 25 mikel262
-------------------------------------------------------------------------------
2
-- File Name : JpegEnc.vhd
3
--
4
-- Project   : JPEG_ENC
5
--
6
-- Module    : JpegEnc
7
--
8
-- Content   : JPEG Encoder Top Level
9
--
10
-- Description : 
11
--
12
-- Spec.     : 
13
--
14
-- Author    : Michal Krepa
15
--
16
-------------------------------------------------------------------------------
17
-- History :
18
-- 20090301: (MK): Initial Creation.
19
-------------------------------------------------------------------------------
20
 
21
-------------------------------------------------------------------------------
22
-------------------------------------------------------------------------------
23
----------------------------------- LIBRARY/PACKAGE ---------------------------
24
-------------------------------------------------------------------------------
25
-------------------------------------------------------------------------------
26
 
27
-------------------------------------------------------------------------------
28
-- generic packages/libraries:
29
-------------------------------------------------------------------------------
30
library ieee;
31
  use ieee.std_logic_1164.all;
32
  use ieee.numeric_std.all;
33
 
34
-------------------------------------------------------------------------------
35
-- user packages/libraries:
36
-------------------------------------------------------------------------------
37
library work;
38
  use work.JPEG_PKG.all;
39
-------------------------------------------------------------------------------
40
-------------------------------------------------------------------------------
41
----------------------------------- ENTITY ------------------------------------
42
-------------------------------------------------------------------------------
43
-------------------------------------------------------------------------------
44
entity JpegEnc is
45
  port
46
  (
47
        CLK                : in  std_logic;
48
        RST                : in  std_logic;
49
 
50
        -- OPB
51
        OPB_ABus           : in  std_logic_vector(31 downto 0);
52
        OPB_BE             : in  std_logic_vector(3 downto 0);
53
        OPB_DBus_in        : in  std_logic_vector(31 downto 0);
54
        OPB_RNW            : in  std_logic;
55
        OPB_select         : in  std_logic;
56
        OPB_DBus_out       : out std_logic_vector(31 downto 0);
57
        OPB_XferAck        : out std_logic;
58
        OPB_retry          : out std_logic;
59
        OPB_toutSup        : out std_logic;
60
        OPB_errAck         : out std_logic;
61
 
62
        -- IMAGE RAM
63
        iram_wdata         : in  std_logic_vector(23 downto 0);
64
        iram_wren          : in  std_logic;
65
        iram_fifo_afull    : out std_logic;
66
 
67
        -- OUT RAM
68
        ram_byte           : out std_logic_vector(7 downto 0);
69
        ram_wren           : out std_logic;
70
        ram_wraddr         : out std_logic_vector(23 downto 0)
71
    );
72
end entity JpegEnc;
73
 
74
-------------------------------------------------------------------------------
75
-------------------------------------------------------------------------------
76
----------------------------------- ARCHITECTURE ------------------------------
77
-------------------------------------------------------------------------------
78
-------------------------------------------------------------------------------
79
architecture RTL of JpegEnc is
80
 
81
  signal qdata              : std_logic_vector(7 downto 0);
82
  signal qaddr              : std_logic_vector(5 downto 0);
83
  signal qwren              : std_logic;
84
  signal jpeg_ready         : std_logic;
85
  signal jpeg_busy          : std_logic;
86
  signal outram_base_addr   : std_logic_vector(9 downto 0);
87
  signal num_enc_bytes      : std_logic_vector(23 downto 0);
88
  signal img_size_x         : std_logic_vector(15 downto 0);
89
  signal img_size_y         : std_logic_vector(15 downto 0);
90
  signal sof                : std_logic;
91
  signal jpg_iram_rden      : std_logic;
92
  signal jpg_iram_rdaddr    : std_logic_vector(31 downto 0);
93
  signal jpg_iram_rdata     : std_logic_vector(23 downto 0);
94
  signal fdct_start         : std_logic;
95
  signal fdct_ready         : std_logic;
96
  signal zig_start          : std_logic;
97
  signal zig_ready          : std_logic;
98
  signal rle_start          : std_logic;
99
  signal rle_ready          : std_logic;
100
  signal huf_start          : std_logic;
101
  signal huf_ready          : std_logic;
102
  signal bs_start           : std_logic;
103
  signal bs_ready           : std_logic;
104
  signal zz_buf_sel         : std_logic;
105
  signal zz_rd_addr         : std_logic_vector(5 downto 0);
106
  signal zz_data            : std_logic_vector(11 downto 0);
107
  signal rle_buf_sel        : std_logic;
108
  signal rle_rdaddr         : std_logic_vector(5 downto 0);
109
  signal rle_data           : std_logic_vector(11 downto 0);
110
  signal huf_buf_sel        : std_logic;
111
  signal huf_rdaddr         : std_logic_vector(5 downto 0);
112
  signal huf_rden           : std_logic;
113
  signal huf_runlength      : std_logic_vector(3 downto 0);
114
  signal huf_size           : std_logic_vector(3 downto 0);
115
  signal huf_amplitude      : std_logic_vector(11 downto 0);
116
  signal huf_dval           : std_logic;
117
  signal bs_buf_sel         : std_logic;
118
  signal bs_fifo_empty      : std_logic;
119
  signal bs_rd_req          : std_logic;
120
  signal bs_packed_byte     : std_logic_vector(7 downto 0);
121
  signal huf_fifo_empty     : std_logic;
122
  signal zz_rden            : std_logic;
123
  signal fdct_sm_settings   : T_SM_SETTINGS;
124
  signal zig_sm_settings    : T_SM_SETTINGS;
125
  signal rle_sm_settings    : T_SM_SETTINGS;
126
  signal huf_sm_settings    : T_SM_SETTINGS;
127
  signal bs_sm_settings     : T_SM_SETTINGS;
128
  signal cmp_max            : std_logic_vector(1 downto 0);
129
  signal image_size_reg     : std_logic_vector(31 downto 0);
130
  signal jfif_ram_byte      : std_logic_vector(7 downto 0);
131
  signal jfif_ram_wren      : std_logic;
132
  signal jfif_ram_wraddr    : std_logic_vector(23 downto 0);
133
  signal out_mux_ctrl       : std_logic;
134
  signal img_size_wr        : std_logic;
135
  signal jfif_start         : std_logic;
136
  signal jfif_ready         : std_logic;
137
  signal bs_ram_byte        : std_logic_vector(7 downto 0);
138
  signal bs_ram_wren        : std_logic;
139
  signal bs_ram_wraddr      : std_logic_vector(23 downto 0);
140
  signal jfif_eoi           : std_logic;
141
  signal fdct_block_cnt     : std_logic_vector(12 downto 0);
142
  signal fdct_fifo_rd       : std_logic;
143
  signal fdct_fifo_empty    : std_logic;
144
  signal fdct_fifo_q        : std_logic_vector(23 downto 0);
145
  signal fdct_fifo_hf_full  : std_logic;
146
 
147
-------------------------------------------------------------------------------
148
-- Architecture: begin
149
-------------------------------------------------------------------------------
150
begin
151
 
152
  -------------------------------------------------------------------
153
  -- Host Interface
154
  -------------------------------------------------------------------
155
  U_HostIF : entity work.HostIF
156
  port map
157
  (
158
        CLK                => CLK,
159
        RST                => RST,
160
        -- OPB
161
        OPB_ABus           => OPB_ABus,
162
        OPB_BE             => OPB_BE,
163
        OPB_DBus_in        => OPB_DBus_in,
164
        OPB_RNW            => OPB_RNW,
165
        OPB_select         => OPB_select,
166
        OPB_DBus_out       => OPB_DBus_out,
167
        OPB_XferAck        => OPB_XferAck,
168
        OPB_retry          => OPB_retry,
169
        OPB_toutSup        => OPB_toutSup,
170
        OPB_errAck         => OPB_errAck,
171
 
172
        -- Quantizer RAM
173
        qdata              => qdata,
174
        qaddr              => qaddr,
175
        qwren              => qwren,
176
 
177
        -- CTRL
178
        jpeg_ready         => jpeg_ready,
179
        jpeg_busy          => jpeg_busy,
180
 
181
        -- ByteStuffer
182
        outram_base_addr   => outram_base_addr,
183
        num_enc_bytes      => num_enc_bytes,
184
 
185
        -- global
186
        img_size_x         => img_size_x,
187
        img_size_y         => img_size_y,
188
        img_size_wr        => img_size_wr,
189
        sof                => sof,
190
        cmp_max            => cmp_max
191
    );
192
 
193
  -------------------------------------------------------------------
194
  -- BUF_FIFO
195
  -------------------------------------------------------------------
196
  U_BUF_FIFO : entity work.BUF_FIFO
197
  port map
198
  (
199
        CLK                => CLK,
200
        RST                => RST,
201
        -- HOST PROG
202
        img_size_x         => img_size_x,
203
        img_size_y         => img_size_y,
204
        sof                => sof,
205
 
206
        -- HOST DATA
207
        iram_wren          => iram_wren,
208
        iram_wdata         => iram_wdata,
209
        fifo_almost_full   => iram_fifo_afull,
210
 
211
        -- FDCT
212
        fdct_block_cnt     => fdct_block_cnt,
213
        fdct_fifo_rd       => fdct_fifo_rd,
214
        fdct_fifo_empty    => fdct_fifo_empty,
215
        fdct_fifo_q        => fdct_fifo_q,
216
        fdct_fifo_hf_full  => fdct_fifo_hf_full
217
    );
218
 
219
  -------------------------------------------------------------------
220
  -- Controller
221
  -------------------------------------------------------------------
222
  U_CtrlSM : entity work.CtrlSM
223
  port map
224
  (
225
        CLK                => CLK,
226
        RST                => RST,
227
 
228
        -- HOST IF
229
        sof                => sof,
230
        img_size_x         => img_size_x,
231
        img_size_y         => img_size_y,
232
        jpeg_ready         => jpeg_ready,
233
        jpeg_busy          => jpeg_busy,
234
        cmp_max            => cmp_max,
235
 
236
        -- FDCT
237
        fdct_start         => fdct_start,
238
        fdct_ready         => fdct_ready,
239
        fdct_sm_settings   => fdct_sm_settings,
240
 
241
        -- ZIGZAG
242
        zig_start          => zig_start,
243
        zig_ready          => zig_ready,
244
        zig_sm_settings    => zig_sm_settings,
245
 
246
        -- RLE
247
        rle_start          => rle_start,
248
        rle_ready          => rle_ready,
249
        rle_sm_settings    => rle_sm_settings,
250
 
251
        -- Huffman
252
        huf_start          => huf_start,
253
        huf_ready          => huf_ready,
254
        huf_sm_settings    => huf_sm_settings,
255
 
256
        -- ByteStuffdr
257
        bs_start           => bs_start,
258
        bs_ready           => bs_ready,
259
        bs_sm_settings     => bs_sm_settings,
260
 
261
        -- JFIF GEN
262
        jfif_start         => jfif_start,
263
        jfif_ready         => jfif_ready,
264
        jfif_eoi           => jfif_eoi,
265
 
266
        -- OUT MUX         
267
        out_mux_ctrl       => out_mux_ctrl
268
    );
269
 
270
  -------------------------------------------------------------------
271
  -- FDCT
272
  -------------------------------------------------------------------
273
  U_FDCT : entity work.FDCT
274
  port map
275
  (
276
        CLK                => CLK,
277
        RST                => RST,
278
        -- CTRL
279
        start_pb           => fdct_start,
280
        ready_pb           => fdct_ready,
281
        fdct_sm_settings   => fdct_sm_settings,
282
 
283
        -- BUF_FIFO
284
        bf_block_cnt       => fdct_block_cnt,
285
        bf_fifo_rd         => fdct_fifo_rd,
286
        bf_fifo_empty      => fdct_fifo_empty,
287
        bf_fifo_q          => fdct_fifo_q,
288
        bf_fifo_hf_full    => fdct_fifo_hf_full,
289
 
290
        -- ZIG ZAG
291
        zz_buf_sel         => zz_buf_sel,
292
        zz_rd_addr         => zz_rd_addr,
293
        zz_data            => zz_data,
294
        zz_rden            => zz_rden,
295
 
296
        -- HOST
297
        img_size_x         => img_size_x,
298
        img_size_y         => img_size_y,
299
        sof                => sof
300
    );
301
 
302
  -------------------------------------------------------------------
303
  -- ZigZag top level
304
  -------------------------------------------------------------------
305
  U_ZZ_TOP : entity work.ZZ_TOP
306
  port map
307
  (
308
        CLK                => CLK,
309
        RST                => RST,
310
        -- CTRL
311
        start_pb           => zig_start,
312
        ready_pb           => zig_ready,
313
 
314
        -- RLE
315
        rle_buf_sel        => rle_buf_sel,
316
        rle_rdaddr         => rle_rdaddr,
317
        rle_data           => rle_data,
318
 
319
        -- FDCT
320
        fdct_buf_sel       => zz_buf_sel,
321
        fdct_rd_addr       => zz_rd_addr,
322
        fdct_data          => zz_data,
323
        fdct_rden          => zz_rden,
324
 
325
        -- HOST
326
        qdata              => qdata,
327
        qaddr              => qaddr,
328
        qwren              => qwren
329
    );
330
 
331
  -------------------------------------------------------------------
332
  -- RLE TOP
333
  -------------------------------------------------------------------
334
  U_RLE_TOP : entity work.RLE_TOP
335
  port map
336
  (
337
        CLK                => CLK,
338
        RST                => RST,
339
        -- CTRL
340
        start_pb           => rle_start,
341
        ready_pb           => rle_ready,
342
        rle_sm_settings    => rle_sm_settings,
343
 
344
        -- HUFFMAN
345
        huf_buf_sel        => huf_buf_sel,
346
        huf_rden           => huf_rden,
347
        huf_runlength      => huf_runlength,
348
        huf_size           => huf_size,
349
        huf_amplitude      => huf_amplitude,
350
        huf_dval           => huf_dval,
351
        huf_fifo_empty     => huf_fifo_empty,
352
 
353
        -- ZIGZAG
354
        zig_buf_sel        => rle_buf_sel,
355
        zig_rd_addr        => rle_rdaddr,
356
        zig_data           => rle_data,
357
 
358
        -- HostIF
359
        sof                => sof
360
    );
361
 
362
  -------------------------------------------------------------------
363
  -- Huffman Encoder
364
  -------------------------------------------------------------------
365
  U_Huffman : entity work.Huffman
366
  port map
367
  (
368
        CLK                => CLK,
369
        RST                => RST,
370
        -- CTRL
371
        start_pb           => huf_start,
372
        ready_pb           => huf_ready,
373
 
374
        -- HOST IF
375
        sof                => sof,
376
        img_size_x         => img_size_x,
377
        img_size_y         => img_size_y,
378
        cmp_max            => cmp_max,
379
 
380
        -- RLE
381
        rle_buf_sel        => huf_buf_sel,
382
        rd_en              => huf_rden,
383
        runlength          => huf_runlength,
384
        VLI_size           => huf_size,
385
        VLI                => huf_amplitude,
386
        d_val              => huf_dval,
387
        rle_fifo_empty     => huf_fifo_empty,
388
 
389
 
390
        -- Byte Stuffer
391
        bs_buf_sel         => bs_buf_sel,
392
        bs_fifo_empty      => bs_fifo_empty,
393
        bs_rd_req          => bs_rd_req,
394
        bs_packed_byte     => bs_packed_byte
395
    );
396
 
397
 
398
  -------------------------------------------------------------------
399
  -- Byte Stuffer
400
  -------------------------------------------------------------------
401
  U_ByteStuffer : entity work.ByteStuffer
402
  port map
403
  (
404
        CLK                => CLK,
405
        RST                => RST,
406
        -- CTRL
407
        start_pb           => bs_start,
408
        ready_pb           => bs_ready,
409
 
410
        -- HOST IF
411
        sof                => sof,
412
        num_enc_bytes      => num_enc_bytes,
413
        outram_base_addr   => outram_base_addr,
414
 
415
        -- Huffman
416
        huf_buf_sel        => bs_buf_sel,
417
        huf_fifo_empty     => bs_fifo_empty,
418
        huf_rd_req         => bs_rd_req,
419
        huf_packed_byte    => bs_packed_byte,
420
 
421
        -- OUT RAM
422
        ram_byte           => bs_ram_byte,
423
        ram_wren           => bs_ram_wren,
424
        ram_wraddr         => bs_ram_wraddr
425
    );
426
 
427
  -------------------------------------------------------------------
428
  -- JFIF Generator
429
  -------------------------------------------------------------------
430
  U_JFIFGen : entity work.JFIFGen
431
  port map
432
  (
433
        CLK                => CLK,
434
        RST                => RST,
435
        -- CTRL
436
        start              => jfif_start,
437
        ready              => jfif_ready,
438
        eoi                => jfif_eoi,
439
 
440
        -- ByteStuffer
441
        num_enc_bytes         => num_enc_bytes,
442
 
443
        -- HOST IF
444
        qwren              => qwren,
445
        qwaddr             => qaddr,
446
        qwdata             => qdata,
447
        image_size_reg     => image_size_reg,
448
        image_size_reg_wr  => img_size_wr,
449
 
450
        -- OUT RAM
451
        ram_byte           => jfif_ram_byte,
452
        ram_wren           => jfif_ram_wren,
453
        ram_wraddr         => jfif_ram_wraddr
454
    );
455
 
456
  image_size_reg <= img_size_x & img_size_y;
457
 
458
  -------------------------------------------------------------------
459
  -- OutMux
460
  -------------------------------------------------------------------
461
  U_OutMux : entity work.OutMux
462
  port map
463
  (
464
        CLK                => CLK,
465
        RST                => RST,
466
        -- CTRL
467
        out_mux_ctrl       => out_mux_ctrl,
468
 
469
        -- ByteStuffer
470
        bs_ram_byte        => bs_ram_byte,
471
        bs_ram_wren        => bs_ram_wren,
472
        bs_ram_wraddr      => bs_ram_wraddr,
473
        -- ByteStuffer
474
        jfif_ram_byte      => jfif_ram_byte,
475
        jfif_ram_wren      => jfif_ram_wren,
476
        jfif_ram_wraddr    => jfif_ram_wraddr,
477
 
478
        -- OUT RAM
479
        ram_byte           => ram_byte,
480
        ram_wren           => ram_wren,
481
        ram_wraddr         => ram_wraddr
482
    );
483
 
484
 
485
end architecture RTL;
486
-------------------------------------------------------------------------------
487
-- Architecture: end
488
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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