解析:
本题目较为简单,有两种思路,一种是状态机方法,一种是移位寄存器方法,因为题目未要求使用哪种方法,因此这里采用较为简洁的移位寄存器方法。
//--------------------------------------------------------------------------------------------------------
// Module : sequence_detect
// Standard: Verilog 2005
// Function: 编写一个序列检测模块,检测输入信号a是否满足01110001序列,当信号满足该序列,给出指示信号match。
// Author : BruceSong
// Date : 2024.04.02
// Version : 1.0
//--------------------------------------------------------------------------------------------------------
`timescale 1ns/1ns
module sequence_detect(
input clk,
input rst_n,
input a,
output reg match
);
reg [7:0] data_reg;
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
data_reg <= 8'b0;
end
else begin
data_reg <= {data_reg[6:0],a};
end
end
always @ (posedge clk or negedge rst_n) begin
if(!rst_n) begin
match <= 8'b0;
end
else begin
if(data_reg == 8'b01110001)
match <= 1'b1;
else begin
match <= 1'b0;
end
end
end
endmodule
标签:--------------------------------------------------------------------------------
From: https://www.cnblogs.com/Bruceson/p/18111344