25:設(shè)計(jì)一個(gè)自動(dòng)飲料售賣機(jī),飲料10分錢,硬幣有5分和10分兩種,并考慮找零,
1.畫出fsm(有限狀態(tài)機(jī))
2.用verilog編程,語法要符合fpga設(shè)計(jì)的要求
3.設(shè)計(jì)工程中可使用的工具及設(shè)計(jì)大致過程?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity drink_auto_sale is
port(clk: in std_logic;
reset:in std_logic;
sw101:in std_logic;
sw102:in std_logic;
buy : out std_logic;
back: out std_logic);
end drink_auto_sale;
architecture Behavioral of drink_auto_sale is
type state_type is(st0,st1);
signal cs ,ns : state_type;
begin
process(clk,reset)
begin
if(reset = '1') then
cs <= st0;
elsif(clk'event and clk = '1') then
cs <= ns;
end if;
end process;
process(reset ,cs)
begin
case cs is
when st0 => if( sw101 = '1') then
ns <= st1;
buy<= '0';
back<= '0';
elsif(sw102 = '1') then
ns <= st0;
buy<= '1';
back <= '0';
else
ns <= st0 ;
buy <= '0';
back <= '0';
end if;
when st1 => if(sw101 = '1') then
ns <= st0;
buy <= '1';
back <= '0';
elsif(sw102 = '1') then
ns <= st0;
buy <= '1';
back <= '1';
end if;
when others => ns <= st0;
buy<= '0';
back <= '0';
end case;
end process;
end Behavioral;
設(shè)計(jì)過程:設(shè)定三個(gè)狀態(tài):0分,5分;當(dāng)狀態(tài)為0分時(shí),接收到5分信號(hào)脈沖后轉(zhuǎn)為5分;接收到10分信號(hào)脈沖時(shí),轉(zhuǎn)到0分狀態(tài),同時(shí)彈出飲料,不找零;狀態(tài)為5分時(shí),接受到5分信號(hào),彈出飲料,不找零,返回0分狀態(tài);當(dāng)接受到10分狀態(tài)時(shí),彈出飲料,找零,并返回零分狀態(tài)。
所用設(shè)計(jì)工具:ISE7.1,modelsim,synplify
(不知道為什么上面的狀態(tài)機(jī)設(shè)計(jì)在synplify的RTL view中沒能看到狀態(tài)機(jī)流程圖,所以狀態(tài)轉(zhuǎn)移圖就沒畫)。
Q26:什么是"線與"邏輯,要實(shí)現(xiàn)它,在硬件特性上有什么具體要求?
線與邏輯是兩個(gè)輸出信號(hào)相連可以實(shí)現(xiàn)與的功能。在硬件上,要用oc門來實(shí)現(xiàn),由于不用 oc門可能使灌電流過大,而燒壞邏輯門. 同時(shí)在輸出端口應(yīng)加一個(gè)上拉電阻。Oc門就是集電極開路門。
Q27:什么是競(jìng)爭(zhēng)與冒險(xiǎn)現(xiàn)象?怎樣判斷?如何消除?
在組合電路中,某一輸入變量經(jīng)過不同途徑傳輸后,到達(dá)電路中某一匯合點(diǎn)的時(shí)間有先有后,這種現(xiàn)象稱競(jìng)爭(zhēng);由于競(jìng)爭(zhēng)而使電路輸出發(fā)生瞬時(shí)錯(cuò)誤的現(xiàn)象叫做冒險(xiǎn)。(也就是由于競(jìng)爭(zhēng)產(chǎn)生的毛刺叫做冒險(xiǎn))。判斷方法:代數(shù)法(如果布爾式中有相反的信號(hào)則可能產(chǎn)生競(jìng)爭(zhēng)和冒險(xiǎn)現(xiàn)象);卡諾圖:有兩個(gè)相切的卡諾圈并且相切處沒有被其他卡諾圈包圍,就有可能出現(xiàn)競(jìng)爭(zhēng)冒險(xiǎn);實(shí)驗(yàn)法:示波器觀測(cè);
解決方法:1:加濾波電路,消除毛刺的影響;2:加選通信號(hào),避開毛刺;3:增加冗余項(xiàng)消除邏輯冒險(xiǎn)。
評(píng)論