Scroll 带串联的VHDL移位

Scroll 带串联的VHDL移位,scroll,concatenation,vhdl,bit-shift,Scroll,Concatenation,Vhdl,Bit Shift,我正在写我认为是相当标准的VHDL代码,但执行过程一直在我脑海中浮现 该代码旨在成为Nexsys 3板上的一个简单游戏。第一个播放器选择一个开关,LED从开关上向下滚动,当它们在开关上时显示空白。当滚动到选择的开关时,第二个播放机按下一个按钮。我的部分游戏是让LED滚动。我的代码可以在下面查看: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use IEEE.NUMERIC_STD.ALL;

我正在写我认为是相当标准的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;
但到目前为止,我还没试过什么办法

非常感谢您的建议

谢谢,

Yusif Nurizade

我想在模拟中,你只需等待;-)

当您使用100MHz时钟时,需要约335ms才能发生任何事情(计数(25)为高)。只要计数(25)处于高位,LED就会在接下来的335毫秒内快速移动,并在启动时的相同位置结束。 -->因此,调整计数器

对于游戏本身,请重新考虑“在计数时移位(25)='1'”这件事!仅在一个对位移动更有意义(例如,如果计数=X“01000000”…)

顺便说一句:对于合成来说,实现门控时钟(如

elsif (clk'event and  clk='1' and count(25) = '1')) then
您应该使用例如:

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

秃子,非常感谢你,马上就修好了!尤西夫努里扎德
elsif (clk'event and  clk='1') then
   if count(25) = '1' then
      ...