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

Subversion Repositories mkjpeg

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

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
        sof                : out std_logic;
60
        cmp_max            : out std_logic_vector(1 downto 0)
61
 
62
    );
63
end entity HostIF;
64
 
65
-------------------------------------------------------------------------------
66
-------------------------------------------------------------------------------
67
----------------------------------- ARCHITECTURE ------------------------------
68
-------------------------------------------------------------------------------
69
-------------------------------------------------------------------------------
70
architecture RTL of HostIF is
71
 
72
  constant C_ENC_START_REG        : std_logic_vector(31 downto 0) := X"0000_0000";
73
  constant C_IMAGE_SIZE_REG       : std_logic_vector(31 downto 0) := X"0000_0004";
74
  constant C_IMAGE_RAM_ACCESS_REG : std_logic_vector(31 downto 0) := X"0000_0008";
75
  constant C_ENC_STS_REG          : std_logic_vector(31 downto 0) := X"0000_000C";
76
  constant C_COD_DATA_ADDR_REG    : std_logic_vector(31 downto 0) := X"0000_0010";
77
  constant C_ENC_LENGTH_REG       : std_logic_vector(31 downto 0) := X"0000_0014";
78 32 mikel262
  constant C_QUANTIZER_RAM_LUM    : std_logic_vector(31 downto 0) :=
79 25 mikel262
                                      X"0000_01" & "------00";
80 32 mikel262
  constant C_QUANTIZER_RAM_CHR    : std_logic_vector(31 downto 0) :=
81
                                      X"0000_02" & "------00";
82 25 mikel262
  constant C_IMAGE_RAM            : std_logic_vector(31 downto 0) :=
83
                                      X"001" & "------------------00";
84
 
85
  constant C_IMAGE_RAM_BASE : unsigned(31 downto 0) := X"0010_0000";
86
 
87
  signal enc_start_reg            : std_logic_vector(31 downto 0);
88
  signal image_size_reg           : std_logic_vector(31 downto 0);
89
  signal image_ram_access_reg     : std_logic_vector(31 downto 0);
90
  signal enc_sts_reg              : std_logic_vector(31 downto 0);
91
  signal cod_data_addr_reg        : std_logic_vector(31 downto 0);
92
  signal enc_length_reg           : std_logic_vector(31 downto 0);
93
 
94
  signal rd_dval                  : std_logic;
95
  signal data_read                : std_logic_vector(31 downto 0);
96
  signal write_done               : std_logic;
97
  signal OPB_select_d             : std_logic;
98
 
99
-------------------------------------------------------------------------------
100
-- Architecture: begin
101
-------------------------------------------------------------------------------
102
begin
103
 
104
  OPB_retry    <= '0';
105
  OPB_toutSup  <= '0';
106
  OPB_errAck   <= '0';
107
 
108
  img_size_x <= image_size_reg(31 downto 16);
109
  img_size_y <= image_size_reg(15 downto 0);
110
 
