【问题标题】:LFSR not working on the FPGA only on the simulatorLFSR 仅在模拟器上不能在 FPGA 上工作
【发布时间】:2014-08-01 20:24:16
【问题描述】:

我试图看到一个 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;

感谢您的帮助。

【问题讨论】:

  • “不起作用”是否意味着您也看到了 rand 的重置值?这两件事的共同点是重置。它来自设备中的哪里是正确的极性? KEY(0) 看起来应该是去弹跳的,否则你将无法准确地看到序列。可能错误的时钟或复位连接的共同点还可能包括与 FPGA 的引脚连接。
  • 您确定从另一端看到的是“00000001”而不是“10000000”吗?
  • 抱歉花了这么多时间来回答,因为我正在旅行。好吧,我认为你是对的,我看到的是另一端的“1000000”。可能是重置问题,我不知道,我再看看。感谢您的帮助

标签: vhdl fpga


【解决方案1】:

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

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

您确定在 modelsim 上看不到这种行为吗?

我建议不要使用按钮来触发该过程,而是使用频率非常低的时钟(1 或 2 Hz)。您可以在其他过程中使用计数器轻松创建它。您还可以使用与最终值不同的其他种子值。

还有一件事,“LEDG

【讨论】:

    猜你喜欢
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-27
    • 2012-08-19
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多