在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 11917|回复: 4

[求助] 帮忙挑挑错

[复制链接]
发表于 2010-7-29 23:19:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

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
发表于 2010-7-30 09:26:00 | 显示全部楼层
建议你去学习下三段状态机
发表于 2010-7-30 11:17:20 | 显示全部楼层
大侠啊
 楼主| 发表于 2010-7-30 20:32:55 | 显示全部楼层
谢谢你的建议,现在还不了解
发表于 2010-7-31 00:10:56 | 显示全部楼层
你这个风格很糟糕。verilog不是c。要考虑综合的结果的。你这样的程序很难分析综合出什么东西来。
建议你改一下程序。每个always块只对应一个寄存器。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-14 12:19 , Processed in 0.025622 second(s), 9 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表