要求:检测10010
实现方案一:移位寄存器
module seqchk(
input x,
input clk,
input rst_n,
output z,
output [4:0]q);
reg [4:0]q;
reg [4:0]q_dly;
//将串行数据转为并行,再检测与目标数据是否一致
always @(posedge clk or negedge rst_n)
if(!rst_n) q <= 5'b0
要求:检测10010
实现方案一:移位寄存器
module seqchk(
input x,
input clk,
input rst_n,
output z,
output [4:0]q);
reg [4:0]q;
reg [4:0]q_dly;
//将串行数据转为并行,再检测与目标数据是否一致
always @(posedge clk or negedge rst_n)
if(!rst_n) q <= 5'b0