我正在编写我认为是相当标准的 VHDL 代码,但执行不断地回到我身上。
该代码旨在成为 Nexsys 3 板上的简单游戏。第一个玩家选择一个开关,当他们在开关本身上方时,LED 从它向下滚动显示一个空白。当滚动条到达选定的开关时,第二个玩家按下按钮。我的游戏部分是让 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);
但到目前为止,我没有尝试过修复它。
任何意见是极大的赞赏。
谢谢,
尤西夫·努里扎德