covergroup_type_cast - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

208


40
 
1
typedef enum logic [1:0] {ZERO, ONE, TWO} reg_t;
2
3
class RegClass;
4
  rand reg_t v;
5
6
  function logic [1:0] get;
7
    return v;
8
  endfunction
9
endclass
10
11
12
class MyTest;
13
  RegClass regClass;
14
15
  covergroup cg;
16
    option.per_instance = 1;
17
    cp1: coverpoint regClass.get();
18
    cp2: coverpoint reg_t'(regClass.get());
19
  endgroup
20
21
  function new();
22
    cg = new;
23
    regClass = new;
24
  endfunction
25
26
  function void run();
27
    regClass.randomize();
28
    cg.sample();
29
  endfunction
30
endclass
31
32
program top;
33
  initial begin
34
    MyTest myTest;
35
36
    myTest = new;
37
    myTest.run();
38
  end
39
endprogram
40
xxxxxxxxxx
1
 
1
// Code your design here
2
188 views and 0 likes     
 
A sample program of covergroup that casting logic vector into enum type.
Coverage result will be in cov.txt.

A sample program of covergroup that casting logic vector into enum type.
Coverage result will be in cov.txt.

2190:0