標(biāo)題: VHDL防抖動(dòng)模塊程序以及解釋 [打印本頁(yè)]

作者: maiwenfeng    時(shí)間: 2017-5-22 09:58
標(biāo)題: VHDL防抖動(dòng)模塊程序以及解釋
libraryieee;  

useieee.std_logic_1164.all;

entityyou is定義實(shí)體

port(clk,din:in std_logic;系統(tǒng)時(shí)鐘和開關(guān)里程輸入脈沖

dout:out std_logic );輸出信號(hào)

endyou;  

architecturertl of you is定義結(jié)構(gòu)體

signalx,y:std_logic;定義兩個(gè)中間標(biāo)準(zhǔn)邏輯信號(hào)

begin  

process(clk) 進(jìn)程

begin

if clk'event and clk='1' then 判斷是否為上升沿

x<=din; 變量賦值

y<=x;

end if;

dout<=x and (not y); 去抖動(dòng)

end process;  

end rtl;



該模塊的的核心部分在于

if clk'event and clk='1' then  

x<=din; y<=x;

end if;

dout<=x and (not y);

   這是一個(gè)同步整形電路,在進(jìn)程中,信號(hào)不是在改變值之后立即變化的,其他語(yǔ)句使用的還是該信號(hào)的舊值(未執(zhí)行進(jìn)程時(shí)的值),所以假設(shè)y=0,那么在時(shí)鐘的上升沿:

如果:

   din="1"小于一個(gè)時(shí)鐘寬:則有x=1,y=0(雖然進(jìn)程中改變了值,但不會(huì)立即被使用);

   則有dout=x and (not y)=1 and (not 0)=1;

如果:

   din="1"超過一個(gè)時(shí)鐘寬:則有x=1,y=1(前次執(zhí)行進(jìn)程后,y的值已經(jīng)改變?yōu)椤?’了);

   則有dout=x and (not y)=1 and (not 1)=0;

如果din在時(shí)鐘周期內(nèi)出現(xiàn)抖動(dòng),則因?yàn)椴粓?zhí)行進(jìn)程,所以輸出無影響,還是被整成一個(gè)時(shí)鐘寬度,所以不管是長(zhǎng)按還是短按你的鍵,有效高電平寬度等于時(shí)鐘。









歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1