集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1427|回复: 3

请教有关verilog编写的计时模块的问题。

[复制链接]
guo88455648 发表于 2011-11-7 13:14:42 | 显示全部楼层 |阅读模式
自己这段时间学习verilog,编写了一段计时模块的程序,但是编译一直有问题。程序如下:

module clock(clks,RESET,scin,mcin,madd,hadd,sout,mout,hout);
input clks,RESET,madd,hadd;
output scin,mcin;
output [5:0]sout,mout,hout;
reg scin,mcin;
reg[5:0]sout,mout,hout;

always @(posedge clks)
  if(!RESET)  sout<=0;
  else
     begin
        if(sout==59)
            begin
              sout<=0;
              scin<=0;
            end
        else
            begin
              sout<=sout+1;
              scin<=0;
            end
      end

always @(posedge scin or posedge madd)   (问题主要出在这里,如果敏感源只是posedge scin,编译就没有问题,加上posedge madd以后
                                                     编译就不能通过)
  if(!RESET)  mout<=0;
  else
     begin
        if(mout==59)
            begin
              mout<=0;
              mcin<=0;
            end
        else
            begin
              mout<=mout+1;
              mcin<=0;
            end
      end


always @(posedge mcin or posedge hadd)         (此处的问题同上面)
  if(!RESET)  hout<=0;
  else
     begin
        if(hout==23)      hout<=0;           
         
        else              hout<=hout+1;            
            
      end


endmodule
引起出现问题的句子我在上面的程序中已经标注出来了,出现的问题为Error (10200): Verilog HDL Conditional Statement error at clock.v(25):
cannot match operand(s) in the condition to the corresponding edges in the enclosing event control of the always construct

请大家帮我解决一下这个问题,谢谢了!
jahero 发表于 2011-11-7 15:30:15 | 显示全部楼层
因为你这么写画不出电路 一个d触发器只有一个边沿触发信号 如果有两个 就要用选通电路选通一下
 楼主| guo88455648 发表于 2011-11-7 19:06:16 | 显示全部楼层
回复 2# jahero


    朋友,能说的详细一些吗
njithjw 发表于 2011-11-7 22:25:34 | 显示全部楼层
module clock
    (
    clks,
    reset,
    scin,
    mcin,
    madd,
    hadd,
    sout,
    mout,
    hout
    );
input           clks;
input           reset;
input           madd;
input           hadd;
output          scin;
output          mcin;
output  [5:0]   sout;
output  [5:0]   mout;
output  [4:0]   hout;

reg             scin;
reg             mcin;
reg     [5:0]   sout;
reg     [5:0]   mout;
reg     [4:0]   hout;


always @ (posedge clks or posedge reset)
begin
    if (reset == 1'b1)
    begin
        sout <= 6'd0;
        scin <= 1'b0;
    end
    else if (sout >= 6'd59)
    begin
        sout <= 6'd0;
        scin <= 1'b1;
    end
    else
    begin
        sout <= sout + 6'd1;
        scin <= 1'b0;
    end
end

always @ (posedge clks or posedge reset)
begin
    if (reset == 1'b1)
    begin
        mout <= 6'd0;
        mcin <= 1'b0;
    end
    else if ((madd == 1'b1) || (scin == 1'b1))
    begin
        if (mout >= 6'd59)
        begin
            mout <= 6'd0;
            mcin <= 1'b1;
        end
        else
        begin
            mout <= mout + 6'd1;
            mcin <= 1'b0;
        end
    end
    else ;
end

always @ (posedge clks or posedge reset)
begin
    if (reset == 1'b1)
    begin
        hout <= 5'd0;
    end
    else if ((hadd == 1'b1) || ((scin == 1'b1) && (mcin == 1'b1)))
    begin
        if (hout >= 5'd23)
            hout <= 5'd0;
        else
            hout <= hout + 5'd1;
    end
    else ;
end

endmodule
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

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

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-15 17:00 , Processed in 0.076505 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表