2.3 使能信號轉(zhuǎn)換模塊
數(shù)字秒表輸入的開始和停止信號是單個脈沖信號,而計數(shù)器要持續(xù)計數(shù)所需的使能信號是持續(xù)的高電平,所以需要通過使能控制電路實現(xiàn)使能信號的轉(zhuǎn)換。該模塊的VHDL源程序以及ModelSim仿真輸出結(jié)果如下:
該模塊源程序:
process(enablein)
begin
if(enablein‘event and enablein=’1‘)then
temp《= not temp;
end if ;
end process;
2.4 譯碼顯示模塊
由上面的設(shè)計可知,計數(shù)器輸出為二進制碼,不能直接點亮數(shù)碼管,要想將計數(shù)結(jié)果通過數(shù)碼管顯示必須再設(shè)計一個七段譯碼電路,以便將計數(shù)結(jié)果輸出。通過分析可知該譯碼器是一個4輸入,7輸出元件,其真值表如表1所示:
根據(jù)以上真值表可寫出譯碼電路VHDL源程序如下:
process(datainput)
begin
case datainput is
when “0000”=>dataoutput<=“0000010”;
when “0001”=>dataoutput<=“1001111”;
when “0010”=>dataoutput<=“0010001”;
when “0011”=>dataoutput<=“0000101”;
when “0100”=>dataoutput<=“1001100”;
when “0101”=>dataoutput<=“0100100”;
when “0110”=>dataoutput<=“0100000”;
when “0111”=>dataoutput<=“0001111”;
when “1000”=>dataoutput<=“0000000”;
when “1001”=>dataoutput<=“0000100”;
when others=>dataoutput<=“1111111”;
end case;
end process;
3 功能驗證以及下載實現(xiàn)
完成以上各個子模塊的設(shè)計后,該數(shù)字秒表的模塊設(shè)計就基本完成了,剩下的工作就是通過一個頂層文件將各個子模塊連接起來。在頂層文件中可以將以上各個子模塊看作一個個黑匣子,只將其輸入輸出端對應(yīng)相連就可以了。下面是該頂層文件的VHDL源程序:
architecture Behavioral of topfile is
signal clk:std_logic:=‘0’;
signal enableout:std_logic:=‘0’;
signal data0,data1,data2,
data3,data4,data5:std_logic_vector(3
downto 0):=“0000”;
component abc
port(clk:in std_logic;
dout:out std_logic);
end component;
component enable
port(enablein:in std_logic;
enableout:out std_logic);
end component;
component highlevel
port(rst,clk,clear:in std_logic;
output1,output2,output3,
output4,output5,output6:out
std_logic_vector(3 downto 0);
carryout:out std_logic);
end component;
component yima
port(datainput:in std_logic_vector(3 downto 0);
dataoutput: out std_logic_vector(6 downto 0));
end component;
begin
u0:abc port map(clkin,clk);
u1:enable port map(enablein,enableout);
u2:highlevel port map(enableout,clk,clear,data0,data1,data2,data3,data4,data5);
u3:yima port map(data0,dataout0);
u4:yima port map(data1,dataout1);
u5:yima port map(data2,dataout2);
u6:yima port map(data3,dataout3);
u7:yima port map(data4,dataout4);
u8:yima port map(data5,dataout5);
end Behavioral;
由于各個子模塊都已經(jīng)經(jīng)過驗證無誤,并且頂層文件中不涉及復(fù)雜的時序關(guān)系,相當于只是將各個模塊用導(dǎo)線連接起來,只要各個端口的連接對應(yīng)正確即可,所以不需寫專門的test bench進行驗證。完成以上設(shè)計后,即可進行邏輯綜合,綜合無誤后進行管腳適配,生成。bit文件然后下載到實驗板上測試。經(jīng)過反復(fù)多次測試,以上設(shè)計完全滿足了預(yù)期的設(shè)計指標,開始/停止按鍵和清零按鍵都能準確的控制秒表的運行,七段顯示數(shù)碼管也能夠準確的顯示計時結(jié)果。通過與標準秒表對比,該設(shè)計的計時誤差在0.03s以內(nèi),而這其中也包括實驗板上晶振由于長期使用所帶來的誤差。
4 結(jié)束語
本文所介紹數(shù)字秒表設(shè)計方法,采用了當下最流行的EDA設(shè)計手段。在Xinlinx FPGA開發(fā)環(huán)境下,采用至上而下的模塊化設(shè)計方法,使得系統(tǒng)開發(fā)速度快、成本低、系統(tǒng)性能大幅度提升。通過實驗驗證,本文設(shè)計的數(shù)字秒表計時準確、性能穩(wěn)定,可以很容易嵌入其他復(fù)雜的數(shù)字系統(tǒng),充當計時模塊。
利用EDA設(shè)計工具,結(jié)合基于FPGA的可編程實驗板,輕松實現(xiàn)電子芯片的設(shè)計,現(xiàn)場觀察實驗結(jié)果,大大縮短了產(chǎn)品的設(shè)計周期和調(diào)試周期,提高了設(shè)計的可靠性和成功率,體現(xiàn)了邏輯器件在數(shù)字設(shè)計中優(yōu)越性。
評論