當前位置:首頁 » 打游戲機 » 帶獲勝音樂拔河游戲機
擴展閱讀
天成解說一個人的游戲 2021-03-16 21:51:02
打游戲什麼牌子顯卡好 2021-03-16 21:51:00

帶獲勝音樂拔河游戲機

發布時間: 2021-03-01 02:32:45

Ⅰ EDA 課程設計 ——拔河游戲機

一、總體設計思想
電子拔河游戲機是一種能容納甲乙雙方參賽游戲電路。由一排發光二極體表示拔河的「電子繩」。由甲乙雙方通過按紐開關使發光二極體向一方的終點延伸,當延伸到某方的最後一個發光二極體時, 則該方獲勝,連續比賽多局以定勝負。

1.基本原理
本電路要求使用9個發光二極體,開機後只有中間一個發亮,此即拔河的中心點。游戲雙方各持一個按鈕,迅速地、不斷地按動,產生脈沖,誰按得快,亮點就向誰的方向移動,每按一次,亮點移動一次。亮點移到任一方終端二極體時,這一方就獲勝,此時雙方按鈕均無作用,輸出保持,只有復位後才使亮點恢復到中心。最後用數碼管顯示獲勝者的盤數。
由設計內容可知,首先需要一個十進制的計數器,用於對雙方按鈕的次數計數,並通過解碼器顯示在數碼管上。設計要求用50MHz的頻率,而設計用到的是1K Hz的頻率,所以要設計一個程序進行分頻。其次,顯視控制部分設計要求在發光二極體上顯示游戲狀態,雙方每按十次,亮點向先按十次移動一次,對脈沖進行計數,每十次移一位。需接入一個清零端 ,用於復位。再次,運用VHDL程序語言進行各個模塊的程序編寫,控制電路的正常運行。最後,將以上程序組裝起來,就可得到所需要的拔河游戲機
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity bahe is
port (a,b,rst,clk:in std_logic;
sg,led:out std_logic_vector(8 downto 0);
bt:out std_logic_vector(7 downto 0));
end bahe;
----------------------------------
architecture one of bahe is
component cnt10
port (clk,rst,en:std_logic;
cout:out std_logic;
cq:out std_logic_vector(3 downto 0));
end component;
component scan
port (clk :in std_logic;
a1, a2,a3,b1,b2,b3:in std_logic_vector(3 downto 0);
sg:out std_logic_vector(8 downto 0);
bt: out std_logic_vector(7 downto 0));
end component;
component lmov
port (kl ,kr:in std_logic_vector(3 downto 0) ;
led:out std_logic_vector(8 downto 0);
en : out std_logic;
rst:in std_logic);
end component;
signal e,f,ca1,ca2,cb1,cb2:std_logic;
signal cqa1,cqa2,cqa3,cqb1,cqb2,cqb3:std_logic_vector(3 downto 0);
begin
u1: cnt10 port map (en=>e,rst=>rst,clk=>a,cout=>ca1,cq=>cqa1);
u2: cnt10 port map (en=>e,rst=>rst,clk=>ca1,cout=>ca2,cq=>cqa2);
u3: cnt10 port map (en=>e,rst=>rst,clk=>ca2,cq=>cqa3);
u4: cnt10 port map (en=>e,rst=>rst,clk=>b,cout=>cb1,cq=>cqb1);
u5: cnt10 port map (en=>e,rst=>rst,clk=>cb1,cout=>cb2,cq=>cqb2);
u6: cnt10 port map (en=>e,rst=>rst,clk=>cb2,cq=>cqb3);
u7: scan port map (a1=>cqa1,a2=>cqa2,a3=>cqa3,b1=>cqb1,
b2=>cqb2,b3=>cqb3,clk=>clk,sg=>sg,bt=>bt);
u8:lmov port map (en=>e,kl=>cqa2,kr=>cqb2,rst=>rst,led=>led);
end architecture one;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt10 is
port(clk,rst,en:std_logic;
cout:out std_logic;
cq:out std_logic_vector(3 downto 0));
end;
architecture one of cnt10 is
begin
process(clk,rst,en)
variable cqi:std_logic_vector(3 downto 0);
begin
if rst='1' then
cqi:=(others=>'0');
elsif clk'event and clk='1' then
if en='1' then
if cqi<9 then cqi:=cqi+1;
else cqi :=(others=>'0');
end if ;
end if;
end if;
if c qi=9 then cout<='0' ;
else cout<='1';
end if;
cq<=cqi;
end process;
end;
電路的VHDL程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity scan is
port (clk :in std_logic;
a1,a2,a3,b1,b2,b3:in std_logic_vector(3 downto 0);
sg:out std_logic_vector(8 downto 0);
bt: out std_logic_vector(7 downto 0));
end;
architecture one of scan is
signal cnt4:std_logic_vector(2 downto 0);
signal a:std_logic_vector(3 downto 0);
signal clk1:std_logic;
begin
p1:process(cnt4)
begin
case cnt4 is
when "000"=>bt<="10000000";a<=a1;
when "001"=>bt<="01000000";a<=a2;
when "010"=>bt<="00100000";a<=a3;
when "011"=>bt<="00000100";a<=b1;
when "100"=>bt<="00000010";a<=b2;
when "101"=>bt<="00000001";a<=b3;
when others=>bt<="00000000";
end case ;
end process p1;
---------------------------------
p2:process (clk)
variable ct:integer range 0 to 50000;
begin
if clk'event and clk='1' then --1000HZ
if ct<49999 then
ct:=ct+1;
clk1<='0';
else
ct:=0;
clk1<='1';
end if;
end if;
end process p2;
process(clk1)
begin
if clk1'event an d clk1='1' then
if cnt4<5 then
cnt4<=cnt4+1;
else
cnt4<="000";
end if;
end if;
end process;
------------------------------------
process (a)
begin
case a is
when "0000"=>sg<="100000000";
when "0001"=>sg<="111110001";
when "0010"=>sg<="001001000";
when "0011"=>sg<="001100000";
when "0100"=>sg<="000110010";
when "0101"=>sg<="000100100";
when "0110"=>sg<="000000100";
when "0111"=>sg<="111110000";
when "1000"=>sg<="000000000";
when "1001"=>sg<="100011111";
when "1010"=>sg<="000100100";
when "1011"=>sg<="000011000";
when "1100"=>sg<="010001100";
when "1101"=>sg<="001001000";
when "1110"=>sg<="001000000";
when "1111"=>sg<="000011111";
when others=>null;
end case ;
end process;
end;
⑸ 勝負顯示
將雙方終端二極體正極經非門後的輸出分別接到二個CC4518計數器的EN端,CC4518的兩組4位BCD碼分別接到實驗裝置的兩組解碼顯示器的A、B、C、D插口處。當一方取勝時,該方終端二極體發亮,產生一個上升沿,使相應的計數器進行加一計數,於是就得到了雙方取勝次數的顯示,若一位數不夠,則進行二位數的級聯。
⑹ 復位
其VHDL程序如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity lmov is
port (kl ,kr:in std_logic_vector(3 downto 0) ;
led:out std_logic_vector(8 downto 0);
en : out std_logic;
rst:in std_logic);
end ;
architecture one of lmov is
begin
process(rst,kl,kr)
begin
if rst='1' then led<="111101111";en<='1';
elsif kl-kr=1 then led<="111011111";en<='1';
elsif kl-kr=2 then led<="110111111";en<='1';
elsif kl-kr=3 then led<="101111111";en<='1';
elsif kl-kr=4 then led<="011111111";en<='0';
elsif kr-kl=1 then led<="111110111";en<='1';
elsif kr-kl=2 then led<="111111011";en<='1' ;
elsif kr-kl=3 then led<="111111101";en<='1';
elsif kl-kr=4 then led<="111111110";en<='0';
elsif kr-kl=0 then led<="111101111";en<='1';
else null;
end if;
end process;
end;

Ⅱ 電子拔河游戲機 真的很急 我沒辦法了 麻煩你了 謝謝

這不是幾句話說得清的。好像是個畢業設計?

Ⅲ 求完整的基於vhdl的拔河游戲機EDA課程設計

用9個LED等當作拔河繩子,通過倒計時作為比賽開始信號
採用5局3勝制,完成一局比賽通過數碼管記錄雙方比分
當有一方得分為3則比賽結束,播放音樂。通過復位鍵重置比賽
這個我能夠給你

Ⅳ 拔河游戲機!

VHDL程序可分為四個模塊兒,即分頻器模塊、狀態機模塊、音樂播放器模塊和數碼管輸出模塊,若果需要防止抖動,還需要加防抖動模塊。

Ⅳ 電子拔河游戲機設計,高手來救~~~!

發了,名字叫電子拔河器 設計一個容納甲乙雙方參賽游戲電路。由一排LED發光二極體表示拔河的的「電子繩」。起始狀態為中間一個LED發光二極體亮,由甲乙互相觸發即可