URL
https://opencores.org/ocsvn/mkjpeg/mkjpeg/trunk
Subversion Repositories mkjpeg
Compare Revisions
- This comparison shows the changes necessary to convert path
/mkjpeg/trunk
- from Rev 31 to Rev 32
- ↔ Reverse comparison
Rev 31 → Rev 32
/doc/JPEG.doc
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/tb/wave.do
414,21 → 414,26
add wave -noupdate -divider quantizer |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/rst |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/clk |
add wave -noupdate -format Literal -radix decimal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/di |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/di |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/divalid |
add wave -noupdate -format Literal -radix decimal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/qdata |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/qwaddr |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/qwren |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/cmp_idx |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/dovalid |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/romaddr_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/slv_romaddr_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/romdatao_s |
add wave -noupdate -format Literal -radix decimal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/di_d1 |
add wave -noupdate -format Literal -radix unsigned /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/divisor_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/divisor_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/remainder_s |
add wave -noupdate -format Literal -radix decimal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do_s |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/round_s |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/di_d1 |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/pipeline_reg |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/sign_bit_pipe |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/pipeline_reg |
add wave -noupdate -format Literal -radix decimal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do_rdiv |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/do_rdiv |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/table_select |
add wave -noupdate -divider r_divider |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/r_divider/rst |
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_zz_top/u_quantizer/r_divider/clk |
655,7 → 660,7
add wave -noupdate -format Logic /jpeg_tb/u_jpegenc/u_outmux/ram_wren |
add wave -noupdate -format Literal /jpeg_tb/u_jpegenc/u_outmux/ram_wraddr |
TreeUpdate [SetDefaultTree] |
WaveRestoreCursors {{Cursor 4} {4522517 ps} 0} |
WaveRestoreCursors {{Cursor 4} {45000815232 ps} 0} |
configure wave -namecolwidth 150 |
configure wave -valuecolwidth 55 |
configure wave -justifyvalue left |
670,4 → 675,4
configure wave -timeline 0 |
configure wave -timelineunits ps |
update |
WaveRestoreZoom {4322687 ps} {4579293 ps} |
WaveRestoreZoom {45000756225 ps} {45001012831 ps} |
/tb/header.hex
33,10 → 33,10
00 |
02 |
11 |
00 |
01 |
03 |
11 |
00 |
01 |
FF |
DB |
00 |
92,6 → 92,75
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
FF |
DB |
00 |
43 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
01 |
/tb/vhdl/HostBFM.vhd
279,7 → 279,7
type ROMQ_TYPE is array (0 to 64-1) |
of unsigned(7 downto 0); |
|
constant qrom : ROMQ_TYPE := |
constant qrom_lum : ROMQ_TYPE := |
( |
-- 100% |
--others => X"01" |
303,10 → 303,10
--X"1C", X"1E", X"1F", X"1E" |
|
-- 75% |
--X"08", X"06", X"06", X"07", X"06", X"05", X"08", X"07", X"07", X"07", X"09", X"09", X"08", X"0A", X"0C", X"14", |
--X"0D", X"0C", X"0B", X"0B", X"0C", X"19", X"12", X"13", X"0F", X"14", X"1D", X"1A", X"1F", X"1E", X"1D", X"1A", |
--X"1C", X"1C", X"20", X"24", X"2E", X"27", X"20", X"22", X"2C", X"23", X"1C", X"1C", X"28", X"37", X"29", X"2C", |
--X"30", X"31", X"34", X"34", X"34", X"1F", X"27", X"39", X"3D", X"38", X"32", X"3C", X"2E", X"33", X"34", X"32" |
X"08", X"06", X"06", X"07", X"06", X"05", X"08", X"07", X"07", X"07", X"09", X"09", X"08", X"0A", X"0C", X"14", |
X"0D", X"0C", X"0B", X"0B", X"0C", X"19", X"12", X"13", X"0F", X"14", X"1D", X"1A", X"1F", X"1E", X"1D", X"1A", |
X"1C", X"1C", X"20", X"24", X"2E", X"27", X"20", X"22", X"2C", X"23", X"1C", X"1C", X"28", X"37", X"29", X"2C", |
X"30", X"31", X"34", X"34", X"34", X"1F", X"27", X"39", X"3D", X"38", X"32", X"3C", X"2E", X"33", X"34", X"32" |
|
-- 15 % |
--X"35", X"25", X"28", X"2F", |
324,9 → 324,22
--X"FF", X"FF", X"FF", X"FF", |
--X"FF", X"CE", X"FF", X"FF", |
--X"FF", X"FF", X"FF", X"FF", |
--X"FF", X"FF", X"FF", X"FF" |
--X"FF", X"FF", X"FF", X"FF" |
|
-- 50% |
--X"10", X"0B", X"0C", X"0E", X"0C", X"0A", X"10", X"0E", |
--X"0D", X"0E", X"12", X"11", X"10", X"13", X"18", X"28", |
--X"1A", X"18", X"16", X"16", X"18", X"31", X"23", X"25", |
--X"1D", X"28", X"3A", X"33", X"3D", X"3C", X"39", X"33", |
--X"38", X"37", X"40", X"48", X"5C", X"4E", X"40", X"44", |
--X"57", X"45", X"37", X"38", X"50", X"6D", X"51", X"57", |
--X"5F", X"62", X"67", X"68", X"67", X"3E", X"4D", X"71", |
--X"79", X"70", X"64", X"78", X"5C", X"65", X"67", X"63" |
); |
|
constant qrom_chr : ROMQ_TYPE := |
( |
-- 50% for luminance! but used as chrominance, TODO!! |
X"10", X"0B", X"0C", X"0E", X"0C", X"0A", X"10", X"0E", |
X"0D", X"0E", X"12", X"11", X"10", X"13", X"18", X"28", |
X"1A", X"18", X"16", X"16", X"18", X"31", X"23", X"25", |
366,17 → 379,25
host_read(CLK, X"0000_0004", data_read, |
OPB_ABus, OPB_BE, OPB_DBus_out, OPB_RNW, OPB_select, OPB_XferAck); |
|
-- write quantization table |
-- write luminance quantization table |
for i in 0 to 64-1 loop |
data_write := X"0000_00" & qrom(i); |
data_write := X"0000_00" & qrom_lum(i); |
addr := X"0000_0100" + to_unsigned(4*i,32); |
-- SOF & num_comps |
host_write(CLK, addr, data_write, |
OPB_ABus, OPB_BE, OPB_DBus_in, OPB_RNW, OPB_select, OPB_XferAck); |
|
end loop; |
|
|
-- write chrominance quantization table |
for i in 0 to 64-1 loop |
data_write := X"0000_00" & qrom_chr(i); |
addr := X"0000_0200" + to_unsigned(4*i,32); |
host_write(CLK, addr, data_write, |
OPB_ABus, OPB_BE, OPB_DBus_in, OPB_RNW, OPB_select, OPB_XferAck); |
|
end loop; |
|
|
|
data_write := to_unsigned(1,32) + shift_left(to_unsigned(3,32),1); |
|
/design/quantizer/QUANTIZER.vhd
1,7 → 1,7
-------------------------------------------------------------------------------- |
-- -- |
-- V H D L F I L E -- |
-- COPYRIGHT (C) 2006 -- |
-- COPYRIGHT (C) 2006-2009 -- |
-- -- |
-------------------------------------------------------------------------------- |
-- -- |
16,8 → 16,6
-- -- |
-------------------------------------------------------------------------------- |
-- -- |
-- Description : Pipelined DCT Quantizer -- |
-- Pipeline delay: 2*SIZE_C+INTERN_PIPE_C -- |
-------------------------------------------------------------------------------- |
|
-------------------------------------------------------------------------------- |
30,7 → 28,7
generic |
( |
SIZE_C : INTEGER := 12; |
RAMQADDR_W : INTEGER := 6; |
RAMQADDR_W : INTEGER := 7; |
RAMQDATA_W : INTEGER := 8 |
); |
port |
40,8 → 38,9
di : in STD_LOGIC_VECTOR(SIZE_C-1 downto 0); |
divalid : in STD_LOGIC; |
qdata : in std_logic_vector(7 downto 0); |
qwaddr : in std_logic_vector(5 downto 0); |
qwaddr : in std_logic_vector(6 downto 0); |
qwren : in std_logic; |
cmp_idx : in unsigned(1 downto 0); |
|
do : out STD_LOGIC_VECTOR(SIZE_C-1 downto 0); |
dovalid : out STD_LOGIC |
52,7 → 51,7
|
constant INTERN_PIPE_C : INTEGER := 3; |
|
signal romaddr_s : UNSIGNED(RAMQADDR_W-1 downto 0); |
signal romaddr_s : UNSIGNED(RAMQADDR_W-2 downto 0); |
signal slv_romaddr_s : STD_LOGIC_VECTOR(RAMQADDR_W-1 downto 0); |
signal romdatao_s : STD_LOGIC_VECTOR(RAMQDATA_W-1 downto 0); |
signal divisor_s : STD_LOGIC_VECTOR(SIZE_C-1 downto 0); |
64,6 → 63,8
signal pipeline_reg : STD_LOGIC_VECTOR(4 downto 0); |
signal sign_bit_pipe : std_logic_vector(SIZE_C+INTERN_PIPE_C+1-1 downto 0); |
signal do_rdiv : STD_LOGIC_VECTOR(SIZE_C-1 downto 0); |
signal table_select : std_logic; |
|
begin |
|
---------------------------- |
86,25 → 87,7
q => romdatao_s |
); |
|
---------------------------- |
-- S_DIVIDER |
---------------------------- |
--U_S_DIVIDER : entity work.s_divider |
-- generic map |
-- ( |
-- SIZE_C => SIZE_C |
-- ) |
-- port map |
-- ( |
-- rst => rst, |
-- clk => clk, |
-- a => di_d1, |
-- d => divisor_s, |
-- |
-- q => do_s, |
-- r => remainder_s, -- if ever used, needs to be 1T delayed |
-- round => round_s |
-- ); |
|
|
divisor_s(RAMQDATA_W-1 downto 0) <= romdatao_s; |
divisor_s(SIZE_C-1 downto RAMQDATA_W) <= (others => '0'); |
120,32 → 103,27
q => do_s |
) ; |
do <= do_s; |
slv_romaddr_s <= STD_LOGIC_VECTOR(romaddr_s); |
slv_romaddr_s <= table_select & STD_LOGIC_VECTOR(romaddr_s); |
|
------------------------------ |
---- round to nearest integer |
-- Quantization sub table select |
------------------------------ |
--process(clk) |
--begin |
-- if clk = '1' and clk'event then |
-- if rst = '1' then |
-- do <= (others => '0'); |
-- else |
-- -- round to nearest integer? |
-- if round_s = '1' then |
-- -- negative number, subtract 1 |
-- if sign_bit_pipe(sign_bit_pipe'length-1) = '1' then |
-- do <= STD_LOGIC_VECTOR(SIGNED(do_s)-TO_SIGNED(1,SIZE_C)); |
-- -- positive number, add 1 |
-- else |
-- do <= STD_LOGIC_VECTOR(SIGNED(do_s)+TO_SIGNED(1,SIZE_C)); |
-- end if; |
-- else |
-- do <= do_s; |
-- end if; |
-- end if; |
-- end if; |
--end process; |
process(clk) |
begin |
if clk = '1' and clk'event then |
if rst = '1' then |
table_select <= '0'; |
else |
-- luminance table select |
if cmp_idx = 0 then |
table_select <= '0'; |
-- chrominance table select |
else |
table_select <= '1'; |
end if; |
end if; |
end if; |
end process; |
|
---------------------------- |
-- address incrementer |
160,7 → 138,7
sign_bit_pipe <= (others => '0'); |
else |
if divalid = '1' then |
romaddr_s <= romaddr_s + TO_UNSIGNED(1,RAMQADDR_W); |
romaddr_s <= romaddr_s + TO_UNSIGNED(1,romaddr_s'length); |
end if; |
|
pipeline_reg <= pipeline_reg(pipeline_reg'length-2 downto 0) & divalid; |
/design/top/JpegEnc.vhd
79,7 → 79,7
architecture RTL of JpegEnc is |
|
signal qdata : std_logic_vector(7 downto 0); |
signal qaddr : std_logic_vector(5 downto 0); |
signal qaddr : std_logic_vector(6 downto 0); |
signal qwren : std_logic; |
signal jpeg_ready : std_logic; |
signal jpeg_busy : std_logic; |
310,6 → 310,7
-- CTRL |
start_pb => zig_start, |
ready_pb => zig_ready, |
zig_sm_settings => zig_sm_settings, |
|
-- RLE |
rle_buf_sel => rle_buf_sel, |
/design/JFIFGen/JFIFGen.vhd
58,7 → 58,7
|
-- HOST IF |
qwren : in std_logic; |
qwaddr : in std_logic_vector(5 downto 0); |
qwaddr : in std_logic_vector(6 downto 0); |
qwdata : in std_logic_vector(7 downto 0); |
image_size_reg : in std_logic_vector(31 downto 0); |
image_size_reg_wr : in std_logic; |
83,6 → 83,8
constant C_SIZE_X_L : integer := 28; |
|
constant C_EOI : std_logic_vector(15 downto 0) := X"FFD9"; |
constant C_QLUM_BASE : integer := 44; |
constant C_QCHR_BASE : integer := 44+69; |
|
|
signal hr_data : std_logic_vector(7 downto 0); |
178,8 → 180,17
end if; |
-- write Quantization table |
elsif qwren = '1' then |
hr_waddr <= std_logic_vector( resize(unsigned(qwaddr),hr_waddr'length) + |
to_unsigned(44,hr_waddr'length)); |
-- luminance table select |
if qwaddr(6) = '0' then |
hr_waddr <= std_logic_vector |
( resize(unsigned(qwaddr(5 downto 0)),hr_waddr'length) + |
to_unsigned(C_QLUM_BASE,hr_waddr'length)); |
else |
-- chrominance table select |
hr_waddr <= std_logic_vector |
( resize(unsigned(qwaddr(5 downto 0)),hr_waddr'length) + |
to_unsigned(C_QCHR_BASE,hr_waddr'length)); |
end if; |
hr_we <= '1'; |
hr_data <= qwdata; |
end if; |
/design/common/JPEG_PKG.vhd
27,12 → 27,12
package JPEG_PKG is |
|
-- do not change, constant |
constant C_HDR_SIZE : integer := 338; |
constant C_HDR_SIZE : integer := 407; |
|
-- warning! this parameter heavily affects memory size required |
-- if expected image width is known change this parameter to match this |
-- otherwise some onchip RAM will be wasted and never used |
constant C_MAX_LINE_WIDTH : integer := 1024; |
constant C_MAX_LINE_WIDTH : integer := 640; |
|
-- 0=highest clock per pixel performance |
-- 1=memory used by BUF_FIFO halved, speed performance reduced by circa 18% |
/design/zigzag/ZZ_TOP.VHD
34,7 → 34,8
------------------------------------------------------------------------------- |
-- user packages/libraries: |
------------------------------------------------------------------------------- |
|
library work; |
use work.JPEG_PKG.all; |
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
----------------------------------- ENTITY ------------------------------------ |
48,6 → 49,7
-- CTRL |
start_pb : in std_logic; |
ready_pb : out std_logic; |
zig_sm_settings : in T_SM_SETTINGS; |
|
-- RLE |
rle_buf_sel : in std_logic; |
62,7 → 64,7
|
-- HOST |
qdata : in std_logic_vector(7 downto 0); |
qaddr : in std_logic_vector(5 downto 0); |
qaddr : in std_logic_vector(6 downto 0); |
qwren : in std_logic |
); |
end entity ZZ_TOP; |
138,7 → 140,7
generic map |
( |
SIZE_C => 12, |
RAMQADDR_W => 6, |
RAMQADDR_W => 7, |
RAMQDATA_W => 8 |
) |
port map |
150,6 → 152,7
qdata => qdata, |
qwaddr => qaddr, |
qwren => qwren, |
cmp_idx => zig_sm_settings.cmp_idx, |
|
do => quant_dout, |
dovalid => quant_dovalid |
/design/hostif/HostIF.vhd
41,7 → 41,7
|
-- Quantizer RAM |
qdata : out std_logic_vector(7 downto 0); |
qaddr : out std_logic_vector(5 downto 0); |
qaddr : out std_logic_vector(6 downto 0); |
qwren : out std_logic; |
|
-- CTRL |
75,8 → 75,10
constant C_ENC_STS_REG : std_logic_vector(31 downto 0) := X"0000_000C"; |
constant C_COD_DATA_ADDR_REG : std_logic_vector(31 downto 0) := X"0000_0010"; |
constant C_ENC_LENGTH_REG : std_logic_vector(31 downto 0) := X"0000_0014"; |
constant C_QUANTIZER_RAM : std_logic_vector(31 downto 0) := |
constant C_QUANTIZER_RAM_LUM : std_logic_vector(31 downto 0) := |
X"0000_01" & "------00"; |
constant C_QUANTIZER_RAM_CHR : std_logic_vector(31 downto 0) := |
X"0000_02" & "------00"; |
constant C_IMAGE_RAM : std_logic_vector(31 downto 0) := |
X"001" & "------------------00"; |
|
91,8 → 93,6
|
signal rd_dval : std_logic; |
signal data_read : std_logic_vector(31 downto 0); |
signal quantizer_ram_q : std_logic_vector(31 downto 0); |
signal image_ram_q : std_logic_vector(31 downto 0); |
signal write_done : std_logic; |
signal OPB_select_d : std_logic; |
|
105,10 → 105,6
OPB_toutSup <= '0'; |
OPB_errAck <= '0'; |
|
-- temporary!! |
quantizer_ram_q <= (others => '0'); |
image_ram_q <= (others => '0'); |
|
img_size_x <= image_size_reg(31 downto 16); |
img_size_y <= image_size_reg(15 downto 0); |
|
229,12 → 225,20
null; |
end case; |
|
if std_match(OPB_ABus, C_QUANTIZER_RAM) then |
if std_match(OPB_ABus, C_QUANTIZER_RAM_LUM) then |
qdata <= OPB_DBus_in(qdata'range); |
qaddr <= OPB_ABus(qaddr'high+2 downto 2); |
qaddr <= '0' & OPB_ABus(qaddr'high+2-1 downto 2); |
qwren <= '1'; |
write_done <= '1'; |
end if; |
|
if std_match(OPB_ABus, C_QUANTIZER_RAM_CHR) then |
qdata <= OPB_DBus_in(qdata'range); |
qaddr <= '1' & OPB_ABus(qaddr'high+2-1 downto 2); |
qwren <= '1'; |
write_done <= '1'; |
end if; |
|
end if; |
end if; |
|