|
各位大俠:
我有一個(gè)程序,輸入頻率為1kHz,另有兩個(gè)輸入口接了撥碼開(kāi)關(guān)(撥碼開(kāi)關(guān)ON接地,OFF懸空)。通過(guò)輸入"00","01","10","11"來(lái)讓輸出口輸出500Hz,250Hz,125Hz,67.5Hz。
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
Entity fen is
port( xh:in std_logic;
ds:in std_logic_vector(1 downto 0);
sc:out std_logic);
End fen;
Architecture fenpin of fen is
Signal data:std_logic_vector(3 downto 0);
begin
yi:process(xh)
begin
if(xh'event and xh='1') then
data<=data+1;
end if;
end process;
er:process(ds,data)
begin
case ds is
when "00"=>sc<=data(0);
when "01"=>sc<=data(1);
when "10"=>sc<=data(2);
when "11"=>sc<=data(3);
when others=>NULL;
end case;
end process;
end fenpin;
我用的芯片是EPM7064STC44-10,xh為40腳,sc為6腳,ds[0]為10腳,ds[1]為11腳。只有“00”與“10”時(shí)能輸出500Hz與125Hz,而"01"與"11"不正常,也就是說(shuō)當(dāng)撥碼開(kāi)關(guān)的1腳接地時(shí),撥碼開(kāi)關(guān)的2腳接地與懸空能正常輸出頻率;當(dāng)撥碼開(kāi)關(guān)的1腳懸空時(shí),輸出頻率就不正常了。這是為什么?請(qǐng)大俠們指點(diǎn)。謝謝!
|
|