题解 | #不重叠序列检测#

不重叠序列检测

http://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
	);
    
    reg [5:0] r_data;
    reg [2:0] cnt;
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            cnt <= 3'd0;
        else if (cnt==3'd5)
            cnt <= 3'd0;
        else 
            cnt <= cnt + 1'b1;
    end
    
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n)
            r_data <= 6'b0;
        else if(cnt==3'd0)
            r_data <= {5'b0,data};
        else 
            r_data <= {r_data[4:0],data};
    end
    
    always @(posedge clk or negedge rst_n) begin
        if (!rst_n) begin
            match <= 1'b0;
            not_match <= 1'b0;
        end
        else if(cnt==3'd5) begin
            if ({r_data[4:0],data}==6'b0111_00) begin
                match <= 1'b1;
                not_match <= 1'b0;
            end
            else begin
                match <= 1'b0;
                not_match <= 1'b1;
            end
        end
        else begin
            match <= 1'b0;
            not_match <= 1'b0;
        end
    end
    
endmodule
全部评论

相关推荐

若怜君欢:驾驶证去掉吧,PPT啥的也去掉,本硕课程去掉,导师和研究方向去掉;加入本硕排名(好才写);技能栏加入你会的那些控制算法和滤波算法,这个比你会啥啥啥软件更有用;获奖写上去,奖学金啊,有没有专利啊之类的 电机和硬件这一块,属于传统制造业,制造业实习并不多。多投一些攒攒经验,有实习最好,没有也不需要焦虑(制造业实习其实除了转正,没多大用处) 最后,划重点,等秋招开始后,把你所有社交软件都发一份简历上去,并经常更新,找人内推你!
点赞 评论 收藏
分享
如题,他是要劝退我了吗
椛鸣:根据你的时间 来给你安排任务 如果你时间长 可能会参与到一些长期的项目 时间短 那就只能做点零工
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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