首页|资源下载
登录|注册

您现在的位置是:首页 > 技术阅读 >  System Verilog当中的Bits vs Bytes

System Verilog当中的Bits vs Bytes

时间:2024-07-16

正如我们所知,“bit”是无符号的,而“byte”是有符号的。那么,你认为下面两个声明是等价的吗?

bit [7:0] aBit; // Note ‘bit’ is 2-state, unsigned

byte bByte; // Note ‘byte’ is 2-state, 8-bit signed integer

答案是不等价,因为:

bit [7:0] aBit; // = 0 to 255
byte bByte; // = -128 to 127

所以,你需要小心混合bit和字byte数据类型的计算。

同样,你认为以下两种说法等价吗?

byte MEM_BYTES [256];
bit signed [7:0] MY_MEM_BYTES [256];

答案是等价。我们可以简单理解为

bit signed [7:0] 等价为 byte。