题解 | #不重叠序列检测#该代码与题目要求不符合

不重叠序列检测

https://www.nowcoder.com/practice/9f91a38c74164f8dbdc5f953edcc49cc

`timescale 1ns/1ns
module sequence_detect(
	input clk,
	input rst_n,
	input data,
	output reg match,
	output reg not_match
	);

// 011100
//
reg [5:0] a_ray;
reg [2:0] a_num;
always @(posedge clk or negedge rst_n) begin
    if (!rst_n) begin
        a_ray <= 0;
        match <= 0;
        not_match <= 0;
        a_num <= 0;
    end
    else begin
        if (a_num==6) begin
            a_ray <= {5'b00000,data};
            a_num <= 1;
			match <= 0;
            not_match <= 0;
        end
        else begin
            a_ray <= {a_ray[4:0],data};
            a_num <= a_num + 1;
            match <= 0;
            not_match <= 0;
        end
    end
end
always @(a_num) begin
    if (a_num==6) begin
        if (a_ray==6'b011100)
            match <= 1;
        else
            not_match <= 1;
    end
end
endmodule

题目时序图出现错误。match需提前一个时钟周期指示,即指示信号与第6信号同时显示。

题目要求用状态机实现,该代码未使用状态机。

全部评论

相关推荐

我是没经验的毕业生,这啥情况啊会不会是hr在刷kpi
JamesGosli...:字节boss属于是群发了,我都快入职字节了,其他部门还在和我boss打招呼
点赞 评论 收藏
分享
06-10 23:36
已编辑
首都经济贸易大学 C++
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务