|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
这个模块运行时经常出现一种异常情况,经常会在out=1'b0,test=8'b0011_0011时锁死,没反应
//一个消抖模块,当输入改变时,延时120个脉冲输出结果,如果输入的毛刺长度小于120个
//脉冲,则不影响输出
module test(key,clk,outo,out,test);
input key,clk;
output outo,out;
output [7:0] test;
reg outo,out;
reg [6:0] count;
reg [1:0]state;
reg [7:0] test;
parameter idle = 2'b00;
parameter high = 2'b01;
parameter low = 2'b10;
always @(posedge clk)begin
case (state)
idle:begin test <= 8'b00010001;
count<=7'b0;
if(key) state <= high;
else state <= low;
end
high:begin
if(count==7'd120) begin test <= 8'b00110001;
state <= idle;
outo <=1'b0;
out <=1'b1;
end
else begin test <= 8'b00110011; //经常在这里锁死,并且out=1'b0
if(key) count <=count+1'b1;
else
state <= idle;
end
end
low: begin
if(count==7'd120) begin test <= 8'b01110001;
state <=idle;
outo <=1'b1;
out <=1'b0;
end
else begin test <= 8'b01110011;
if(!key) count <= count+1'b1;
else
state <= idle;
end
end
default: begin state <= idle; test <= 8'b11110000;end
endcase
end
endmodule |
|