6

如何在FPGA中生成伪随机数?

4

4 回答 4

7

这已涵盖(我会选择 LFSR): Spartan-3E 上的随机数生成

于 2009-07-14T14:17:21.793 回答
5

关于在 FPGA 中高效生成伪随机数序列的赛灵思应用说明非常出色。它是XAPP052

于 2009-07-20T18:27:42.350 回答
4

如果不是用于密码学或其他具有智能对手(例如赌博)的应用程序,我会使用线性反馈移位寄存器方法。

它只使用异或和移位,因此在硬件上实现非常简单。

于 2009-07-14T14:20:40.027 回答
1

正如其他人所说,LFSR 可用于 FPGA 中的伪随机数。这是最大长度 32 位 LFSR 的 VHDL 实现。

process(clk)

  -- maximal length 32-bit xnor LFSR based on xilinx app note XAPP210
  function lfsr32(x : std_logic_vector(31 downto 0)) return std_logic_vector is
  begin
    return x(30 downto 0) & (x(0) xnor x(1) xnor x(21) xnor x(31));
  end function;

begin
  if rising_edge(clk) then
    if rst='1' then
      pseudo_rand <= (others => '0');
    else
      pseudo_rand <= lfsr32(psuedo_rand);
    end if;
  end if;
end process;
于 2013-09-18T16:49:18.750 回答