集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2539|回复: 9

帮忙看下怎么错了,谢谢

[复制链接]
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 [25:0]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 [3:0]dig;
   output reg [6:0]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 [6:0]hex0,hex1,hex2;
   wire clk_1hz;
   reg [11:0]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[3:0]<=4'd9)
         begin
            dis h0(cnt[3:0],hex0);//出错
            dis h1(cnt[7:4],hex1);//出错
            if(cnt[7:4]<=4'd9)
              begin
                dis h1(cnt[7:4],hex1);//出错
                dis h2(cnt[11:8],hex2);//出错
              end
            else
              begin
                dis h1(cnt[7:4],hex1);//出错
                dis h2((cnt[11:8]+4'b1),hex2);//出错
              end
         end
       else
        begin
          dis h0(cnt[3:0],hex0);//出错
          dis h1((cnt[7:4]+4'b1),hex1);//出错
          if((cnt[7:4]+4'b1)<=4'd9)
            begin
              dis h1((cnt[7:4]+4'b1),hex1);//出错
              dis h2(cnt[11:8],hex2);//出错
            end
          else
              begin
              dis h1((cnt[7:4]+4'b1),hex1);//出错
              dis h2((cnt[11:8]+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 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-26 06:26 , Processed in 0.067912 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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