【verilog】十一、m序列發生器

一、定義

m序列:最長線性反饋移位寄存器序列的簡稱。是一種僞隨機序列、僞噪聲碼。

僞隨機序列:不能預先確定但可以重複實現的序列。

 

二、原理

 

遞推方程:

特徵方程:

x^i僅指明其係數代表ci的值,x本身的取值並無實際意義。

本原多項式:

若反饋移位寄存器的特徵多項式爲本原多項式,則移位寄存器能產生m序列。

若一個n次多項式f(x)滿足:

1)既約的:不能再因式分解;

2)可整除(x^m + 1), m = 2^n - 1;

3)除不盡(x^q + 1), q < m;

則稱:f(x)爲本原多項式。

三、實現

//以x8+x4+x3+x2+1爲例:
module m_sequence(
    input        sclk,
    input        rst_n,
    output        m_seq
);
 
parameter POLY = 8'b10001110;
reg [7 : 0] shift_reg;
 
always@(posedge sclk or negedge rst_n)
begin
    if(rst_n == 0)
    begin
        shift_reg <= 8'b11111111;
    end

    else
    begin
        shift_reg[7] <= (shift_reg[0] & POLY[7]) ^
                        (shift_reg[1] & POLY[6]) ^
                        (shift_reg[2] & POLY[5]) ^
                        (shift_reg[3] & POLY[4]) ^
                        (shift_reg[4] & POLY[3]) ^
                        (shift_reg[5] & POLY[2]) ^
                        (shift_reg[6] & POLY[1]) ^
                        (shift_reg[7] & POLY[0]);

        shift_reg[6 : 0] <= shift_reg[7 : 1];
    end
end
 
assign m_seq = shift_reg[0];
 
endmodule

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章