解法一:最容易想到的casex
`timescale 1ns/1ns
module sequence_detect(
input clk,
input rst_n,
input a,
output reg match
);
reg [8:0] val;
always@(posedge clk or negedge rst_n)begin
if(!rst_n)begin
val <= 0;
end
else begin
val <= {val[7:0],a};
end
end
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
match <= 0;
else begin
casex(val)
9'b011xxx110 : match <= 1'b1;
default : match <= 1'b0;
endcase
end
end
endmodule
解法二:移位方式

本文介绍了三种不同的方法来解决含有无关项的序列检测问题:casex、移位检测和三段式状态机。通过实例代码展示并对比了它们在Verilog中的实现,适合理解序列匹配在硬件设计中的应用。
最低0.47元/天 解锁文章
316

被折叠的 条评论
为什么被折叠?



