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;