题解 | #含有无关项的序列检测#

含有无关项的序列检测

http://www.nowcoder.com/practice/cba67d06d6834a5d9b93e1087b56c8d8

`timescale 1ns/1ns module sequence_detect( input clk, input rst_n, input a, output reg match ); reg [8:0] temp_a; reg matcha,matchb; always@(posedge clk or negedge rst_n) begin if(!rst_n) temp_a <= 0; else temp_a <= {temp_a[7:0],a}; end always@(posedge clk or negedge rst_n) begin if(!rst_n) matcha <= 0; else if(temp_a[8:6] == 3'b011) matcha <= 1; else matcha <= 0; end always@(posedge clk or negedge rst_n) begin if(!rst_n) matchb <= 0; else if(temp_a[2:0] == 3'b110) matchb <= 1; else matchb <= 0; end always @(*) begin match <= matcha&&matchb; end endmodule

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 12:11
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
头顶尖尖的程序员:我也是面了三四次才放平心态的。准备好自我介绍,不一定要背熟,可以记事本写下来读。全程控制语速,所有问题都先思考几秒,不要急着答,不要打断面试官说话。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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