摘要: 检测代码:module det_seq(clk,rst_n,din,dout); input clk,rst_n; input din; output dout; reg [4:0] shift_reg; parameter s=5'b11010; always@(posedge clk,negedge rst_n)begin if(~rst_n) shift_reg<=5'b0; else shift_reg<={shift_reg[3:0],din}; end assign dout=(shift_reg==s)?1'b1:1'b0; endmo 阅读全文
posted @ 2012-02-23 17:41 pzchu 阅读(273) 评论(0) 推荐(0) 编辑
摘要: 边沿检测Verilog程序代码:module DetecEdge(clk,ps2_clk,rst_n,pos_ps2_clk,neg_ps2_clk);input clk; //输入时钟input ps2_clk; //输入要检测边沿的脉冲input rst_n; //复位信号output pos_ps2_clk; //上升沿标志位output neg_ps2_clk; //下降沿标志位reg ps2_clk_r0,ps2_clk_r1,ps2_clk_r2; //ps2_clk状态寄存器always@(posedge clk or negedge rst_n) if(!rst_n) beg. 阅读全文
posted @ 2012-02-23 16:40 pzchu 阅读(100) 评论(0) 推荐(0) 编辑