Skip to content

Commit 22f922f

Browse files
committedJul 9, 2015
encoder: simplify HostIF (to reduce logic)
1 parent f1d03b2 commit 22f922f

File tree

2 files changed

+43
-91
lines changed

2 files changed

+43
-91
lines changed
 

‎hdl/encoder/vhdl/HostIF.vhd

+41-89
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ entity HostIF is
5656
CLK : in std_logic;
5757
RST : in std_logic;
5858
-- OPB
59-
OPB_ABus : in std_logic_vector(31 downto 0);
59+
OPB_ABus : in std_logic_vector(11 downto 0);
6060
OPB_BE : in std_logic_vector(3 downto 0);
6161
OPB_DBus_in : in std_logic_vector(31 downto 0);
6262
OPB_RNW : in std_logic;
@@ -96,32 +96,23 @@ end entity HostIF;
9696
-------------------------------------------------------------------------------
9797
architecture RTL of HostIF is
9898

99-
constant C_ENC_START_REG : std_logic_vector(31 downto 0) := X"0000_0000";
100-
constant C_IMAGE_SIZE_REG : std_logic_vector(31 downto 0) := X"0000_0004";
101-
constant C_IMAGE_RAM_ACCESS_REG : std_logic_vector(31 downto 0) := X"0000_0008";
102-
constant C_ENC_STS_REG : std_logic_vector(31 downto 0) := X"0000_000C";
103-
constant C_COD_DATA_ADDR_REG : std_logic_vector(31 downto 0) := X"0000_0010";
104-
constant C_ENC_LENGTH_REG : std_logic_vector(31 downto 0) := X"0000_0014";
105-
constant C_QUANTIZER_RAM_LUM : std_logic_vector(31 downto 0) :=
106-
X"0000_01" & "------00";
107-
constant C_QUANTIZER_RAM_CHR : std_logic_vector(31 downto 0) :=
108-
X"0000_02" & "------00";
109-
constant C_IMAGE_RAM : std_logic_vector(31 downto 0) :=
110-
X"001" & "------------------00";
111-
112-
constant C_IMAGE_RAM_BASE : unsigned(31 downto 0) := X"0010_0000";
99+
constant C_ENC_START_REG : std_logic_vector(11 downto 0) := X"000";
100+
constant C_IMAGE_SIZE_REG : std_logic_vector(11 downto 0) := X"004";
101+
constant C_IMAGE_RAM_ACCESS_REG : std_logic_vector(11 downto 0) := X"008";
102+
constant C_ENC_STS_REG : std_logic_vector(11 downto 0) := X"00C";
103+
constant C_COD_DATA_ADDR_REG : std_logic_vector(11 downto 0) := X"010";
104+
constant C_ENC_LENGTH_REG : std_logic_vector(11 downto 0) := X"014";
105+
constant C_QUANTIZER_RAM_LUM_BASE : std_logic_vector(11 downto 0) := X"100";
106+
constant C_QUANTIZER_RAM_CHR_BASE : std_logic_vector(11 downto 0) := X"200";
113107

114108
signal enc_start_reg : std_logic_vector(31 downto 0);
115109
signal image_size_reg : std_logic_vector(31 downto 0);
116110
signal image_ram_access_reg : std_logic_vector(31 downto 0);
117111
signal enc_sts_reg : std_logic_vector(31 downto 0);
118112
signal cod_data_addr_reg : std_logic_vector(31 downto 0);
119-
signal enc_length_reg : std_logic_vector(31 downto 0);
120113

121-
signal rd_dval : std_logic;
122-
signal data_read : std_logic_vector(31 downto 0);
123-
signal write_done : std_logic;
124-
signal OPB_select_d : std_logic;
114+
signal read_ack : std_logic;
115+
signal write_ack : std_logic;
125116

126117
-------------------------------------------------------------------------------
127118
-- Architecture: begin
@@ -143,46 +134,31 @@ begin
143134
p_read : process(CLK, RST)
144135
begin
145136
if RST = '1' then
146-
OPB_DBus_out <= (others => '0');
147-
rd_dval <= '0';
148-
data_read <= (others => '0');
137+
read_ack <= '0';
138+
OPB_DBus_out <= (others => '0');
149139
elsif CLK'event and CLK = '1' then
150-
rd_dval <= '0';
151-
152-
OPB_DBus_out <= data_read;
153-
154-
if OPB_select = '1' and OPB_select_d = '0' then
140+
read_ack <= '0';
141+
if OPB_select = '1' and read_ack = '0' then
155142
-- only double word transactions are be supported
156143
if OPB_RNW = '1' and OPB_BE = X"F" then
144+
read_ack <= '1';
157145
case OPB_ABus is
158146
when C_ENC_START_REG =>
159-
data_read <= enc_start_reg;
160-
rd_dval <= '1';
161-
147+
OPB_DBus_out <= enc_start_reg;
162148
when C_IMAGE_SIZE_REG =>
163-
data_read <= image_size_reg;
164-
rd_dval <= '1';
165-
149+
OPB_DBus_out <= image_size_reg;
166150
when C_IMAGE_RAM_ACCESS_REG =>
167-
data_read <= image_ram_access_reg;
168-
rd_dval <= '1';
169-
151+
OPB_DBus_out <= image_ram_access_reg;
170152
when C_ENC_STS_REG =>
171-
data_read <= enc_sts_reg;
172-
rd_dval <= '1';
173-
153+
OPB_DBus_out <= enc_sts_reg;
174154
when C_COD_DATA_ADDR_REG =>
175-
data_read <= cod_data_addr_reg;
176-
rd_dval <= '1';
177-
155+
OPB_DBus_out <= cod_data_addr_reg;
178156
when C_ENC_LENGTH_REG =>
179-
data_read <= enc_length_reg;
180-
rd_dval <= '1';
181-
157+
OPB_DBus_out(31 downto 24) <= (others => '0');
158+
OPB_DBus_out(23 downto 0) <= num_enc_bytes;
182159
when others =>
183-
data_read <= (others => '0');
160+
OPB_DBus_out <= (others => '0');
184161
end case;
185-
186162
end if;
187163
end if;
188164
end if;
@@ -195,76 +171,63 @@ begin
195171
begin
196172
if RST = '1' then
197173
qwren <= '0';
198-
write_done <= '0';
174+
write_ack <= '0';
199175
enc_start_reg <= (others => '0');
200176
image_size_reg <= (others => '0');
201177
image_ram_access_reg <= (others => '0');
202178
enc_sts_reg <= (others => '0');
203179
cod_data_addr_reg <= (others => '0');
204-
enc_length_reg <= (others => '0');
205180
qdata <= (others => '0');
206181
qaddr <= (others => '0');
207-
OPB_select_d <= '0';
208182
sof <= '0';
209183
img_size_wr <= '0';
210184
elsif CLK'event and CLK = '1' then
211-
qwren <= '0';
212-
write_done <= '0';
213-
sof <= '0';
214-
img_size_wr <= '0';
215-
OPB_select_d <= OPB_select;
185+
qwren <= '0';
186+
write_ack <= '0';
187+
sof <= '0';
188+
img_size_wr <= '0';
216189

