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

Subversion Repositories mkjpeg

[/] [mkjpeg/] [trunk/] [design/] [hostif/] [HostIF.vhd] - Blame information for rev 62

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

Line No. Rev Author Line
1 25 mikel262
-------------------------------------------------------------------------------
2
-- File Name : HostIF.vhd
3
--
4
-- Project   : JPEG_ENC
5
--
6
-- Module    : HostIF
7
--
8
-- Content   : Host Interface (Xilinx OPB v2.1)
9
--
10
-- Description : 
11
--
12
-- Spec.     : 
13
--
14
-- Author    : Michal Krepa
15
--
16
-------------------------------------------------------------------------------
17
-- History :
18
-- 20090301: (MK): Initial Creation.
19
-------------------------------------------------------------------------------
20
 
21
library ieee;
22
  use ieee.std_logic_1164.all;
23
  use ieee.numeric_std.all;
24
 
25
entity HostIF is
26
  port
27
  (
28
        CLK                : in  std_logic;
29
        RST                : in  std_logic;
30
        -- OPB
31
        OPB_ABus           : in  std_logic_vector(31 downto 0);
32
        OPB_BE             : in  std_logic_vector(3 downto 0);
33
        OPB_DBus_in        : in  std_logic_vector(31 downto 0);
34
        OPB_RNW            : in  std_logic;
35
        OPB_select         : in  std_logic;
36
        OPB_DBus_out       : out std_logic_vector(31 downto 0);
37
        OPB_XferAck        : out std_logic;
38
        OPB_retry          : out std_logic;
39
        OPB_toutSup        : out std_logic;
40
        OPB_errAck         : out std_logic;
41
 
42
        -- Quantizer RAM
43
        qdata              : out std_logic_vector(7 downto 0);
44 32 mikel262
        qaddr              : out std_logic_vector(6 downto 0);
45 25 mikel262
        qwren              : out std_logic;
46
 
47
        -- CTRL
48
        jpeg_ready         : in  std_logic;
49
        jpeg_busy          : in  std_logic;
50
 
51
        -- ByteStuffer
52
        outram_base_addr   : out std_logic_vector(9 downto 0);
53
        num_enc_bytes      : in  std_logic_vector(23 downto 0);
54
 
55
        -- others
56
        img_size_x         : out std_logic_vector(15 downto 0);
57
        img_size_y         : out std_logic_vector(15 downto 0);
58
        img_size_wr        : out std_logic;
59 61 mikel262
        sof                : out std_logic
60 25 mikel262
 
61
    );
62
end entity HostIF;
63
 
64
-------------------------------------------------------------------------------
65
-------------------------------------------------------------------------------
66
----------------------------------- ARCHITECTURE ------------------------------
67
-------------------------------------------------------------------------------
68
-------------------------------------------------------------------------------
69
architecture RTL of HostIF is
70
 
71
  constant C_ENC_START_REG        : std_logic_vector(31 downto 0) := X"0000_0000";
72
  constant C_IMAGE_SIZE_REG       : std_logic_vector(31 downto 0) := X"0000_0004";
73
  constant C_IMAGE_RAM_ACCESS_REG : std_logic_vector(31 downto 0) := X"0000_0008";
74
  constant C_ENC_STS_REG          : std_logic_vector(31 downto 0) := X"0000_000C";
75
  constant C_COD_DATA_ADDR_REG    : std_logic_vector(31 downto 0) := X"0000_0010";
76
  constant C_ENC_LENGTH_REG       : std_logic_vector(31 downto 0) := X"0000_0014";
77 32 mikel262
  constant C_QUANTIZER_RAM_LUM    : std_logic_vector(31 downto 0) :=
78 25 mikel262
                                      X"0000_01" & "------00";
79 32 mikel262
  constant C_QUANTIZER_RAM_CHR    : std_logic_vector(31 downto 0) :=
80
                                      X"0000_02" & "------00";
81 25 mikel262
  constant C_IMAGE_RAM            : std_logic_vector(31 downto 0) :=
82
                                      X"001" & "------------------00";
83
 
84
  constant C_IMAGE_RAM_BASE : unsigned(31 downto 0) := X"0010_0000";
85
 
86
  signal enc_start_reg            : std_logic_vector(31 downto 0);
87
  signal image_size_reg           : std_logic_vector(31 downto 0);
88
  signal image_ram_access_reg     : std_logic_vector(31 downto 0);
89
  signal enc_sts_reg              : std_logic_vector(31 downto 0);
90
  signal cod_data_addr_reg        : std_logic_vector(31 downto 0);
91
  signal enc_length_reg           : std_logic_vector(31 downto 0);
92
 
93
  signal rd_dval                  : std_logic;
94
  signal data_read                : std_logic_vector(31 downto 0);
95
  signal write_done               : std_logic;
96
  signal OPB_select_d             : std_logic;
97
 
98
-------------------------------------------------------------------------------
99
-- Architecture: begin
100
-------------------------------------------------------------------------------
101
begin
102
 
103
  OPB_retry    <= '0';
104
  OPB_toutSup  <= '0';
105
  OPB_errAck   <= '0';
106
 
107
  img_size_x <= image_size_reg(31 downto 16);
108
  img_size_y <= image_size_reg(15 downto 0);
109
 
