OpenCores
URL https://opencores.org/ocsvn/mjpeg-decoder/mjpeg-decoder/trunk

Subversion Repositories mjpeg-decoder

[/] [mjpeg-decoder/] [trunk/] [mjpeg/] [pcores/] [myipif/] [hdl/] [vhdl/] [jpeg_idct.vhd] - Blame information for rev 8

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

Line No. Rev Author Line
1 2 smanz
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
 
6
 
7
entity jpeg_idct is
8
  port
9
    (   Clk                             : in std_logic;
10
                reset_i                 : in std_logic;
11
 
12
                context_i               : in  std_logic_vector(3 downto 0);
13
                data_i                  : in  std_logic_vector(11 downto 0);
14
                context_o               : out std_logic_vector(3 downto 0);
15
                data_o                  : out std_logic_vector(8 downto 0);
16
 
17
                -- flow control
18
                datavalid_i     : in std_logic;
19
                datavalid_o     : out std_logic;
20
                ready_i                 : in  std_logic;
21
                ready_o                 : out std_logic
22
    );
23
end entity jpeg_idct;
24
 
25
 
26
 
27
 
28
 
29
architecture IMP of jpeg_idct is
30
 
31
        --------------------------------------------------------------
32
        -- IDCT-Core
33
        --------------------------------------------------------------
34
        component jpeg_idct_core_12
35
                port (
36
                ND: IN std_logic;
37
                RDY: OUT std_logic;
38
                RFD: OUT std_logic;
39
                CLK: IN std_logic;
40
                RST: IN std_logic;
41
                DIN: IN std_logic_VECTOR(11 downto 0);
42
                DOUT: OUT std_logic_VECTOR(8 downto 0));
43
        end component;
44
        --------------------------------------------------------------
45
 
46
        signal datavalid : std_logic :='0';
47
        signal ready, last_ready : std_logic :='0';
48
        signal block_counter : std_logic_vector(1 downto 0) :=(others=>'0');
49
        signal out_counter, out_counter_D : std_logic_vector(7 downto 0) :=(others=>'0');
50
        signal in_counter,  in_counter_D  : std_logic_vector(7 downto 0) :=(others=>'0');
51
        signal eoi, eoi_D : std_logic_vector(3 downto 0) :=(others=>'0');
52
        signal eoi_out, eoi_out_D : std_logic :='0';
53
        signal header_select, header_select_D : std_logic_vector(3 downto 0) :=(others=>'0');
54
        signal header_select_out, header_select_out_D : std_logic :='0';
55
        signal context : std_logic_vector(3 downto 0) := (others=>'0');
56
 
57
begin
58
 
59
        --------------------------------------------------------------
60
        -- dataflow
61
        --------------------------------------------------------------
62
        datavalid_o <= datavalid;
63
        ready_o <= ready and last_ready and ready_i;
64
        process(Clk)
65
        begin
66
                if rising_edge(Clk) then
67
                        last_ready <= ready;
68
                end if;
69
        end process;
70
        --------------------------------------------------------------
71
 
72
 
73
 
74
 
75
        --------------------------------------------------------------
76
        -- context (esp. eoi)
77
        --------------------------------------------------------------
78
        context_o <= context;
79
 
80
        -- count to see when block is finished
81
        out_counter_D   <= out_counter +1;
82
        in_counter_D    <= in_counter +1;
83
        process(Clk)
84
        begin
85
                if rising_edge(Clk) then
86
                        if reset_i='1' then
87
                                out_counter     <= (others=>'0');
88
                        elsif(datavalid='1') then
89
                                out_counter     <= out_counter_D;
90
                        end if;
91
 
92
                        if reset_i='1' then
93
                                in_counter      <= (others=>'0');
94
                        elsif(datavalid_i='1' and ready='1') then
95
                                in_counter      <= in_counter_D;
96
                        end if;
97
 
98
                end if;
