牛客进阶题目2:含有无关项的序列检测
跟上一题类似
这里有人可能会用到casex,最好别用,有的工具可能不支持
`timescale 1ns/1ns
module sequence_detect(
input clk,
input rst_n,
input a,
output reg match
);
reg [8:0] temp ;
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
temp <= 'd0 ;
else
temp <= {temp[7:0],a};
end
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
match <= 1'b0 ;
else if(temp[2:0]==3'b110 && temp[8:6] == 3'b011)
match <= 1'b1 ;
else
match <= 1'b0 ;
end
endmodule
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】