2013-03-30 42 views
0

我正在寫我認爲會是相當標準的VHDL代碼,但執行不斷回來。串聯VHDL轉換

該代碼旨在成爲Nexsys 3板上的簡單遊戲。第一個播放器選擇一個開關,當它從開關上方向下滾動時,顯示一個空白。第二位玩家在滾動到達所選開關時按下一個按鈕。我的遊戲的一部分是讓LED滾動。我的代碼可以在下面查看:

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 
use IEEE.STD_LOGIC_UNSIGNED.ALL; 
use IEEE.NUMERIC_STD.ALL; 

entity Two_Player_3_24_2013 is 
port( clk:  in std_logic; 
     rst:  in std_logic; 
     switches: in std_logic_vector(7 downto 0); 
     led_indic: out std_logic_vector(7 downto 0)   
); 

end Two_Player_3_24_2013; 

architecture Behavioral of Two_Player_3_24_2013 is 

signal count: std_logic_vector(31 downto 0):= "00000000000000000000000000000000";  
signal only_one: std_logic := '0'; 
signal shifter: std_logic_vector(7 downto 0) := "00000000"; 

begin 

only_one <= '1' when switches = "10000000" else 
      '1' when switches = "01000000" else 
      '1' when switches = "00100000" else 
      '1' when switches = "00010000" else 
      '1' when switches = "00001000" else 
      '1' when switches = "00000100" else 
      '1' when switches = "00000010" else 
      '1' when switches = "00000001" else 
      '0'; 

counting: process(clk, rst, only_one) 
    begin 
    if (rst = '1') then 
    count <= "00000000000000000000000000000000"; 
    elsif (clk'event and clk='1' and only_one = '1') then 
    count <= count + '1'; 
    end if; 
end process counting; 


shifting: process(clk, rst, count, shifter) 
    begin 
    if (rst = '1') then 
    shifter <= "00000000"; 
    elsif (clk'event and clk='1' and count = "00000000000000010000000000000000") then 
    shifter <= switches; 
    elsif (clk'event and clk='1' and count(25) = '1') then 
    shifter <= shifter(0) & shifter(7 downto 1); 
    end if; 
end process shifting; 

led_indic <= shifter; 

end Behavioral; 

現在我已經檢查了零件的個別和他們的工作。僅當一個開關打開時,only_one信號才爲真。計數器在正確的時間開始,第一個開關也在正確的時間觸發。出於某種原因,我仍然無法弄清楚,但是,它拒絕滾動。我試過在主板上和模擬中都運行這個,但我無法弄清楚爲什麼滾動不起作用。原始設置只發生在特定的時間,而連接應該定期發生。我知道問題是與

shifter <= shifter(0) & shifter(7 downto 1); 

但到目前爲止我沒有嘗試過已修復它。

任何意見非常感謝。

感謝,
Yusif Nurizade

回答

1

我在模擬猜你只需要等待;-)

當您使用100MHz的時鐘,花費〜335ms,直到出了什麼事(計數(25 ) 高)。只要計數(25)很高,LED就會非常快地移動,接下來的335ms結束於與它們開始相同的位置。 - >因此調整你的計數器

爲遊戲本身重新思考「轉移while count(25)='1'」的東西!它更有意義只在一個counterposition轉移(例如,如果計數= X「01000000」 ......)

BTW:合成它不是實現諸如

elsif (clk'event and clk='1' and count(25) = '1')) then 

你應該門控時鐘好的做法而使用例如:

elsif (clk'event and clk='1') then 
    if count(25) = '1' then 
     ... 
+0

禿子, 太感謝你了,立即定了! Yusif Nurizade –