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

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [design/] [zigzag/] [ZIGZAG.VHD] - Blame information for rev 67

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

Line No. Rev Author Line
1 25 mikel262
--------------------------------------------------------------------------------
2
--                                                                            --
3
--                          V H D L    F I L E                                --
4
--                          COPYRIGHT (C) 2006                                --
5
--                                                                            --
6
--------------------------------------------------------------------------------
7
--                                                                            --
8
-- Title       : ZIGZAG                                                       --
9
-- Design      : MDCT CORE                                                    --
10
-- Author      : Michal Krepa                                                 --
11
--                                                                            --
12
--------------------------------------------------------------------------------
13
--                                                                            --
14
-- File        : ZIGZAG.VHD                                                   --
15
-- Created     : Sun Sep 3 2006                                               --
16
--                                                                            --
17
--------------------------------------------------------------------------------
18
--                                                                            --
19
--  Description : Zig-Zag scan                                                --
20
--                                                                            --
21
--------------------------------------------------------------------------------
22
 
23
--------------------------------------------------------------------------------
24
 
25
library IEEE;
26
  use IEEE.STD_LOGIC_1164.All;
27
  use IEEE.NUMERIC_STD.all;
28
 
29
entity zigzag is
30
  generic
31
    (
32
      RAMADDR_W     : INTEGER := 6;
33
      RAMDATA_W     : INTEGER := 12
34
    );
35
  port
36
    (
37
      rst        : in  STD_LOGIC;
38
      clk        : in  STD_LOGIC;
39
      di         : in  STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0);
40
      divalid    : in  STD_LOGIC;
41
      rd_addr    : in  unsigned(5 downto 0);
42
      fifo_rden  : in  std_logic;
43
 
44
      fifo_empty : out std_logic;
45
      dout       : out STD_LOGIC_VECTOR(RAMDATA_W-1 downto 0);
46
      dovalid    : out std_logic;
47
      zz_rd_addr : out STD_LOGIC_VECTOR(5 downto 0)
48
    );
49
end zigzag;
50
 
51
architecture rtl of zigzag is
52
 
53
  type ZIGZAG_TYPE is   array (0 to 2**RAMADDR_W-1) of INTEGER range 0 to 2**RAMADDR_W-1;
54
  constant ZIGZAG_ARRAY : ZIGZAG_TYPE :=
55
                      (
56
                       0,1,8,16,9,2,3,10,
57
                       17,24,32,25,18,11,4,5,
58
                       12,19,26,33,40,48,41,34,
59
                       27,20,13,6,7,14,21,28,
60
                       35,42,49,56,57,50,43,36,
61
                       29,22,15,23,30,37,44,51,
62
                       58,59,52,45,38,31,39,46,
63
                       53,60,61,54,47,55,62,63
64
                      );
65
 
66
  signal fifo_wr      : std_logic;
67
  signal fifo_q       : std_logic_vector(11 downto 0);
68
  signal fifo_full    : std_logic;
69
  signal fifo_count   : std_logic_vector(6 downto 0);
70
  signal fifo_data_in : std_logic_vector(11 downto 0);
71
  signal fifo_empty_s : std_logic;
72
 
73
 
74
begin
75
 
76
  dout <= fifo_q;
77
  fifo_empty <= fifo_empty_s;
78
 
79
  -------------------------------------------------------------------
80
  -- FIFO (show ahead)
81
  -------------------------------------------------------------------
82
  U_FIFO : entity work.FIFO
83
  generic map
84
  (
85
        DATA_WIDTH        => 12,
86
        ADDR_WIDTH        => 6
87
  )
88
  port map
89
  (
90
        rst               => RST,
91
        clk               => CLK,
92
        rinc              => fifo_rden,
93
        winc              => fifo_wr,
94
        datai             => fifo_data_in,
95
 
96
        datao             => fifo_q,
97
        fullo             => fifo_full,
98
        emptyo            => fifo_empty_s,
99
        count             => fifo_count
100
  );
101
 
102
  fifo_wr      <= divalid;
103
  fifo_data_in <= di;
104
 
105
 
106
  process(clk)
107
  begin
108
    if clk = '1' and clk'event then
109
      if rst = '1' then
110
        zz_rd_addr <= (others => '0');
111
        dovalid    <= '0';
112
      else
113
        zz_rd_addr <= std_logic_vector(
114
                      to_unsigned((ZIGZAG_ARRAY(to_integer(rd_addr))),6));
115
 
116
        dovalid    <= fifo_rden and not fifo_empty_s;
117
      end if;
118
    end if;
119
  end process;
120
 
121
 
122
end rtl;
123
--------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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