111
  outram_base_addr <= cod_data_addr_reg(outram_base_addr'range);
112
 
113
  cmp_max <= enc_start_reg(2 downto 1);
114
 
115
  -------------------------------------------------------------------
116
  -- OPB read
117
  -------------------------------------------------------------------
118
  p_read : process(CLK, RST)
119
  begin
120
    if RST = '1' then
121
      OPB_DBus_out <= (others => '0');
122
      rd_dval      <= '0';
123
      data_read    <= (others => '0');
124
    elsif CLK'event and CLK = '1' then
125
      rd_dval <= '0';
126
 
127
      OPB_DBus_out <= data_read;
128
 
129
      if OPB_select = '1' and OPB_select_d = '0' then
130
        -- only double word transactions are be supported
131
        if OPB_RNW = '1' and OPB_BE = X"F" then
132
          case OPB_ABus is
133
            when C_ENC_START_REG =>
134
              data_read <= enc_start_reg;
135
              rd_dval <= '1';
136
 
137
            when C_IMAGE_SIZE_REG =>
138
              data_read <= image_size_reg;
139
              rd_dval <= '1';
140
 
141
            when C_IMAGE_RAM_ACCESS_REG =>
142
              data_read <= image_ram_access_reg;
143
              rd_dval <= '1';
144
 
145
            when C_ENC_STS_REG =>
146
              data_read <= enc_sts_reg;
147
              rd_dval <= '1';
148
 
149
            when C_COD_DATA_ADDR_REG =>
150
              data_read <= cod_data_addr_reg;
151
              rd_dval <= '1';
152
 
153
            when C_ENC_LENGTH_REG =>
154
              data_read <= enc_length_reg;
155
              rd_dval <= '1';
156
 
157
            when others =>
158
              data_read <= (others => '0');
159
          end case;
160
 
161
        end if;
162
      end if;
163
    end if;
164
  end process;
165
 
166
  -------------------------------------------------------------------
167
  -- OPB write
168
  -------------------------------------------------------------------
169
  p_write : process(CLK, RST)
170
  begin
171
    if RST = '1' then
172
      qwren                <= '0';
173
      write_done           <= '0';
174
      enc_start_reg        <= (others => '0');
175
      image_size_reg       <= (others => '0');
176
      image_ram_access_reg <= (others => '0');
177
      enc_sts_reg          <= (others => '0');
178
      cod_data_addr_reg    <= (others => '0');
179
      enc_length_reg       <= (others => '0');
180
      qdata                <= (others => '0');
181
      qaddr                <= (others => '0');
182
      OPB_select_d         <= '0';
183
      sof                  <= '0';
184
      img_size_wr          <= '0';
185
    elsif CLK'event and CLK = '1' then
186
      qwren        <= '0';
187
      write_done   <= '0';
188
      sof          <= '0';
189
      img_size_wr  <= '0';
190
      OPB_select_d <= OPB_select;
191
 
192
      if OPB_select = '1' and OPB_select_d = '0' then
193
        -- only double word transactions are be supported
194
        if OPB_RNW = '0' and OPB_BE = X"F" then
195
          case OPB_ABus is
196
            when C_ENC_START_REG =>
197
              enc_start_reg <= OPB_DBus_in;
198
              write_done <= '1';
199
              if OPB_DBus_in(0) = '1' then
200
                sof <= '1';
201
              end if;
202
 
203
            when C_IMAGE_SIZE_REG =>
204
              image_size_reg <= OPB_DBus_in;
205
              img_size_wr <= '1';
206
              write_done <= '1';
207
 
208
            when C_IMAGE_RAM_ACCESS_REG =>
209
              image_ram_access_reg <= OPB_DBus_in;
210
              write_done <= '1';
211
 
212
            when C_ENC_STS_REG =>
213
              enc_sts_reg <= (others => '0');
214
              write_done <= '1';
215
 
216
            when C_COD_DATA_ADDR_REG =>
217
              cod_data_addr_reg <= OPB_DBus_in;
218
              write_done <= '1';
219
 
220
            when C_ENC_LENGTH_REG =>
221
              --enc_length_reg <= OPB_DBus_in;
222
              write_done <= '1';
223
 
224
            when others =>
225
              null;
226
          end case;
227
 
228 32 mikel262
          if std_match(OPB_ABus, C_QUANTIZER_RAM_LUM) then
229 25 mikel262
            qdata      <= OPB_DBus_in(qdata'range);
230 32 mikel262
            qaddr      <= '0' & OPB_ABus(qaddr'high+2-1 downto 2);
231 25 mikel262
            qwren      <= '1';
232
            write_done <= '1';
233
          end if;
234 32 mikel262
 
235
          if std_match(OPB_ABus, C_QUANTIZER_RAM_CHR) then
236
            qdata      <= OPB_DBus_in(qdata'range);
237
            qaddr      <= '1' & OPB_ABus(qaddr'high+2-1 downto 2);
238
            qwren      <= '1';
239
            write_done <= '1';
240
          end if;
241
 
242 25 mikel262
        end if;
243
      end if;
244
 
245
      -- special handling of status reg
246
      if jpeg_ready = '1' then
247
        -- set jpeg done flag
248
        enc_sts_reg(1) <= '1';
249
      end if;
250
      enc_sts_reg(0) <= jpeg_busy;
251
 
252
      enc_length_reg <= (others => '0');
253
      enc_length_reg(num_enc_bytes'range) <= num_enc_bytes;
254
 
255
    end if;
256
  end process;
257
 
258
  -------------------------------------------------------------------
259
  -- transfer ACK
260
  -------------------------------------------------------------------
261
  p_ack : process(CLK, RST)
262
  begin
263
    if RST = '1' then
264
      OPB_XferAck <= '0';
265
    elsif CLK'event and CLK = '1' then
266
      OPB_XferAck <= rd_dval or write_done;
267
    end if;
268
  end process;
269
 
270
 
271
end architecture RTL;
272
-------------------------------------------------------------------------------
273
-- Architecture: end
274
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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