题解 | #序列检测器(Moore型)#
序列检测器(Moore型)
https://www.nowcoder.com/practice/d5c5b853b892402ea80d27879b8fbfd6
`timescale 1ns/1ns module det_moore( input clk , input rst_n , input din , output reg Y ); reg [3:0]data_reg; always@(posedge clk or negedge rst_n) if(rst_n == 1'b0) data_reg <= 4'b0; else data_reg <= {data_reg[3:0],din}; always@(posedge clk or negedge rst_n) if (rst_n == 1'b0) Y <= 1'b0; else if (data_reg == 4'b1101) Y <= 1'b1; else Y <= 1'b0; endmodule
没有看题目让用状态机,所以这里来一个不用状态机的答案。(doge)