Vhdl LFSR仅在模拟器上不在FPGA上工作

Vhdl LFSR仅在模拟器上不在FPGA上工作,vhdl,fpga,Vhdl,Fpga,我试图看到一个8位LFSR在Altera DE2上工作,我用VHDL写了一个代码,它在ModelSim上运行良好,但在FPGA上看不到它工作。代码如下: library ieee; use ieee.std_logic_1164.all; entity lfsr_8bit is port ( CLOCK_50 : in std_logic; rst : in std_logic; LEDG : out std_logic_vector(7 downto 0)); end

我试图看到一个8位LFSR在Altera DE2上工作,我用VHDL写了一个代码,它在ModelSim上运行良好,但在FPGA上看不到它工作。代码如下:

library ieee;
use ieee.std_logic_1164.all;

entity lfsr_8bit is
port (
    CLOCK_50 : in std_logic;
    rst : in std_logic;
    LEDG : out std_logic_vector(7 downto 0));
end lfsr_8bit;

architecture behaviour of lfsr_8bit is
    signal lfsr_done : std_logic;
    signal rand : std_logic_vector(7 downto 0);
begin
    ciclo : process (CLOCK_50, rst)
    begin


            if (rst='0') then
                rand      <= "00000001"; -- seed
                lfsr_done <= '0';
            elsif (CLOCK_50'EVENT AND CLOCK_50 = '1') then
                   if rand = "10000000" then
                    lfsr_done <= '1';
                   end if;
                   if lfsr_done = '0' then
                    rand(0) <= rand(6) xor rand(7);
                    rand(7 downto 1) <= rand(6 downto 0);
                   end if; 
            end if;
            LEDG <= rand(7 downto 0);
    end process ciclo;
end behaviour;
我在FPGA上只能看到种子00000001,仅此而已。我想这是因为时钟,它对我的眼睛来说更快,但我不知道如何修复它,因为我开始用VHDL编程。我也试着把时钟换成一个按钮,但也没用。以下是我的尝试:

library ieee;
use ieee.std_logic_1164.all;

entity lfsr_8bit is
port (

    KEY : in std_logic_vector(3 downto 0);
    rst : in std_logic;
    LEDG : out std_logic_vector(7 downto 0));
end lfsr_8bit;

architecture behaviour of lfsr_8bit is
    signal lfsr_done : std_logic;
    signal rand : std_logic_vector(7 downto 0);
begin
    ciclo : process (KEY, rand, rst)
    begin

            if (rst='0') then
                rand      <= "00000001"; -- seed
                lfsr_done <= '0';
            elsif (KEY(0) = '0') then
                   if rand = "10000000" then
                    lfsr_done <= '1';
                   end if;
                   if lfsr_done = '0' then
                    rand(0) <= rand(6) xor rand(7);
                    rand(7 downto 1) <= rand(6 downto 0);
                   end if; 
            end if;
            LEDG <= rand(7 downto 0);
    end process ciclo;
end behaviour;

谢谢您的帮助。

我认为您在FPGA上看到种子是正常的,因为它是信号rand将停止的值

在rand为10000000的时钟周期中,lfsr_done将设置为“1”,但rand也将更改!在这个时钟周期中,lfsr_done仍然是“0”。然后rand收到值00000001,将永远不会再演变

您确定没有在modelsim上看到此行为吗

我建议,不要使用按钮来触发这个过程,而是使用1或2赫兹的极低频时钟。您可以在其他进程中使用计数器轻松创建它。也可以使用与结束值不同的其他种子值


还有一件事,线LEDG很可能不起作用,这意味着你也看到了兰特的重置值?这两者的两个共同点是复位。它来自于设备的哪一个地方是正确的极性?KEY0看起来应该被反弹回,否则您将无法准确地看到序列。可能错误的时钟或重置连接的共同点还可能包括到FPGA的引脚连接。您确定从另一端看到的是00000001而不是10000000吗?抱歉,花了这么多时间回答,因为我在旅行。嗯,我想你是对的,我看到的是另一端的1000000。可能是重置问题,我不知道,我会再看一遍。谢谢你的帮助