217-
if OPB_select = '1' and OPB_select_d = '0' then
190+
if OPB_select = '1' and write_ack = '0' then
218191
-- only double word transactions are be supported
219192
if OPB_RNW = '0' and OPB_BE = X"F" then
193+
write_ack <= '1';
220194
case OPB_ABus is
221195
when C_ENC_START_REG =>
222196
enc_start_reg <= OPB_DBus_in;
223-
write_done <= '1';
224197
if OPB_DBus_in(0) = '1' then
225198
sof <= '1';
226199
end if;
227200

228201
when C_IMAGE_SIZE_REG =>
229202
image_size_reg <= OPB_DBus_in;
230203
img_size_wr <= '1';
231-
write_done <= '1';
232204

233205
when C_IMAGE_RAM_ACCESS_REG =>
234206
image_ram_access_reg <= OPB_DBus_in;
235-
write_done <= '1';
236207

237208
when C_ENC_STS_REG =>
238209
enc_sts_reg <= (others => '0');
239-
write_done <= '1';
240210

241211
when C_COD_DATA_ADDR_REG =>
242212
cod_data_addr_reg <= OPB_DBus_in;
243-
write_done <= '1';
244213

245214
when C_ENC_LENGTH_REG =>
246215
--enc_length_reg <= OPB_DBus_in;
247-
write_done <= '1';
248216

249217
when others =>
250-
null;
218+
if OPB_ABus(11 downto 8) = C_QUANTIZER_RAM_LUM_BASE(11 downto 8) then
219+
qwren <= '1';
220+
qaddr <= '0' & OPB_ABus(qaddr'high+2-1 downto 2);
221+
elsif OPB_ABus(11 downto 8) = C_QUANTIZER_RAM_CHR_BASE(11 downto 8) then
222+
qwren <= '1';
223+
qaddr <= '1' & OPB_ABus(qaddr'high+2-1 downto 2);
224+
end if;
251225
end case;
252226

253-
if std_match(OPB_ABus, C_QUANTIZER_RAM_LUM) then
254-
qdata <= OPB_DBus_in(qdata'range);
255-
qaddr <= '0' & OPB_ABus(qaddr'high+2-1 downto 2);
256-
qwren <= '1';
257-
write_done <= '1';
258-
end if;
227+
end if;
259228

260-
if std_match(OPB_ABus, C_QUANTIZER_RAM_CHR) then
261-
qdata <= OPB_DBus_in(qdata'range);
262-
qaddr <= '1' & OPB_ABus(qaddr'high+2-1 downto 2);
263-
qwren <= '1';
264-
write_done <= '1';
265-
end if;
229+
qdata <= OPB_DBus_in(qdata'range);
266230

267-
end if;
268231
end if;
269232

270233
-- special handling of status reg
@@ -274,24 +237,13 @@ begin
274237
end if;
275238
enc_sts_reg(0) <= jpeg_busy;
276239

277-
enc_length_reg <= (others => '0');
278-
enc_length_reg(num_enc_bytes'range) <= num_enc_bytes;
279-
280240
end if;
281241
end process;
282242

283243
-------------------------------------------------------------------
284244
-- transfer ACK
285245
-------------------------------------------------------------------
286-
p_ack : process(CLK, RST)
287-
begin
288-
if RST = '1' then
289-
OPB_XferAck <= '0';
290-
elsif CLK'event and CLK = '1' then
291-
OPB_XferAck <= rd_dval or write_done;
292-
end if;
293-
end process;
294-
246+
OPB_XferAck <= read_ack or write_ack;
295247

296248
end architecture RTL;
297249
-------------------------------------------------------------------------------

‎hdl/encoder/vhdl/JpegEnc.vhd

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ entity JpegEnc is
7474
(
7575
CLK : in std_logic;
7676
RST : in std_logic;
77-
77+
7878
-- OPB
79-
OPB_ABus : in std_logic_vector(31 downto 0);
79+
OPB_ABus : in std_logic_vector(11 downto 0);
8080
OPB_BE : in std_logic_vector(3 downto 0);
8181
OPB_DBus_in : in std_logic_vector(31 downto 0);
8282
OPB_RNW : in std_logic;

0 commit comments

Comments
 (0)
Please sign in to comment.