📄 dct8_slow.txt
字号:
-- Top entity is DCT8_slow
-- ENTITY DCT8_slow IS
-- PORT(
-- clk : IN std_logic ;
-- dctselect : IN std_logic ;
-- din : IN std_logic ;
-- mode : IN std_logic_vector (1 downto 0) ;
-- reset : IN std_logic ;
-- doutput : OUT std_logic_vector (15 DOWNTO 0) ;
-- next_in : OUT std_logic ;
-- read : OUT std_logic
-- );
--
-- Please refer to the FreeDCT-L documentation
-- Sherif Taher Eid, sherif_taher@ieee.org
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY add12slow IS
PORT(
a : IN std_logic_vector (11 downto 0) ;
b : IN std_logic_vector (11 downto 0) ;
output : OUT std_logic_vector (12 downto 0)
);
-- Declarations
END add12slow ;
--
--
ARCHITECTURE beh OF add12slow IS
signal output_temp : unsigned(12 downto 0);
BEGIN
output_temp <= unsigned(a(11)&a) + unsigned(b(11)&b);
output <= std_logic_vector(output_temp);
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY add16bits IS
PORT(
a : IN std_logic_vector (15 downto 0) ;
b : IN std_logic_vector (15 downto 0) ;
output : OUT std_logic_vector (15 downto 0)
);
-- Declarations
END add16bits ;
--
--
ARCHITECTURE beh OF add16bits IS
signal output_temp : unsigned(15 downto 0);
BEGIN
output_temp <= unsigned(a) + unsigned(b);
output <= std_logic_vector(output_temp);
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
ENTITY and15 IS
PORT(
enable : IN std_logic ;
input : IN std_logic_vector (15 downto 0) ;
output : OUT std_logic_vector (15 downto 0)
);
-- Declarations
END and15 ;
--
--
ARCHITECTURE struct OF and15 IS
BEGIN
with enable select
output <= "0000000000001100" when '0',
input when others;
END struct;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
LIBRARY std ;
USE std.textio.all;
ENTITY cyclereg IS
PORT(
ck : IN std_logic ;
din : IN std_logic ;
first : IN std_logic ;
mode : IN std_logic_vector (1 downto 0) ;
rst : IN std_logic ;
enable_rom : OUT std_logic
);
-- Declarations
END cyclereg ;
--
--
ARCHITECTURE beh OF cyclereg IS
signal internal : std_logic_vector(95 downto 0);
signal din_tmp : std_logic;
signal op_mode : std_logic_vector(2 downto 0);
BEGIN
op_mode <= first&mode;
with op_mode select
din_tmp <= din when "100",
din when "101",
din when "110",
din when "111",
internal(63) when "000",
internal(71) when "001",
internal(79) when "010",
internal(95) when others;
enable_rom <= internal(0);
process(ck,rst)
begin
if rising_edge(ck) then
if rst = '1' then
internal <= (others => '0');
elsif mode = "00" then -- 8 bits resolution mode
internal(63 downto 1) <= internal(62 downto 0);
internal(0) <= din_tmp;
elsif mode = "01" then -- 9 bits resolution mode
internal(71 downto 1) <= internal(70 downto 0);
internal(0) <= din_tmp;
elsif mode = "10" then -- 10 bits resolution mode
internal(79 downto 1) <= internal(78 downto 0);
internal(0) <= din_tmp;
else -- 12 bits resolution mode
internal(95 downto 1) <= internal(94 downto 0);
internal(0) <= din_tmp;
end if;
end if;
end process;
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
ENTITY div2_9_en IS
PORT(
ain : IN std_logic_vector (12 downto 0) ;
enable : IN std_logic ;
aout : OUT std_logic_vector (11 downto 0)
);
-- Declarations
END div2_9_en ;
--
--
ARCHITECTURE struct OF div2_9_en IS
BEGIN
with enable select
aout <= ain(12 downto 1) when '1',
"000000000000" when others;
END struct;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
ENTITY reg12bits IS
PORT(
ain : IN std_logic_vector (11 downto 0) ;
clk : IN std_logic ;
enable : IN std_logic ;
aout : OUT std_logic_vector (11 downto 0)
);
-- Declarations
END reg12bits ;
--
--
ARCHITECTURE beh OF reg12bits IS
BEGIN
process(clk,enable)
begin
if enable = '0' then
aout <= "000000000000";
else
if rising_edge(clk) then
aout <= ain;
end if;
end if;
end process;
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
ENTITY reg13bits IS
PORT(
ain : IN std_logic_vector (12 downto 0) ;
clk : IN std_logic ;
enable : IN std_logic ;
aout : OUT std_logic_vector (12 downto 0)
);
-- Declarations
END reg13bits ;
--
--
ARCHITECTURE beh OF reg13bits IS
BEGIN
process(clk,enable)
begin
if enable = '0' then
aout <= "0000000000000";
else
if rising_edge(clk) then
aout <= ain;
end if;
end if;
end process;
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
ENTITY reg16bits IS
PORT(
ain : IN std_logic_vector (15 downto 0) ;
clk : IN std_logic ;
enable : IN std_logic ;
aout : OUT std_logic_vector (15 downto 0)
);
-- Declarations
END reg16bits ;
--
--
ARCHITECTURE beh OF reg16bits IS
BEGIN
process(clk,enable)
begin
if enable = '0' then
aout <= "0000000000000000";
else
if rising_edge(clk) then
aout <= ain;
end if;
end if;
end process;
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY ROM64 IS
PORT(
columns : IN std_logic_vector (2 downto 0) ;
compl : IN std_logic ;
enable_rom : IN std_logic ;
rows : IN std_logic_vector (2 downto 0) ;
output : OUT std_logic_vector (11 DOWNTO 0)
);
-- Declarations
END ROM64 ;
--
--
ARCHITECTURE beh OF ROM64 IS
-- ROM used for Forward Discrete Cosine Transform
type ROM_array is array (63 downto 0) of std_logic_vector(11 downto 0);
signal coeff_out : std_logic_vector(11 downto 0);
signal rt,ct : unsigned(2 downto 0);
--signal cmp_c1 : unsigned(11 downto 0);
signal cmp_c2 : std_logic_vector(11 downto 0);
--signal nottemp : std_logic_vector(7 downto 0);
signal coeff: ROM_array;
signal addr : integer range 0 to 63;
--signal ap : std_logic_vector(7 downto 0) := "01011011";
--signal bp : std_logic_vector(7 downto 0) := "01110110";
--signal cp : std_logic_vector(7 downto 0) := "00110001";
--signal dp : std_logic_vector(7 downto 0) := "01111110";
--signal ep : std_logic_vector(7 downto 0) := "01101010";
--signal fp : std_logic_vector(7 downto 0) := "01000111";
--signal gp : std_logic_vector(7 downto 0) := "00011001";
--signal am : std_logic_vector(7 downto 0) := "10100101";
--signal bm : std_logic_vector(7 downto 0) := "10001010";
--signal cm : std_logic_vector(7 downto 0) := "11001111";
--signal dm : std_logic_vector(7 downto 0) := "10000010";
--signal em : std_logic_vector(7 downto 0) := "10010110";
--signal fm : std_logic_vector(7 downto 0) := "10111001";
--signal gm : std_logic_vector(7 downto 0) := "11100111";
signal ap : std_logic_vector(11 downto 0) := "010110101000";
signal bp : std_logic_vector(11 downto 0) := "011101100100";
signal cp : std_logic_vector(11 downto 0) := "001100010000";
signal dp : std_logic_vector(11 downto 0) := "011111011001";
signal ep : std_logic_vector(11 downto 0) := "011010100111";
signal fp : std_logic_vector(11 downto 0) := "010001110010";
signal gp : std_logic_vector(11 downto 0) := "000110010000";
signal am : std_logic_vector(11 downto 0) := "101001011000";
signal bm : std_logic_vector(11 downto 0) := "100010011100";
signal cm : std_logic_vector(11 downto 0) := "110011110000";
signal dm : std_logic_vector(11 downto 0) := "100000100111";
signal em : std_logic_vector(11 downto 0) := "100101011001";
signal fm : std_logic_vector(11 downto 0) := "101110001110";
signal gm : std_logic_vector(11 downto 0) := "111001110000";
BEGIN
coeff(0) <= ap; -- A
coeff(1) <= ap; -- A
coeff(2) <= ap; -- A
coeff(3) <= ap; -- A
coeff(4) <= ap; -- A
coeff(5) <= ap; -- A
coeff(6) <= ap; -- A
coeff(7) <= ap; -- A
coeff(8) <= dp; -- D
coeff(9) <= ep; -- E
coeff(10) <= fp; -- F
coeff(11) <= gp; -- G
coeff(12) <= gm; -- -G
coeff(13) <= fm; -- -F
coeff(14) <= em; -- -E
coeff(15) <= dm; -- -D
coeff(16) <= bp; -- B
coeff(17) <= cp; -- C
coeff(18) <= cm; -- -C
coeff(19) <= bm; -- -B
coeff(20) <= bm; -- -B
coeff(21) <= cm; -- -C
coeff(22) <= cp; -- C
coeff(23) <= bp; -- B
coeff(24) <= ep; -- E
coeff(25) <= gm; -- -G
coeff(26) <= dm; -- -D
coeff(27) <= fm; -- -F
coeff(28) <= fp; -- F
coeff(29) <= dp; -- D
coeff(30) <= gp; -- G
coeff(31) <= em; -- -E
coeff(32) <= ap; -- A
coeff(33) <= am; -- -A
coeff(34) <= am; -- -A
coeff(35) <= ap; -- A
coeff(36) <= ap; -- A
coeff(37) <= am; -- -A
coeff(38) <= am; -- -A
coeff(39) <= ap; -- A
coeff(40) <= fp; -- F
coeff(41) <= dm; -- -D
coeff(42) <= gp; -- G
coeff(43) <= ep; -- E
coeff(44) <= em; -- -E
coeff(45) <= gm; -- -G
coeff(46) <= dp; -- D
coeff(47) <= fm; -- -F
coeff(48) <= cp; -- C
coeff(49) <= bm; -- -B
coeff(50) <= bp; -- B
coeff(51) <= cm; -- -C
coeff(52) <= cm; -- -C
coeff(53) <= bp; -- B
coeff(54) <= bm; -- -B
coeff(55) <= cp; -- C
coeff(56) <= gp; -- G
coeff(57) <= fm; -- -F
coeff(58) <= ep; -- E
coeff(59) <= dm; -- -D
coeff(60) <= dp; -- D
coeff(61) <= em; -- -E
coeff(62) <= fp; -- F
coeff(63) <= gm; -- -G
rt <= unsigned(rows);
ct <= unsigned(columns);
addr <= CONV_INTEGER(rt&ct);
with enable_rom select
coeff_out <= coeff(addr) when '1',
"000000000000" when others;
--nottemp <= not(coeff_out);
--cmp_c1 <= unsigned(nottemp) + "000000000001";
--cmp_c2 <= std_logic_vector(cmp_c1);
cmp_c2 <= not(coeff_out);
with compl select
output <= cmp_c2 when '1',
coeff_out when others;
END beh;
--
--
LIBRARY ieee ;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -