hfy0911@126.com 发表于 2012-8-10 14:53:42

帮忙看下怎么错了,谢谢

//产生1hz的时钟信号
module div(clk_i,rst,clk_o);
   input clk_i,rst;
   output reg clk_o;
   parameter m=50_000_000;
   parameter n=24_999_999;
   reg cnt;
   always @(posedge clk_i,negedge rst)
        begin
         if(!rst)
             cnt<=26'b0;
          else
            begin
                if(cnt==m-1)
                  cnt<=26'b0;
                else
                  cnt<=cnt+26'b1;
             end
        end
   always @(posedge clk_i,negedge rst)
        begin
          if(!rst)
          clk_o<=0;
          else
          begin
              if(cnt<=n)
                clk_o<=1;
              else
                clk_o<=0;
          end
        end
endmodule
       
//数码管显示
module dis(dig,seg);
   input dig;
   output reg seg;
   always @(dig)
   begin
   case(dig)
        4'h0:seg=7'b1000000;
        4'h1:seg=7'b0000110;
        4'h2:seg=7'b0100100;
        4'h3:seg=7'b0110000;
        4'h4:seg=7'b0011001;
        4'h5:seg=7'b0010010;
        4'h6:seg=7'b0000010;
        4'h7:seg=7'b1111000;
        4'h8:seg=7'b0000000;
        4'h9:seg=7'b0010000;
        4'ha:seg=7'b1000000;
        4'hb:seg=7'b0000110;
        4'hc:seg=7'b0100100;
        4'hd:seg=7'b0110000;
        4'he:seg=7'b0011001;
        4'hf:seg=7'b0010010;
      endcase
   end
endmodule
//顶层文件
module part2(clk_50,key0,hex0,hex1,hex2);
   input clk_50,key0;
   output hex0,hex1,hex2;
   wire clk_1hz;
   reg cnt;
   parameter M=65535;
   div u0(clk_50,rst,clk_1hz);
   always @(posedge clk_1hz or negedge key0)
   begin
       if(!keyo)
        cnt<=12'b0;
       else
        begin
          if(cnt<=M)
          cnt<=cnt+12'b1;
          else
          cnt<=12'b0;
        end
      end
   always @(cnt)
   begin
       if(cnt<=4'd9)
       begin
          dis h0(cnt,hex0);//出错
          dis h1(cnt,hex1);//出错
          if(cnt<=4'd9)
              begin
                dis h1(cnt,hex1);//出错
                dis h2(cnt,hex2);//出错
              end
          else
              begin
                dis h1(cnt,hex1);//出错
                dis h2((cnt+4'b1),hex2);//出错
              end
       end
       else
        begin
          dis h0(cnt,hex0);//出错
          dis h1((cnt+4'b1),hex1);//出错
          if((cnt+4'b1)<=4'd9)
          begin
              dis h1((cnt+4'b1),hex1);//出错
              dis h2(cnt,hex2);//出错
          end
          else
          begin
              dis h1((cnt+4'b1),hex1);//出错
              dis h2((cnt+4'b1),hex2);//出错
          end
       end
                       
    end
endmodule

上面这段代码用来实现三位BCD码计数器,最后一部分是顶层文件,在编译的时候,提示出错Error (10170): Verilog HDL syntax error at part2.v(105) near text "(";expecting ";"
,出错处在代码中已经标出,请问这该怎么改才能编译正确,谢谢

hfy0911@126.com 发表于 2012-8-11 10:24:12

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:17

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:17

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:18

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:34

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:35

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:36

没人愿意指点一下吗,唉。。。

hfy0911@126.com 发表于 2012-8-11 10:24:37

没人愿意指点一下吗,唉。。。

xiebinqiang 发表于 2012-8-11 15:06:10

楼主,是不是在always里面不能共进行分模块的调用的,你可以把你的dis写成函数的形式,这样就不会有错误了
页: [1]
查看完整版本: 帮忙看下怎么错了,谢谢