⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fcsr.m

📁 伪随机序列产生器-代进位反馈移位寄存器
💻 M
字号:
% Script file: fcsr.m
%
% Purpose:an algorithm to achieve the peseudorandom sequence with the size of T=12 by 
% FCSR block
% 
% 
% Record of revisions:  
% ==== ========== ===================== 
% 05/20/07 Xin Li Original code 
% Define variables:
% msinteger --state integer of mainregister
% csinteger --state integer of carries register
% rnd --the output sequence of the fcsr cipher
% k --Main register size
% q --Connection integer 
% d -- 
% T --the period of the output sequence 
% mkey --the key sequence for the main register
% ckey --the key sequence for the carries register
% m_register --the main register  matrix 
% cell --the carries register matrix 
% F --the filter function 
% S --the output sequence 



function [msinteger,csinteger,rnd]=fcsr
k=3;
T=12;
q=-13;
d=[0 1 1 1];% d=(abs(q)+1)/2.
F=d;
mkey=[zeros(1,3) 1];% key.
m_register = mkey;%The main register is initialized with the key K.
newregister=zeros(1,4);
newcell=zeros(1,4);
cell=zeros(1,4);% Carries register is initialized to 0.
%cell=ckey;
msinteger=zeros(1,T);
csinteger=zeros(1,T);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The output sequence--rnd of the FCSR%
% the mainregister's state integer--mregister and 
%carries rigister's state integer--cregister of the FCSR%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:T
    rnd(i)=m_register(4);
    for l=2:4
    msinteger(i)=msinteger(i)+m_register(l)*2.^(4-l); 
    end
    for l=2:4
    csinteger(i)=csinteger(i)+cell(l)*2.^(4-l); 
    end
    
    for j=2:4
       newregister(j)=xor(xor(m_register(j-1),d(j)*cell(j)),d(j)*m_register(4));
       newcell(j)=xor(xor(m_register(j-1)*cell(j),cell(j)*m_register(4)),m_register(j-1)*m_register(4));  
   end
   
m_register= newregister;
cell=newcell;
cell(2)=0;
end

%rnd=[m_register cell];
% m_register=mkey=[0 0 1],
%cell=ckey=[0 0 0]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -