用verilog实现LBIST,要求:包含8位LFSR,MCU可以发送自定义LFSR的seed或使用默认的LFSR值(0xB2),执行预定义的计算,并进行验证。验证正确,会产生新的伪随机数;验证错误,输出错误信号。
时间: 2024-05-02 19:21:23 浏览: 67
LFSR.rar_LFSR verilog_VHDL LFSR Code_lfsr
以下是实现LBIST的Verilog代码,包括8位LFSR和验证模块。MCU可以通过“lfsr_seed”输入端口发送自定义种子值,或者使用默认值0xB2。验证正确时,“pass”输出端口将产生高电平信号,否则,“fail”输出端口将产生高电平信号。
```
module LBIST(
input clk,
input reset,
input [7:0] lfsr_seed,
output reg pass,
output reg fail
);
reg [7:0] lfsr;
reg [7:0] lfsr_out;
wire lfsr_tap = lfsr[5] ^ lfsr[3];
// LFSR
always @(posedge clk) begin
if (reset) begin
lfsr <= 0;
end else begin
lfsr <= {lfsr[6:0], lfsr_tap};
end
end
// Validation
always @(posedge clk) begin
if (reset) begin
pass <= 0;
fail <= 0;
lfsr_out <= 0;
end else begin
if (lfsr == 8'hB2) begin
// Default seed value
lfsr_out <= lfsr;
pass <= 1;
fail <= 0;
end else if (lfsr == lfsr_seed) begin
// Custom seed value
lfsr_out <= lfsr;
pass <= 1;
fail <= 0;
end else begin
// Incorrect LFSR output
lfsr_out <= lfsr;
pass <= 0;
fail <= 1;
end
end
end
endmodule
```
阅读全文