打印

SystemVerilog Literal Values

[复制链接]
1595|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
星星之火红|  楼主 | 2012-11-8 19:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
The lexical conventions for SystemVerilog literal values are extensions of those for Verilog. System Verilog adds literal time values, literal array values, literal structures and enhancements to literal strings.
Integer and logic literals:
Literal integer and logic values can be sized or unsized, and follow the same rules for signed ness, truncation. System Verilog adds the ability to specify unsized literal single bit values with a preceding apostrophe (’), but without the base specifier. All bits of the unsized value are set to the value of the specified bit. In a self-determined context these literals have a width of 1 bit, and the value is treated as unsigned.


'0, ’1, ’X, ’x, ’Z, ’z // sets all bits to this value


Real literals:


The default type is real for fixed point format (e.g. 1.2), and exponent format (e.g. 2.0e10). A cast can be used to convert literal real values to the short real type.


Time literals:


Time is written in integer or fixed point format, followed without a space by a time unit (fs ps ns us ms s Step). For example: 1ns, 1ps, 1ms


The time literal is interpreted as a realtime value scaled to the current time unit and rounded to the current Time precision. Note that if a time literal is used as an actual parameter to a module or interface instance, the Current time unit and precision are those of the module or interface instance


String literals:


A string literal is enclosed in quotes and has its own data type .Non-printing and other special characters are preceded with a backslash.
string name = “ Kacper Tech”;
\v vertical tab
\f form feed
\a bell
\x02 hex number
bit [7:0] c2 = "hello world\n" ;
A string literal can be assigned to an unpacked array of bytes. If the size differs, it is left justified.
byte c3 [0:12] = "hello world\n" ;

Array literals:


Array literals are syntactically similar to C initializers, but with the replicate operator ({{}}) allowed.
int n [1:2][1:3] = {{0,1,2},{3{4}}};
int n[1:2][1:3] = {2{{3{a, b}}}}; // same as {{a,b,a,b,a,b},{a,b,a,b,a,b}}

Structure Literals:


Structure literals are syntactically similar to C initializers. Structure literals must have a type, either from context or a cast.
typedef struct {int a; shortreal b ;} ab;
ab c;
c = {0, 0.0}; // structure literal type determined from

相关帖子

沙发
GoldSunMonkey| | 2012-11-8 20:49 | 只看该作者
:Q要是中文就好了。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

101

主题

1782

帖子

22

粉丝