selampl.vhd

来自「《CPLDFPGA嵌入式应用开发技术白金手册》源代码」· VHDL 代码 · 共 51 行

VHD
51
字号
--SEL_ampl 
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity sel_ampl is
port (
       key: in std_logic_vector(1 downto 0);
       ampl:in std_logic_vector(9 downto 0);
       in1: in std_Logic_vector(7 downto 0);
       in2: in std_logic;
       in3: in std_logic_vector(5 downto 0);
       dout: out std_logic_vector(9 downto 0);
       led1: out std_logic_vector(6 downto 0)
      );
end sel_ampl;

architecture beh of sel_ampl is
begin
 process(key)
       variable temp: std_logic_vector(9 downto 0);
       variable temp2:std_logic_vector(9 downto 0);
       variable temp1:std_logic_vector(9 downto 0);
    begin
       temp(1 downto 0):=ampl(4 downto 3);
       temp(9 downto 2):="00000000";
       temp2(3 downto 0):=ampl(6 downto 3);
       temp2(9 downto 4):="000000";
       case key is
       when "01" =>
                   temp1:=temp1(1 downto 0)*in1+in1;
                   dout<=temp1;
                   led1<="1111001";
	   when "10" =>
				case in2 is
					when '1'=> dout<=ampl;
					when others=>dout<="0000000000";
				end case;
				led1 <="0100100";
	  when "11" =>
      			temp1:=temp2(3 downto 0)*in3+in3;
                dout<=temp1;
       			led1<="0110000";
	 when others =>
     			dout<="0000000000";
      	        led1<="1111111";
  	 end case;
end process;
end beh;

⌨️ 快捷键说明

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