SV——Verilog和System Verilog中字面值表示

 

0. 介绍

字面值(literal integer)就是类似5、'h10这种值。

 

1. syntax

<size>'s<base><value>

  • <size> is optional. If given, it specifies the total number of bits represented by the literal integer. If not given, the default size, per the Verilog/SystemVerilog standard is "at least"32 bits.
  • s is optional. If given, it specifies thatthe literal integer should be treated as a signed value in operations. If not given, the default is unsigned. (The signed specifier wasadded to Verilog as part of the Verilog-200I standard.)
  • <base> is required, and specifies whether the value is in binary, octal, decimal, or hex.
  • <value> is required, andspecifies the literal integer value.

The baseoptions are represented using b, 0, d, or h for binary, octal, decimal andhex,
respectively. The base specifier can be either lowercase or uppercase (i.e. ' h 5
and ' H5 are the same).

2. 符号

Unbased literal integers default to signed. Based literal integers default to unsigned.

比如5,表示有符号的5;'d5表示无符号5.

3. reference

《Verilog and SystemVerilog Gotchas》

 

上一篇:使用pyinstaller打包报错,SyntaxWarning: “is not“ with a literal. Did you mean “!=“?


下一篇:vue固化插件