VL26 含有无关项的序列检测

 

`timescale 1ns/1ns
module sequence_detect(
    input clk,
    input rst_n,
    input a,
    output reg match
    );
reg [8:0] temp_a;
always @(posedge clk,negedge rst_n) begin
if(!rst_n)
temp_a<=0;
else
temp_a<={temp_a[7:0],a};
end

always @(posedge clk,negedge rst_n)begin
if(!rst_n)
match<=1'b0;
else
match<=((temp_a[8:6]==3'b011)&&(temp_a[2:0]==3'b110))?1'b1:1'b0;
end
endmodule
和上一题相比就是三元运算符的条件稍微多了一步
posted @ 2024-08-29 16:25  段星儿  阅读(20)  评论(0)    收藏  举报