110
  outram_base_addr <= cod_data_addr_reg(outram_base_addr'range);
111
 
112
  -------------------------------------------------------------------
113
  -- OPB read
114
  -------------------------------------------------------------------
115
  p_read : process(CLK, RST)
116
  begin
117
    if RST = '1' then
118
      OPB_DBus_out <= (others => '0');
119
      rd_dval      <= '0';
120
      data_read    <= (others => '0');
121
    elsif CLK'event and CLK = '1' then
122
      rd_dval <= '0';
123
 
124
      OPB_DBus_out <= data_read;
125
 
126
      if OPB_select = '1' and OPB_select_d = '0' then
127
        -- only double word transactions are be supported
128
        if OPB_RNW = '1' and OPB_BE = X"F" then
129
          case OPB_ABus is
130
            when C_ENC_START_REG =>
131
              data_read <= enc_start_reg;
132
              rd_dval <= '1';
133
 
134
            when C_IMAGE_SIZE_REG =>
135
              data_read <= image_size_reg;
136
              rd_dval <= '1';
137
 
138
            when C_IMAGE_RAM_ACCESS_REG =>
139
              data_read <= image_ram_access_reg;
140
              rd_dval <= '1';
141
 
142
            when C_ENC_STS_REG =>
143
              data_read <= enc_sts_reg;
144
              rd_dval <= '1';
145
 
146
            when C_COD_DATA_ADDR_REG =>
147
              data_read <= cod_data_addr_reg;
148
              rd_dval <= '1';
149
 
150
            when C_ENC_LENGTH_REG =>
151
              data_read <= enc_length_reg;
152
              rd_dval <= '1';
153
 
154
            when others =>
155
              data_read <= (others => '0');
156
          end case;
157
 
158
        end if;
159
      end if;
160
    end if;
161
  end process;
162
 
163
  -------------------------------------------------------------------
164
  -- OPB write
165
  -------------------------------------------------------------------
166
  p_write : process(CLK, RST)
167
  begin
168
    if RST = '1' then
169
      qwren                <= '0';
170
      write_done           <= '0';
171
      enc_start_reg        <= (others => '0');
172
      image_size_reg       <= (others => '0');
173
      image_ram_access_reg <= (others => '0');
174
      enc_sts_reg          <= (others => '0');
175
      cod_data_addr_reg    <= (others => '0');
176
      enc_length_reg       <= (others => '0');
177
      qdata                <= (others => '0');
178
      qaddr                <= (others => '0');
179
      OPB_select_d         <= '0';
180
      sof                  <= '0';
181
      img_size_wr          <= '0';
182
    elsif CLK'event and CLK = '1' then
183
      qwren        <= '0';
184
      write_done   <= '0';
185
      sof          <= '0';
186
      img_size_wr  <= '0';
187
      OPB_select_d <= OPB_select;
188
 
189
      if OPB_select = '1' and OPB_select_d = '0' then
190
        -- only double word transactions are be supported
191
        if OPB_RNW = '0' and OPB_BE = X"F" then
192
          case OPB_ABus is
193
            when C_ENC_START_REG =>
194
              enc_start_reg <= OPB_DBus_in;
195
              write_done <= '1';
196
              if OPB_DBus_in(0) = '1' then
197
                sof <= '1';
198
              end if;
199
 
200
            when C_IMAGE_SIZE_REG =>
201
              image_size_reg <= OPB_DBus_in;
202
              img_size_wr <= '1';
203
              write_done <= '1';
204
 
205
            when C_IMAGE_RAM_ACCESS_REG =>
206
              image_ram_access_reg <= OPB_DBus_in;
207
              write_done <= '1';
208
 
209
            when C_ENC_STS_REG =>
210
              enc_sts_reg <= (others => '0');
211
              write_done <= '1';
212
 
213
            when C_COD_DATA_ADDR_REG =>
214
              cod_data_addr_reg <= OPB_DBus_in;
215
              write_done <= '1';
216
 
217
            when C_ENC_LENGTH_REG =>
218
              --enc_length_reg <= OPB_DBus_in;
219
              write_done <= '1';
220
 
221
            when others =>
222
              null;
223
          end case;
224
 
225 32 mikel262
          if std_match(OPB_ABus, C_QUANTIZER_RAM_LUM) then
226 25 mikel262
            qdata      <= OPB_DBus_in(qdata'range);
227 32 mikel262
            qaddr      <= '0' & OPB_ABus(qaddr'high+2-1 downto 2);
228 25 mikel262
            qwren      <= '1';
229
            write_done <= '1';
230
          end if;
231 32 mikel262
 
232
          if std_match(OPB_ABus, C_QUANTIZER_RAM_CHR) then
233
            qdata      <= OPB_DBus_in(qdata'range);
234
            qaddr      <= '1' & OPB_ABus(qaddr'high+2-1 downto 2);
235
            qwren      <= '1';
236
            write_done <= '1';
237
          end if;
238
 
239 25 mikel262
        end if;
240
      end if;
241
 
242
      -- special handling of status reg
243
      if jpeg_ready = '1' then
244
        -- set jpeg done flag
245
        enc_sts_reg(1) <= '1';
246
      end if;
247
      enc_sts_reg(0) <= jpeg_busy;
248
 
249
      enc_length_reg <= (others => '0');
250
      enc_length_reg(num_enc_bytes'range) <= num_enc_bytes;
251
 
252
    end if;
253
  end process;
254
 
255
  -------------------------------------------------------------------
256
  -- transfer ACK
257
  -------------------------------------------------------------------
258
  p_ack : process(CLK, RST)
259
  begin
260
    if RST = '1' then
261
      OPB_XferAck <= '0';
262
    elsif CLK'event and CLK = '1' then
263
      OPB_XferAck <= rd_dval or write_done;
264
    end if;
265
  end process;
266
 
267
 
268
end architecture RTL;
269
-------------------------------------------------------------------------------
270
-- Architecture: end
271
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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