Interview-style solutions for all 10 UVM functional coverage questions

 

1. Unique Address Coverage

class packet;

rand bit [7:0] addr;

covergroup cg;

cp_addr : coverpoint addr {
bins low = {[0:63]};
bins medium = {[64:127]};
bins high = {[128:191]};
bins top = {[192:255]};
}

endgroup

function new();
cg = new();
endfunction

endclass

2. Burst Transaction Coverage

class packet;

rand bit [4:0] burst_len;
rand bit [1:0] burst_type;
rand bit [2:0] size;

covergroup cg;

cp_len : coverpoint burst_len {
bins len[] = {1,2,4,8,16};
}

cp_type : coverpoint burst_type;

cp_size : coverpoint size;

cross cp_len, cp_type, cp_size;

endgroup

function new();
cg = new();
endfunction

endclass

3. AXI Coverage

class axi_packet;

rand bit [3:0] awlen;
rand bit [2:0] awsize;
rand bit [1:0] awburst;
rand bit awlock;

covergroup cg;

cp_len : coverpoint awlen;
cp_size : coverpoint awsize;
cp_burst : coverpoint awburst;
cp_lock : coverpoint awlock;

cross cp_len,cp_size,cp_burst;

endgroup

function new();
cg=new();
endfunction

endclass

4. Packet Length Coverage

class packet;

rand int length;
rand bit crc_error;
rand bit parity_error;

covergroup cg;

cp_len : coverpoint length {

bins small ={[64:256]};
bins medium ={[257:1024]};
bins large ={[1025:2048]};
bins jumbo ={[2049:4096]};

}

cp_crc : coverpoint crc_error;

cp_parity : coverpoint parity_error;

cross cp_len,cp_crc;
cross cp_len,cp_parity;

endgroup

function new();
cg=new();
endfunction

endclass

5. FIFO Coverage

class fifo_cov;

bit empty,full;
bit overflow,underflow;

covergroup cg;

cp_empty : coverpoint empty;

cp_full : coverpoint full;

cp_overflow : coverpoint overflow;

cp_underflow : coverpoint underflow;

transition : coverpoint full{

bins full_to_empty =(1=>0);

}

endgroup

function new();
cg=new();
endfunction

endclass

6. Cache Coverage

class cache_cov;

bit hit;
bit write;
bit invalidate;

covergroup cg;

cp_hit : coverpoint hit;

cp_write : coverpoint write;

cp_inv : coverpoint invalidate;

cross cp_hit,cp_write;

endgroup

function new();
cg=new();
endfunction

endclass

7. Interrupt Coverage

class intr_cov;

rand bit [4:0] intr_id;
rand bit [2:0] priority;

covergroup cg;

cp_intr : coverpoint intr_id;

cp_priority : coverpoint priority;

cross cp_intr,cp_priority;

endgroup

function new();
cg=new();
endfunction

endclass

8. Random Reset Coverage

class reset_cov;

typedef enum {IDLE,READ,WRITE,ERROR} state_t;

state_t state;

bit reset;

covergroup cg;

cp_state : coverpoint state;

cp_reset : coverpoint reset;

cross cp_state,cp_reset;

endgroup

function new();
cg=new();
endfunction

endclass

9. Memory Controller Coverage

class mem_cov;

rand bit read;
rand bit write;

rand bit [3:0] bank;

covergroup cg;

cp_read : coverpoint read;

cp_write : coverpoint write;

cp_bank : coverpoint bank;

cross cp_bank,cp_read,cp_write;

endgroup

function new();
cg=new();
endfunction

endclass

Post a Comment

0 Comments