|
各位大俠:
我有一個程序,輸入頻率為1kHz,另有兩個輸入口接了撥碼開關(guān)(撥碼開關(guān)ON接地,OFF懸空)。通過輸入"00","01","10","11"來讓輸出口輸出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”時能輸出500Hz與125Hz,而"01"與"11"不正常,也就是說當撥碼開關(guān)的1腳接地時,撥碼開關(guān)的2腳接地與懸空能正常輸出頻率;當撥碼開關(guān)的1腳懸空時,輸出頻率就不正常了。這是為什么?請大俠們指點。謝謝!
|
|