首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LFSR仅在模拟器上不能在FPGA上工作

LFSR仅在模拟器上不能在FPGA上工作
EN

Stack Overflow用户
提问于 2014-08-02 04:24:17
回答 1查看 184关注 0票数 0

我试着看到一个8位的LFSR在Altera上工作,我用VHDL语言写了一个代码,它在ModelSim上工作得很好,但我看不到它在DE2上工作。代码如下:

代码语言:javascript
复制
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上看到的只有seed (00000001),别的什么也没有。我认为这是因为时钟,它对我的眼睛来说更快,但我不知道如何解决这个问题,因为我开始用VHDL编程。我也试着把时钟换成按钮,但也不起作用。下面是我尝试的方法:

代码语言:javascript
复制
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;

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2014-08-19 16:18:17

我认为在FPGA上看到seed是很正常的,因为它是信号"rand“将停止的值。

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

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

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

还有一件事,"LEDG <= rand(7 downto 0);“这一行可能在进程之外,而它只是并发语句。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25088119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档