⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dctslow.vhd

📁 算术处理器的VERILOG hdl的源代码
💻 VHD
📖 第 1 页 / 共 2 页
字号:
-- 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)   );-- DeclarationsEND add12slow ;----ARCHITECTURE beh OF add12slow ISsignal output_temp : unsigned(12 downto 0);BEGINoutput_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)   );-- DeclarationsEND add16bits ;----ARCHITECTURE beh OF add16bits ISsignal output_temp : unsigned(15 downto 0);BEGINoutput_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)   );-- DeclarationsEND and15 ;----ARCHITECTURE struct OF and15 ISBEGINwith 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    );-- DeclarationsEND cyclereg ;----ARCHITECTURE beh OF cyclereg ISsignal internal : std_logic_vector(95 downto 0);signal din_tmp : std_logic;signal op_mode : std_logic_vector(2 downto 0);BEGINop_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)   );-- DeclarationsEND div2_9_en ;----ARCHITECTURE struct OF div2_9_en ISBEGINwith 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)   );-- DeclarationsEND reg12bits ;----ARCHITECTURE beh OF reg12bits ISBEGINprocess(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)   );-- DeclarationsEND reg13bits ;----ARCHITECTURE beh OF reg13bits ISBEGINprocess(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)   );-- DeclarationsEND reg16bits ;----ARCHITECTURE beh OF reg16bits ISBEGINprocess(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)   );-- DeclarationsEND ROM64 ;----ARCHITECTURE beh OF ROM64 IS-- ROM used for Forward Discrete Cosine Transformtype 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";BEGINcoeff(0) <= ap;    --     Acoeff(1) <= ap;    --     Acoeff(2) <= ap;    --     Acoeff(3) <= ap;    --     Acoeff(4) <= ap;    --     Acoeff(5) <= ap;    --     Acoeff(6) <= ap;    --     Acoeff(7) <= ap;    --     Acoeff(8) <= dp;    --     Dcoeff(9) <= ep;    --     Ecoeff(10) <= fp;   --     Fcoeff(11) <= gp;   --     Gcoeff(12) <= gm;   --    -Gcoeff(13) <= fm;   --    -F   coeff(14) <= em;   --    -Ecoeff(15) <= dm;   --    -Dcoeff(16) <= bp;   --     Bcoeff(17) <= cp;   --     Ccoeff(18) <= cm;   --    -Ccoeff(19) <= bm;   --    -Bcoeff(20) <= bm;   --    -Bcoeff(21) <= cm;   --    -Ccoeff(22) <= cp;   --     Ccoeff(23) <= bp;   --     Bcoeff(24) <= ep;   --     Ecoeff(25) <= gm;   --    -Gcoeff(26) <= dm;   --    -Dcoeff(27) <= fm;   --    -Fcoeff(28) <= fp;   --     Fcoeff(29) <= dp;   --     Dcoeff(30) <= gp;   --     Gcoeff(31) <= em;   --    -Ecoeff(32) <= ap;   --     Acoeff(33) <= am;   --    -Acoeff(34) <= am;   --    -Acoeff(35) <= ap;   --     Acoeff(36) <= ap;   --     Acoeff(37) <= am;   --    -Acoeff(38) <= am;   --    -Acoeff(39) <= ap;   --     Acoeff(40) <= fp;   --     Fcoeff(41) <= dm;   --    -Dcoeff(42) <= gp;   --     Gcoeff(43) <= ep;   --     Ecoeff(44) <= em;   --    -Ecoeff(45) <= gm;   --    -Gcoeff(46) <= dp;   --     Dcoeff(47) <= fm;   --    -Fcoeff(48) <= cp;   --     Ccoeff(49) <= bm;   --    -Bcoeff(50) <= bp;   --     Bcoeff(51) <= cm;   --    -Ccoeff(52) <= cm;   --    -Ccoeff(53) <= bp;   --     Bcoeff(54) <= bm;   --    -Bcoeff(55) <= cp;   --     Ccoeff(56) <= gp;   --     Gcoeff(57) <= fm;   --    -Fcoeff(58) <= ep;   --     Ecoeff(59) <= dm;   --    -Dcoeff(60) <= dp;   --     Dcoeff(61) <= em;   --    -Ecoeff(62) <= fp;   --     Fcoeff(63) <= gm;   --    -Grt <= unsigned(rows);ct <= unsigned(columns);addr <= CONV_INTEGER(rt&ct);with enable_rom selectcoeff_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 selectoutput <= cmp_c2 when '1',	  coeff_out when others;	END beh;----LIBRARY ieee ;USE ieee.std_logic_1164.all;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -