为什么在模块part1中给出错误?

埃莱姆·埃克林

在我之前的问题中,我曾问过我要设计一种装瓶系统,该装瓶系统将所需数量的药片装满瓶子。在我的项目的第1部分中,用户将按FPGA上的按钮来确定每个瓶子中将装入多少片药片,并显示所需的数字。这是我为我的项目编写的第1部分的代码,不知道为什么它会在模块part1中给出错误。

module count(clk,clr,cntEn,dout);
    input clk,clr,cntEn;
    output reg [8:0] dout ;

    always@(posedge clk)
    begin
      if(clr) 
        dout<=0;
      else if(cntEn)
        dout<=dout+1;
    end

endmodule


module sevenseg(num,dout);
    input      [3:0] num;
    output reg [6:0] dout;

    always@(*) begin
    case(num)
        0:dout=7'b1111110;
        1:dout=7'b1100000;
        2:dout=7'b1011011;
        3:dout=7'b1001111;
        4:dout=7'b1100110;
        5:dout=7'b1101101;
        6:dout=7'b1111101;
        7:dout=7'b0000111;
        8:dout=7'b1111111;
        9:dout=7'b1101111;
    endcase
end

endmodule


module part1(clk,clr,cntEn,dout);
    input   clk, clr, cntEn;
    output  dout;
    wire    w1;

    begin
        count    count_1   (clk, clr, cntEn, w1);
        sevenseg sevenseg_1(w1,  dout );
    end

endmodule
摩根

ljk07指出了错误,不需要模块1中的begin end,某些解析器可能只是忽略它们而其他则抛出错误。它应该是:

module part1(clk,clr,cntEn,dout);
  input   clk, clr, cntEn;
  output  dout;
  wire    w1;

  count    count_1   (clk, clr, cntEn, w1);
  sevenseg sevenseg_1(w1,  dout );

endmodule

我认为也应该指出,除非您受制于Verilog-95,否则最好采用ANSI样式的端口声明,因为这样会使代码维护更容易。

module part1(
  input   clk, clr, cntEn,
  output  dout
);
  wire    w1;

  count    count_1   (clk, clr, cntEn, w1);
  sevenseg sevenseg_1(w1,  dout );

endmodule

sevenseg模块还具有不完整的case语句,这将导致隐式闩锁。添加默认值或为num的所有选项完全指定输出:

module sevenseg(num,dout);
  input      [3:0] num;
  output reg [6:0] dout;

  always @(*) begin
    case(num)
      0:dout=7'b1111110;
      1:dout=7'b1100000;
      2:dout=7'b1011011;
      3:dout=7'b1001111;
      4:dout=7'b1100110;
      5:dout=7'b1101101;
      6:dout=7'b1111101;
      7:dout=7'b0000111;
      8:dout=7'b1111111;
      9:dout=7'b1101111;
      default: dout='b0;
    endcase
  end
endmodule

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么我的查询在mySql中给出错误的fileid?

为什么指令中的数据名称给出错误?

为什么Post方法在Laravel中给出错误MethodNotAllowedHttpException

为什么dockerfile中的双'COPY'给出错误

为什么DELIMITER //在MariaDB中给出错误?

为什么在lua中运行'setfallback'会给出错误

为什么geoshere给出错误的距离?

为什么“ const extern”给出错误?

为什么'->'(12,b)给出错误?

为什么MomentJS给出错误的结果

为什么Android Studio在实施'constraintlayout:2.0.0-beta1'后给出错误消息

为什么在每晚Rust 1.29中运行的发电机在每晚1.34.0中给出错误?

为什么模块的Import export给出错误,因为声明了“ BlogpostModule”,但其值从未读取。ts(6133)” angular 7

为什么$ book给出错误,而$ title和$ author没有给出错误?

为什么简单计算的值在Java中给出错误的结果?它会溢出吗?

为什么int = int * double给出错误而int * = double却没有(在Java中)?

为什么在方括号中使用if不会在python中给出错误

为什么Ruby中的这个布尔语句会给出错误?

为什么在printf中调用两次的inet_ntoa给出错误的输出?

为什么显式缩小变量不会在Kotlin中给出错误

为什么我的代码行在字符串中给出错误的字符位置

为什么GeneratedPluginRegistrant.registerWith(this)在Flutter MainActivity.kt中给出错误?

为什么字符串中的反斜杠(\)在控制台中给出错误

为什么决策树在 R 中给出错误的分类?

为什么 x = 7 < 5 ; print(x) 在 python 中给出错误?

加密模块中的字节编码给出错误

为什么 Laravel 给出错误的结果查询?

为什么struct给出错误的sizeof和void指针

为什么使用/“ /”时“ grep”给出错误?