2021年6月25日 星期五

HDLBits 32bit LFSR

HDLBits 32bit LFSR

See Lfsr5 for explanations.

Build a 32-bit Galois LFSR with taps at bit positions 32, 22, 2, and 1.

參考 5bit LFSR題,實現一個 32bit LFSR,

抽頭點為32,22,2,1。

提示:32bit 的 LFSR 最好使用向量實現



module top_module(
    input clk,
    input reset,    // Active-high synchronous reset to 32'h1
    output [31:0] q
); 
    reg [31:0] q_next;
  //Build a 32-bit Galois LFSR with taps at bit positions 32, 22, 2, and 1. 
    //bit positions 32-1=31, 22-1=21, 2-1=1, and 1-1=0.
    always @ (*)
        begin
            q_next = {q[0], q[31:1]};
            q_next[31] = q[0] ^ 1'b0;
            q_next[21] = q[22] ^ q[0];
            q_next[1] = q[2] ^ q[0];
            q_next[0] = q[1] ^ q[0];
        end 
    
    always @ (posedge clk)
        begin
        if (reset)
                q <= 32'h1;
            else
                q <= q_next;
        end
endmodule

沒有留言:

張貼留言

  清除項目編譯快取 執行 flutter clean 重新取得套件依賴 執行 flutter pub get 完整重新編譯並執行 flutter run 1. 新增專案套件 (pubspec.yaml) 在 Flutter 專案根目錄下的 pubspec.yaml 中,新增 ...