?? amp.vhd
字號:
library ieee ;
use ieee.std_logic_1164.all ;
use ieee.std_logic_arith.all ;
entity amp is
port (clk : in std_logic ;
panel : in std_logic_vector (7 downto 0);
amp : in std_logic_vector (7 downto 0);
panelsel : out std_logic; --控制cd4053決定放大器所測屏是LCD OR PDP
pu : out std_logic;
pd : out std_logic --控制電位器x9511的電阻變化情況
) ;
end amp ;
architecture rtl of amp is
signal clkout : std_logic ;
signal ctrl : std_logic ;
signal ctrl31_enable : std_logic ;
signal ctrl52_enable : std_logic ;
signal ctrl56_enable : std_logic ;
signal ctrl58_enable : std_logic ;
signal ctrl59_enable : std_logic ;
signal ctrl60_enable : std_logic ;
signal amp1 : std_logic_vector (3 downto 0);
signal amp2 : std_logic_vector (3 downto 0);
signal count31 : unsigned (26 downto 0);
signal count52 : unsigned (27 downto 0);
signal count56 : unsigned (27 downto 0);
signal count58 : unsigned (27 downto 0);
signal count59 : unsigned (27 downto 0);
signal count60 : unsigned (27 downto 0);
COMPONENT count IS
port
(
clkin : in std_logic ;
clkout : out std_logic
) ;
END COMPONENT;
begin
U1: count
PORT MAP
(
clkin => clk,
clkout => clkout
);
process(clk)
begin
if clk'event and clk = '1' then
case panel is
WHEN "00000000"=> panelsel <= '0'; --所測屏為LCD
WHEN "10000000"=> panelsel <= '1'; --所測屏為PDP
when others => panelsel <= '0';
end case;
end if;
end process;
process(clk)
begin
if clk'event and clk = '1' then
case amp is
WHEN "00000000"=> amp1 <= "0000";
amp2 <= amp1 ;
WHEN "10000000"=> amp1 <= "0001";
amp2 <= amp1 ;
WHEN "11000000"=> amp1 <= "0011";
amp2 <= amp1 ;
WHEN "10100000"=> amp1 <= "0101";
amp2 <= amp1 ;
WHEN "11100000"=> amp1 <= "0111";
amp2 <= amp1 ;
WHEN "10010000"=> amp1 <= "1001";
amp2 <= amp1 ;
WHEN "11010000"=> amp1 <= "1011";
amp2 <= amp1 ;
WHEN "10110000"=> amp1 <= "1101";
amp2 <= amp1 ;
WHEN "11110000"=> amp1 <= "1111";
amp2 <= amp1 ;
when others => amp1 <= "0001";
amp2 <= amp1 ;
end case;
end if;
end process;
process(clk)
begin
if clk'event and clk = '1' then
if amp1=amp2 then
ctrl <= '0';
else ctrl <= '1';
end if;
end if;
end process;
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl31_enable <= '1';
elsif std_logic_vector(count31) = "101000000000000000000000000" then
ctrl31_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl31_enable)
begin
if clk'event and clk = '1' then
if ctrl31_enable = '0' then
count31 <= "000000000000000000000000000" ;
else
count31 <= count31 + "000000000000000000000000001" ;
end if ;
end if ;
end process ; --將電位器示數調整位最大,x9511共有31級(10k/31是每一級的阻值)
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl52_enable <= '1';
elsif std_logic_vector(count52) = "1000001000000000000000000000" then
ctrl52_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl52_enable)
begin
if clk'event and clk = '1' then
if ctrl52_enable = '0' then
count52 <= "0000000000000000000000000000" ;
else
count52 <= count52 + "0000000000000000000000000001" ;
end if ;
end if ;
end process ; --從電位器最大值調整至3倍的放大倍數
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl56_enable <= '1';
elsif std_logic_vector(count56) = "1000101010000000000000000000" then
ctrl56_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl56_enable)
begin
if clk'event and clk = '1' then
if ctrl56_enable = '0' then
count56 <= "0000000000000000000000000000" ;
else
count56 <= count56 + "0000000000000000000000000001" ;
end if ;
end if ;
end process ; --5倍的放大倍數
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl58_enable <= '1';
elsif std_logic_vector(count58) = "1000111110000000000000000000" then
ctrl58_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl58_enable)
begin
if clk'event and clk = '1' then
if ctrl58_enable = '0' then
count58 <= "0000000000000000000000000000" ;
else
count58 <= count58 + "0000000000000000000000000001" ;
end if ;
end if ;
end process ; --7倍的放大倍數
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl59_enable <= '1';
elsif std_logic_vector(count59) = "1001001000000000000000000000" then
ctrl59_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl59_enable)
begin
if clk'event and clk = '1' then
if ctrl59_enable = '0' then
count59 <= "0000000000000000000000000000" ;
else
count59 <= count59 + "0000000000000000000000000001" ;
end if ;
end if ;
end process ; --9,11倍的放大倍數
process(clk)
begin
if clk'event and clk = '1' then
if ctrl = '1' then
ctrl60_enable <= '1';
elsif std_logic_vector(count60) = "1001010010000000000000000000" then
ctrl60_enable <= '0';
end if;
end if;
end process;
process (clk, ctrl60_enable)
begin
if clk'event and clk = '1' then
if ctrl60_enable = '0' then
count60 <= "0000000000000000000000000000" ;
else
count60 <= count60 + "0000000000000000000000000001" ;
end if ;
end if ;
end process ; --13,15倍的放大倍數
process(clk,amp1)
begin
if clk'event and clk = '1' then
if amp1 = "0001" then
pu <= clkout;
pd <= '0';
elsif amp1 = "0011" then
if ctrl31_enable = '1' and ctrl52_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl52_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "0101" then
if ctrl31_enable = '1' and ctrl56_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl56_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "0111" then
if ctrl31_enable = '1' and ctrl58_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl58_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "1001" then
if ctrl31_enable = '1' and ctrl59_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl59_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "1011" then
if ctrl31_enable = '1' and ctrl59_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl59_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "1101" then
if ctrl31_enable = '1' and ctrl60_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl60_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
elsif amp1 = "1111" then
if ctrl31_enable = '1' and ctrl60_enable = '1' then
pu <= clkout;
pd <= '0';
elsif ctrl31_enable = '0' and ctrl60_enable = '1' then
pu <= '0';
pd <= clkout;
else pu <= '0';
pd <= '0';
end if;
end if;
end if;
end process; --調整過程:接收到數據后先將電位器調整為最大值,之后再按要求往下調整
end;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -