zoukankan      html  css  js  c++  java
  • 如何避免Quartus II自動將未宣告的信號視為wire?

    Abstract 在Verilog 1995規定,對於沒宣告的信號會自動視為wire,這樣常常造成debug的困難,Verilog 2001另外定義了`default_nettype none,將不再自動產生wire,且目前Quartus II 8.1已經支援。

    Introduction 很多人抱怨Quartus II對Verilog語法檢查能力很差,如以下的code,Quartus II竟然可以編譯成功。

    default_nettype_none.v / Verilog

    复制代码
    1 module default_nettype_none ( 2   input n0, 3   input n1, 4   output o1 5 ); 6 7 assign ol = n0 & n1; // no error here, only warning8 9 endmodule
    复制代码

    因為打錯,而將o1打成ol,Quartus II並未抓出這個錯誤,竟然順利編譯成功,雖然有warning,不過因為Quartus II一向有太多的warning,假如用了Nios II與SOPC,warning更可能多到不小心就忽略了這個warning。

    warning02

    像這種狀況,比較理想的方式是如同C/C++一樣,由Compiler強行產生error,讓編譯不成功,強迫coder去改code。

    default_nettype_none.v / Verilog

    复制代码
    1 `default_nettype none 2 3 module default_nettype_none ( 4   input n0, 5   input n1, 6   output o1 7 ); 8 9 assign ol = n0 & n1; // compiler error here10 11 endmodule
    复制代码

    第1行加了`default_nettype none,這是Verilog 2001新增的compiler directive,避免Verilog將未宣告的信號視為wire,重要的是Quartus II 8.1有支援,並且產生了錯誤訊息,阻止繼續編譯。

    warning01 

    完整程式下載 default_nettype_none.7z

    Conclusion 看到Verilog 2001的`default_nettype none,使我想到了VB6與VBScript,VB因為是個弱型別語言,類似Verilog 1995一樣,只要沒宣告過的變數,VB6/VBScript會自動幫你宣告,這是C/C++這種強型別語言所不允許的,也因為如此,VB6/VBScript常因為打錯字而造成debug困難,後來VB6/VBScript提出了option explicit這個compiler directive,將VB6/VBScript變成一個強型別語言,這與Verilog 2001的`default_nettype none非常類似。

  • 相关阅读:
    sqlserver 动态 sql语句的执行
    SqlServer位运算 权限设计
    更改主数据 的管理员账户
    如何查看dll 的PublicKeyToken
    varbinary 与 字符串 的互换函数
    analysis service 配置远程连接
    sqlserver字符串拆分(split)方法汇总
    openfile 安装备忘
    Lamp 在centos 中的安装
    Oracle查询表中的各列的列名,数据类型,以及类型长度
  • 原文地址:https://www.cnblogs.com/kaiseradler/p/2857521.html
Copyright © 2011-2022 走看看