我正在寫我認爲會是相當標準的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
禿子, 太感謝你了,立即定了! Yusif Nurizade –