Я когда-то делал универсальный генератор m-последовательностей следующим образом:
library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all;
entity GaloisPRNG is generic( PN : std_logic_vector := O"325" ); port( CLK : in STD_LOGIC; PRN : in STD_LOGIC; Q : out STD_LOGIC ); end GaloisPRNG;
architecture rtl of GaloisPRNG is
function calcN (P : std_logic_vector) return natural is variable tN : natural; begin tN := 0; for i in P'Length-1 downto 0 loop if P(i) = '1' then tN := i; end if; end loop; return P'Length - tN - 1; end; constant N : natural := calcN(PN); signal A, X : STD_LOGIC_VECTOR(N-1 downto 0); constant P : STD_LOGIC_VECTOR (N downto 0) := PN (PN'Length-N-1 to PN'Length-1);
begin
A(N-1) <= X(0); process ( X ) begin for i in N-2 downto 0 loop if P(i+1) = '0' then A(i) <= X(i+1); elsif P(i+1) = '1' then A(i) <= X(i+1) xor X(0); end if; end loop; end process;
process ( CLK, PRN ) begin if PRN = '0' then X <= ( others => '1' ); elsif CLK'event and CLK = '1' then X <= A; end if; end process; Q <= X(0);
end rtl;
Задаешь нужный полином (PN) и получаешь желаемый генератор.
|