Iverilog源码分析 -- vvp value change 类型

vvp_vecor4_t

该类用来存储不包含strength信息的4-stat值;
里面所有的value均为a/b bus:

	// Values in the vvp_vector4_t are stored split across two
	// arrays. For each bit in the vector, there is an abit and a
	// bbit. the encoding of a vvp_vector4_t is:
	//
	//         abit bbit
	//         ---- ----
	// BIT4_0    0    0   (Note that for BIT4_0 and BIT4_1, the bbit
	// BIT4_1    1    0    value is 0. This makes detecting XZ fast.)
	// BIT4_X    1    1
	// BIT4_Z    0    1

      unsigned size_;
      union {
	    unsigned long abits_val_;
	    unsigned long*abits_ptr_;
      };
      union {
	    unsigned long bbits_val_;
	    unsigned long*bbits_ptr_;
      };

代表01xz字符串;

vvp_vector4array_t / vvp_vector4array_sa / vvp_vector4array_aa

这几个类是记录了vvp_vector4_t的array, static alloc 和automatic alloc的不同之处是:static alloc只会产生一次, automatic alloc可能会动态地产生多次。

module tryfact;
// define the function
function automatic integer factorial;
input [31:0] operand;
integer i;
if (operand >= 2)
factorial = factorial (operand - 1) * operand;
else
factorial = 1;
endfunction
// test the function
integer result;
integer n;
initial begin
for (n = 0; n <= 7; n = n+1) begin
result = factorial(n);
$display("%0d factorial=%0d", n, result);
end
end
endmodule // tryfact

vvp_vector2_t

采用unsigned long arr来进行存储;
代表一系列的01字符串, 可以来存储integer, time等值;

vvp_scalar_t

  • The strength values are as defined here:
  • HiZ - 0
  • Small - 1
  • Medium - 2
  • Weak - 3
  • Large - 4
  • Pull - 5
  • Strong - 6
  • Supply – 7
    该class, 用一个byte记录value, 其中包含strength0, strength1, 他们各包含3 bit, 剩下2个bit, 可以记录4种值01xz的其中一种;
# define STREN1(v) (((v)&0x70) >> 4)
# define STREN0(v) ((v)&0x07)

inline vvp_bit4_t vvp_scalar_t::value() const
{
      if ((value_ & 0x77) == 0) {
	    return BIT4_Z;
      } else switch (value_ & 0x88) {
	  case 0x00:
	    return BIT4_0;
	  case 0x88:
	    return BIT4_1;
	  default:
	    return BIT4_X;
      }
}

vvp_vector8_t

此类是一个vvp_scalar_t的数组, 可以记录包含strength信息的vector值;
unsigned size_;
union {
unsigned charptr_;
unsigned char val_[sizeof(void
)];
}
根据一个value的值大小size, 决定存储在val或者ptr里面;

inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
: size_(size__)
{
      if (size_ <= sizeof(val_)) {
	    memset(val_, 0, sizeof(val_));
      } else {
	    ptr_ = new unsigned char[size_];
	    memset(ptr_, 0, size_);
      }
}

由于该类是一个vvp_scalar_t的vector, 可以通过vector的index来获得某一个vvp_scalar_t;

vvp_object_t

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值