

Код
library IEEE;
use IEEE.std_logic_1164.all;
entity Scrambler_1 is
port (
CLK: in std_logic;
data_in: in std_logic;
data_out: out std_logic;
CLK_out:out std_logic
);
end entity;
architecture Scrambler_1 of Scrambler_1 is
signal STATE:integer:=0;
begin
process(CLK)
variable reg:std_logic_vector(19 downto 0):=(others =>'1');
variable a:std_logic;
variable b:std_logic;
variable c:std_logic;
variable d:std_logic;
variable e:std_logic;
variable counter:integer;
begin
if(CLK'event and CLK='1' ) then
CASE STATE is
when 0=>
CLK_out<='0';
--Initial values;
reg(19 downto 0):=(others =>'1');
counter:=31;
a:=reg(0) xor reg(8);
b:=reg(2) xnor reg(19);
c:='0';
d:=b xnor c;
e:=data_in xnor d;
data_out<=e;
STATE<=1;
when 1=>
e:=data_in xnor d;
CLK_out<='0';
--sdvig registra
reg(19 downto 1):=reg(18 downto 0);
reg(0):=e;
a:=reg(0) xor reg(8);
b:=reg(2) xnor reg(19);
counter:=counter+1;
if(a='1') then
counter:=31;
end if;
if(counter=32) then
counter:=0;
end if;
if(counter=30) then
c:='1';
else
c:='0';
end if;
d:=b xnor c;
e:=data_in xnor d;
data_out<=e;
STATE<=2;
when 2=>
CLK_out<='1';
STATE<=1;
when others => null;
end case;
end if;
end process;
end architecture;
use IEEE.std_logic_1164.all;
entity Scrambler_1 is
port (
CLK: in std_logic;
data_in: in std_logic;
data_out: out std_logic;
CLK_out:out std_logic
);
end entity;
architecture Scrambler_1 of Scrambler_1 is
signal STATE:integer:=0;
begin
process(CLK)
variable reg:std_logic_vector(19 downto 0):=(others =>'1');
variable a:std_logic;
variable b:std_logic;
variable c:std_logic;
variable d:std_logic;
variable e:std_logic;
variable counter:integer;
begin
if(CLK'event and CLK='1' ) then
CASE STATE is
when 0=>
CLK_out<='0';
--Initial values;
reg(19 downto 0):=(others =>'1');
counter:=31;
a:=reg(0) xor reg(8);
b:=reg(2) xnor reg(19);
c:='0';
d:=b xnor c;
e:=data_in xnor d;
data_out<=e;
STATE<=1;
when 1=>
e:=data_in xnor d;
CLK_out<='0';
--sdvig registra
reg(19 downto 1):=reg(18 downto 0);
reg(0):=e;
a:=reg(0) xor reg(8);
b:=reg(2) xnor reg(19);
counter:=counter+1;
if(a='1') then
counter:=31;
end if;
if(counter=32) then
counter:=0;
end if;
if(counter=30) then
c:='1';
else
c:='0';
end if;
d:=b xnor c;
e:=data_in xnor d;
data_out<=e;
STATE<=2;
when 2=>
CLK_out<='1';
STATE<=1;
when others => null;
end case;
end if;
end process;
end architecture;
У меня получается последовательность: 0xFF,0xFF,0xFF,0xFD,0xB6,0xDB