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

相关推荐
Hacker_Z&Q14 分钟前
CSS 笔记2 (属性)
前端·css·笔记
丝斯201139 分钟前
AI学习笔记整理(67)——大模型的Benchmark(基准测试)
人工智能·笔记·学习
whale fall1 小时前
2026 年 1-3 月雅思口语完整话题清单(1-4 月通用最终版)
笔记·学习
xian_wwq1 小时前
【学习笔记】对网络安全“三化六防挂图作战”的理解与思考
笔记·学习·三化六防
三伏5221 小时前
Cortex-M3权威指南Cn第十章——笔记
笔记·单片机·嵌入式硬件·cortex-m3
AI视觉网奇2 小时前
metahuman 购买安装记录
笔记·学习·ue5
koo3642 小时前
pytorch深度学习笔记19
pytorch·笔记·深度学习
历程里程碑2 小时前
Linux 17 程序地址空间
linux·运维·服务器·开发语言·数据结构·笔记·排序算法
夜流冰3 小时前
工程师 - ADC的Gain和offset
笔记
wdfk_prog4 小时前
[Linux]学习笔记系列 -- [drivers][dma]stm32-dma
linux·笔记·学习