Elaboration是个什么过程?
语义分析(parsed)完之后,在进行simulation之前,需要确保RTL中各modules已被定义,并且处理模块之间的参数传递,这个过程就是elaboration.
4-state data types
logic reginteger time
2-state types
bit int
signed data types
byte shortint int integer longint
unsigned data types
bit reg logic
generate … endgenerate模块
generate可创建参数化model。Generate在elaboration期间初始化。例如根据不同的参数例化不同的module。
例化system-C
可在module里面例化System-Cmodule,实现System-Verilog和System-C的混合仿真。
DPI
可以用irun直接编译。
Mailbox
Mailbox的存储顺序采取FIFO方式。
rand
dist
constraint c1{
xinside {[0:9]};
xdist {[0:3] := 1, [4:5] := 2, 6 = 1, [7:9] :/ 1};
}
coverage
bit [9:0] v_a;
covergroup cg @(posedge clk);
coverpoint v_a
{
bins a = { [0:63],65 }; // 1 bins.
bins b[] = { [127:150],[148:191] }; // note overlappingvalues, 24+44=69 bins.
bins c[] = { 200,201,202 }; // 3 bins.
bins d = { [1000:$] }; // 1 bins.
bins others[] = default;
}
endgroup
参数化coverage
covergroup gc (ref int ra, int low, int high )@(posedge clk);
coverpoint ra // sample variable passed by reference
{
bins good = { [low : high] };
bins bad[] = default;
}
endgroup
...
int va, vb;
cg c1 = new( va, 0, 50 ); // cover variable va inthe range 0 to 50
cg c2 = new( vb, 120, 600 ); // cover variable vb inthe range 120 to 600
time scope
timeunit timeprecision
如果在module/program/package/interface定义中没有指定timeunit,则按照以下规则采用timeunit:
1. 如果module/interface是nested,timeunit继承于nest的上层module/interface(program/package无法被nest)。
2. 如果compilationunit内有timescale在之前被指定,则采用上一个timescale。
3. 否则,如果该compilation-unit指定了timeunit,则采用该time unit。
4. 否则采用默认的timeunit。
timeprecision的规则跟timeunit一样。
编译通过但simulation 时间无法前进的原因:
可能是由于类似forever语句中没有时间消耗,从而导致死锁。
几种parameter的区别
parameter, localparam, specparam, defparam
—Implicit in-line parameter redefinition (e.g. foo #(value, value) u1(...); )
—Explicit in-line parameter redefinition (e.g. foo #(.name(value),.name(value)) u1 (...); )
— defparam statements,using hierarchical path names to redefine each parameter
例如:defparamhost_dpdm_trans.vipModelName ="spiderman_tb_top.host((model))";
$cast
Sub-class object可以赋值给Superclass变量。
只有当Super class变量指向的是相同的sub-class或者该sub-class的子类例化出的object,该superclass变量才可以赋值给sub-class 变量。而且需要用$cast来进行转换。
DPI中pure和context的区别?
在SV中imported的function可以被声明为pure或者context。
当声明为pure时,说明该function或者task只与输入参数有关。要声明为pure,有以下条件:
1. function。
2. 返回值为non void。
3. 参数列表里没有output和inout类型。
import的function和task可以被声明为context, 当声明为context时,说明该function或task可能会调用SV export出去的function或者task或者访问SV的data objects。