99
        end process;
100
 
101
        -- remember header_select to write while block is shifted out
102
        process(context_i, in_counter, out_counter, header_select)
103
        begin
104
                header_select_D <= header_select;
105
 
106
                if in_counter(5 downto 0) = "111101" then                --      just a random counter_value less than "1111111" and greater than "000000"
107
                        case in_counter(7 downto 6) is
108
                        when "00" =>
109
                                header_select_D(0) <= context_i(1);
110
                        when "01" =>
111
                                header_select_D(1) <= context_i(1);
112
                        when "10" =>
113
                                header_select_D(2) <= context_i(1);
114
                        when others =>
115
                                header_select_D(3) <= context_i(1);
116
                        end case;
117
                end if;
118
 
119
                case out_counter(7 downto 6) is
120
                when "00" =>
121
                        header_select_out_D <= header_select(0);
122
                when "01" =>
123
                        header_select_out_D <= header_select(1);
124
                when "10" =>
125
                        header_select_out_D <= header_select(2);
126
                when others =>
127
                        header_select_out_D <= header_select(3);
128
                end case;
129
 
130
        end process;
131
 
132
        -- remember received eoi to write after block is finished
133
        process(eoi, context_i, in_counter, out_counter)
134
        begin
135
 
136
                eoi_D <= eoi;
137
                eoi_out_D <='0';
138
 
139
                if context_i(3)='1' then
140
                        case in_counter(7 downto 6) is
141
                        when "00" =>
142
                                eoi_D(0) <= '1';
143
                        when "01" =>
144
                                eoi_D(1) <= '1';
145
                        when "10" =>
146
                                eoi_D(2) <= '1';
147
                        when others =>
148
                                eoi_D(3) <= '1';
149
                        end case;
150
                elsif(out_counter(5 downto 0)="000000") then
151
                        case out_counter(7 downto 6) is
152
                        when "00" =>
153
                                eoi_D(0) <= '0';
154
                                eoi_out_D <= eoi(0);
155
                        when "01" =>
156
                                eoi_D(1) <= '0';
157
                                eoi_out_D <= eoi(1);
158
                        when "10" =>
159
                                eoi_D(2) <= '0';
160
                                eoi_out_D <= eoi(2);
161
                        when others =>
162
                                eoi_D(3) <= '0';
163
                                eoi_out_D <= eoi(3);
164
                        end case;
165
                end if;
166
 
167
        end process;
168
 
169
 
170
        process(Clk)
171
        begin
172
                if rising_edge(Clk) then
173
 
174
                        eoi                                     <= eoi_D;
175
                        eoi_out                                 <= eoi_out_D;
176
                        header_select           <= header_select_D;
177
                        header_select_out       <= header_select_out_D;
178
 
179
                        context <= '0' & context(2 downto 0);
180
 
181
                        if reset_i='1' then
182
                                eoi             <= "0000";
183
                                eoi_out <= '0';
184
                                context <= (others=>'0');
185
                                header_select           <= (others=>'0');
186
                                header_select_out       <= '0';
187
                        elsif(out_counter(5 downto 0)="000000") then
188
                                context <= eoi_out & '0' & header_select_out & '0';
189
                        end if;
190
 
191
                end if;
192
        end process;
193
 
194
        --------------------------------------------------------------
195
 
196
 
197
 
198
 
199
        --------------------------------------------------------------
200
        -- IDCT-Core
201
        --------------------------------------------------------------
202
        jpeg_idct_core_12_p : jpeg_idct_core_12
203
                        port map (
204
                        ND => datavalid_i,
205
                                RDY => datavalid,
206
                                RFD => ready,
207
                                CLK => CLK,
208
                                RST => reset_i,
209
                                DIN => data_i,
210
                                DOUT => data_o);
211
        --------------------------------------------------------------
212
 
213
end IMP;
214
 

powered by: WebSVN 2.1.0

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