英文:
If I use a blocking expression in the covergroup, do I need a sample directive from the previous code?
问题
一个覆盖组(covergroup)可以从过程代码中的样本指令(如.sample()
)以及覆盖组内的阻塞表达式(例如@(clk)
或@(signal)
)触发。
如果在覆盖组中实现了一个阻塞表达式,是否需要一个样本指令.sample()
?
class func_cov extends uvm_subscriber #(seq_item);
covergroup cg @(posedge clk);
option.per_instance = 1; // 每个实例的覆盖
option.auto_bin_max = 256; // 设置最大的 bin 数
option.type_option = UVM_UNSIGNED; // 将覆盖类型设置为无符号
option.weight = 1; // 设置覆盖权重
// 向覆盖组添加覆盖点
coverpoint req.addr {
bins range[] = {0, 255, 512, 1023};
}
coverpoint req.data {
bins data_range[] = {[0:255], [256:511], [512:767], [768:1023]};
}
endgroup
function new(string name = "func_cov", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
cg = new("cg", this);
endfunction
function void write(seq_item req);
// 收集覆盖数据
cg.sample();
endfunction
endclass
英文:
A covergroup is triggered from a sample directive from procedural code such as .sample()
and from a blocking expression within a covergroup such as @(clk)
or @(signal)
.
If I implement a blocking expression in the covergroup, do I need a sample directive .sample()
?
class func_cov extends uvm_subscriber #(seq_item);
covergroup cg @(posedge clk);
option.per_instance = 1; // Per instance coverage
option.auto_bin_max = 256; // Set maximum number of bins
option.type_option = UVM_UNSIGNED; // Set coverage type to unsigned
option.weight = 1; // Set coverage weight
// Add coverage points to the covergroup
coverpoint req.addr {
bins range[] = {0, 255, 512, 1023};
}
coverpoint req.data {
bins data_range[] = {[0:255], [256:511], [512:767], [768:1023]};
}
endgroup
function new(string name = "func_cov", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
cg = new("cg", this);
endfunction
function void write(seq_item req);
// Collect coverage data
cg.sample();
endfunction
endclass
答案1
得分: 1
不需要调用sample
方法。在您的代码中,覆盖率在coverage_event上进行采样,即@(posedge clk)
。
请参考IEEE Std 1800-2017,第19.3节"定义覆盖模型:covergroup"。
英文:
> If I implement a blocking expression in the covergroup, do I need a
> sample directive .sample()?
No, you do not need to call the sample
method. In your code, coverage is sampled at the coverage_event, which is @(posedge clk)
Refer to IEEE Std 1800-2017, section 19.3 Defining the coverage model: covergroup.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论