verilog检测10010序列

module squence_check

(

input clk,

input rst_n,

input i_din,

output o_flg

)

//syte 1

//always @(posedge clk or negedge rst_n)

// if(!rst_n)

// dat_sequence <= 5'd0;

// else

// dat_sequence <= {dat_sequence[3 : 0],i_din};

//

//assign flg = {dat_sequence[3 : 0],i_din} == 5'b10010;

//

//always @(posedge clk or negedge rst_n)

// if(!rst_n)

// o_flg <= 1'd0;

// else

// o_flg <= flg;

//

always @(posedge clk or negedge rst_n)

if(!rst_n)

curr_state <= IDLE;

else

curr_state <= nxt_state;

always@ (*)

case(curr_state)

IDLE:

if(i_din == 1'd1)

nxt_state = S0;

else

nxt_state = IDLE;

S0:

if(i_din == 1'd0)

nxt_state = S1;

else

nxt_state = S0;

S1:

if(i_din == 1'd0)

nxt_state = S2;

else

nxt_state = S0;

S2:

if(i_din == 1'd1)

nxt_state = S3;

else

nxt_state = IDLE;

S3:

if(i_din == 1'd0)

nxt_state = S4;

else

nxt_state = S0;

S4:

if(i_din == 1'd0)

nxt_state = IDLE;

else

nxt_state = S0;

default:

nxt_state = IDLE;

endcase

assign o_flg = (curr_state == S4);

endmodule

相关推荐
西岸行者5 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky5 天前
Django入门笔记
笔记·django
勇气要爆发5 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意5 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
勇气要爆发5 天前
吴恩达《LangChain LLM 应用开发精读笔记》2-Models, Prompts and Parsers 模型、提示和解析器
android·笔记·langchain
qianshanxue115 天前
计算机操作的一些笔记标题
笔记
土拨鼠烧电路5 天前
笔记11:数据中台:不是数据仓库,是业务能力复用的引擎
数据仓库·笔记
土拨鼠烧电路5 天前
笔记14:集成与架构:连接孤岛,构建敏捷响应能力
笔记·架构
烟花落o5 天前
栈和队列的知识点及代码
开发语言·数据结构·笔记·栈和队列·编程学习