diff --git a/src/axi/axi_agent_config.sv b/src/axi/axi_agent_config.sv index 47fc1e6..0c40da6 100644 --- a/src/axi/axi_agent_config.sv +++ b/src/axi/axi_agent_config.sv @@ -12,6 +12,30 @@ class axi_agent_config extends uvm_object; /// Maximum value of pre_response_delay 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_field_int(pre_transaction_delay_min, 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"); super.new(name); + cg_pre_transaction_delay = new(); + cg_pre_response_delay = new(); endfunction // -------------------------------------------------- @@ -45,6 +71,7 @@ class axi_agent_config extends uvm_object; // `uvm_error("get_pre_transaction_delay", "Randomization failed") // end dly = $urandom_range(pre_transaction_delay_max, pre_transaction_delay_min); + cg_pre_transaction_delay.sample(dly); return dly; endfunction @@ -62,6 +89,7 @@ class axi_agent_config extends uvm_object; // `uvm_error("get_pre_response_delay", "Randomization failed") // end dly = $urandom_range(pre_response_delay_max, pre_response_delay_min); + cg_pre_response_delay.sample(dly); return dly; endfunction endclass diff --git a/src/axi/axi_transaction.sv b/src/axi/axi_transaction.sv index 0253500..204f2bc 100644 --- a/src/axi/axi_transaction.sv +++ b/src/axi/axi_transaction.sv @@ -9,6 +9,48 @@ class axi_transaction extends uvm_sequence_item; rand bit [2:0] size; // Size 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_field_enum(axi_transaction_type_t, txn_type, UVM_DEFAULT) `uvm_field_int(addr, UVM_DEFAULT) @@ -22,6 +64,11 @@ class axi_transaction extends uvm_sequence_item; // Constructor function new(string name = "axi_transaction"); super.new(name); + cg_axi_transaction = new(); + endfunction + + function void sample_coverage(); + cg_axi_transaction.sample(); endfunction // Get transaction id - made up of sequence ID and trasacton ID