Added functional coverage

This commit is contained in:
2026-06-05 22:22:57 -07:00
parent 73b38f7e55
commit be0350dfe7
2 changed files with 75 additions and 0 deletions
+28
View File
@@ -12,6 +12,30 @@ class axi_agent_config extends uvm_object;
/// Maximum value of pre_response_delay /// Maximum value of pre_response_delay
int pre_response_delay_max = 20; int pre_response_delay_max = 20;
// --------------------------------------------------
// Functional coverage
// Cover the *actual* delays produced by the getters.
// --------------------------------------------------
/* verilator lint_off COVERIGN */
covergroup cg_pre_transaction_delay with function sample(int dly);
option.per_instance = 1;
cp_dly: coverpoint dly {
bins min = {pre_transaction_delay_min};
bins max = {pre_transaction_delay_max};
bins in_range[] = {[pre_transaction_delay_min:pre_transaction_delay_max]};
}
endgroup
covergroup cg_pre_response_delay with function sample(int dly);
option.per_instance = 1;
cp_dly: coverpoint dly {
bins min = {pre_response_delay_min};
bins max = {pre_response_delay_max};
bins in_range[] = {[pre_response_delay_min:pre_response_delay_max]};
}
endgroup
/* verilator lint_on COVERIGN */
`uvm_object_utils_begin(axi_agent_config) `uvm_object_utils_begin(axi_agent_config)
`uvm_field_int(pre_transaction_delay_min, UVM_DEFAULT) `uvm_field_int(pre_transaction_delay_min, UVM_DEFAULT)
`uvm_field_int(pre_transaction_delay_max, UVM_DEFAULT) `uvm_field_int(pre_transaction_delay_max, UVM_DEFAULT)
@@ -22,6 +46,8 @@ class axi_agent_config extends uvm_object;
// -------------------------------------------------- // --------------------------------------------------
function new(string name = "axi_agent_config"); function new(string name = "axi_agent_config");
super.new(name); super.new(name);
cg_pre_transaction_delay = new();
cg_pre_response_delay = new();
endfunction endfunction
// -------------------------------------------------- // --------------------------------------------------
@@ -45,6 +71,7 @@ class axi_agent_config extends uvm_object;
// `uvm_error("get_pre_transaction_delay", "Randomization failed") // `uvm_error("get_pre_transaction_delay", "Randomization failed")
// end // end
dly = $urandom_range(pre_transaction_delay_max, pre_transaction_delay_min); dly = $urandom_range(pre_transaction_delay_max, pre_transaction_delay_min);
cg_pre_transaction_delay.sample(dly);
return dly; return dly;
endfunction endfunction
@@ -62,6 +89,7 @@ class axi_agent_config extends uvm_object;
// `uvm_error("get_pre_response_delay", "Randomization failed") // `uvm_error("get_pre_response_delay", "Randomization failed")
// end // end
dly = $urandom_range(pre_response_delay_max, pre_response_delay_min); dly = $urandom_range(pre_response_delay_max, pre_response_delay_min);
cg_pre_response_delay.sample(dly);
return dly; return dly;
endfunction endfunction
endclass endclass
+47
View File
@@ -9,6 +9,48 @@ class axi_transaction extends uvm_sequence_item;
rand bit [2:0] size; // Size rand bit [2:0] size; // Size
rand bit [7:0] length; // Length rand bit [7:0] length; // Length
// --------------------------------------------------
// Functional coverage
// --------------------------------------------------
/* verilator lint_off COVERIGN */
covergroup cg_axi_transaction with function sample();
option.per_instance = 1;
cp_type: coverpoint txn_type;
cp_size: coverpoint size {
bins b0 = {3'd0};
bins b1 = {3'd1};
bins b2 = {3'd2};
bins b3 = {3'd3};
bins b4 = {3'd4};
bins b5 = {3'd5};
bins b6 = {3'd6};
bins b7 = {3'd7};
}
cp_len: coverpoint length {
bins single = {8'd0};
bins short = {[8'd1:8'd3]};
bins mid = {[8'd4:8'd15]};
bins long = {[8'd16:8'd255]};
}
cp_resp: coverpoint resp;
cp_strb: coverpoint strb {
bins none = {'0};
bins full = { {`DATA_WIDTH_DIV_8{1'b1}} };
bins other = default;
}
cp_addr_lsb: coverpoint addr[11:0] {
bins aligned = {12'h000};
bins unaligned = default;
}
cp_addr_msb: coverpoint addr[`ADDR_WIDTH-1 -: 4] iff (`ADDR_WIDTH >= 4);
x_type_size: cross cp_type, cp_size;
x_type_len: cross cp_type, cp_len;
x_type_resp: cross cp_type, cp_resp;
endgroup
/* verilator lint_on COVERIGN */
`uvm_object_utils_begin(axi_transaction) `uvm_object_utils_begin(axi_transaction)
`uvm_field_enum(axi_transaction_type_t, txn_type, UVM_DEFAULT) `uvm_field_enum(axi_transaction_type_t, txn_type, UVM_DEFAULT)
`uvm_field_int(addr, UVM_DEFAULT) `uvm_field_int(addr, UVM_DEFAULT)
@@ -22,6 +64,11 @@ class axi_transaction extends uvm_sequence_item;
// Constructor // Constructor
function new(string name = "axi_transaction"); function new(string name = "axi_transaction");
super.new(name); super.new(name);
cg_axi_transaction = new();
endfunction
function void sample_coverage();
cg_axi_transaction.sample();
endfunction endfunction
// Get transaction id - made up of sequence ID and trasacton ID // Get transaction id - made up of sequence ID and trasacton ID