OpenCores
URL https://opencores.org/ocsvn/uart2bus_testbench/uart2bus_testbench/trunk

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [agent/] [coverage/] [uart_coverage.svh] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 HanySalah
//-------------------------------------------------------------------------------------------------
2
//
3
//                             UART2BUS VERIFICATION
4
//
5
//-------------------------------------------------------------------------------------------------
6
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : AGENT
9
//-------------------------------------------------------------------------------------------------
10
// TITLE      : UART Coverage
11
// DESCRIPTION: THIS BLOCK INCLUDES ALL THE COVERPINS THAT ARE SAMPLED EACH STIMULUS
12
//-------------------------------------------------------------------------------------------------
13
// LOG DETAILS
14
//-------------
15
// VERSION      NAME        DATE        DESCRIPTION
16
//    1       HANY SALAH    08022016    FILE CREATION
17
//    2       HANY SALAH    11022016    IMPROVE BLOCK DESCRIPTION & ADD CODE COMMENTS
18
//-------------------------------------------------------------------------------------------------
19
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
20
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
21
//-------------------------------------------------------------------------------------------------
22
 
23 18 HanySalah
struct {command cmd1; command cmd2;} twoburstscmd;
24 13 HanySalah
 
25
class uart_coverage extends uvm_subscriber#(uart_transaction);
26 4 HanySalah
 
27
  `uvm_component_utils(uart_coverage)
28
 
29
  uart_transaction        trans,_trans;
30 18 HanySalah
  uart_transaction        trans_o1,trans_o2,trans_o3;
31 4 HanySalah
 
32 18 HanySalah
   uart_dashboard          dashboard;
33
 
34
 
35 4 HanySalah
  covergroup trans_attrib;
36
    communication_mode:
37
      coverpoint trans._mode{
38
        bins valid_mode         = {text,binary};
39 18 HanySalah
        ignore_bins invalid_mode       = {wrong_mode_text,wrong_mode_bin};
40 4 HanySalah
      }
41
    address:
42
      coverpoint trans.address;
43 14 HanySalah
 
44 4 HanySalah
  endgroup:trans_attrib
45
 
46
  covergroup text_mode_cov;
47
    command:
48
      coverpoint trans._command{
49 13 HanySalah
        bins          valid_command  ={read,2};
50 18 HanySalah
        ignore_bins  invalid_command={nop,invalid_read,invalid_write};
51 4 HanySalah
      }
52
    first_white_space_field:
53 14 HanySalah
      coverpoint trans._spacetype1{bins         validspace   ={single,tab};
54 18 HanySalah
                                   ignore_bins invalidspace ={wrong_space};}
55 4 HanySalah
    second_white_space_field:
56 14 HanySalah
      coverpoint trans._spacetype2{bins         validspace   ={single,tab};
57 18 HanySalah
                                   ignore_bins invalidspace ={wrong_space};}
58 4 HanySalah
    end_of_line_field:
59 14 HanySalah
      coverpoint trans._eoltype{bins         valideol={cr,lf};
60 18 HanySalah
                                ignore_bins eol ={wrong_eol};}
61 4 HanySalah
    prefix_character_type:
62
      coverpoint trans._chartype;
63 18 HanySalah
 
64
    white_spaces_x:
65
      cross first_white_space_field,second_white_space_field,end_of_line_field;
66
 
67
    pref_x_command:
68
      cross command,prefix_character_type;
69
 
70 4 HanySalah
  endgroup:text_mode_cov
71
 
72
  covergroup binary_mode_cov;
73
    command:
74
      coverpoint trans._command{
75 13 HanySalah
        bins normal_command={read,2,nop};
76 18 HanySalah
        ignore_bins wrong_command ={invalid_read,invalid_write};
77 4 HanySalah
      }
78
    acknowledge_requirement:
79
      coverpoint trans._reqack;
80
    incremental_address_requirement:
81
      coverpoint trans._reqinc;
82
    Length_of_data:
83
      coverpoint trans.length_data{
84
        bins zero           = {0};
85
        bins valid          = {[1:256]};
86
        illegal_bins invalid= {[257:$]};
87
      }
88
  endgroup:binary_mode_cov
89 18 HanySalah
 
90
  covergroup two_bursts ;
91
     command: coverpoint trans._command{
92
        bins nop_write = (nop=>2);
93
        bins nop_read  = (nop=>read);
94
        bins nop_nop   = (nop=>nop);
95
        bins write_write = (2=>2);
96
        bins write_read  = (2=>read);
97
        bins write_nop   = (2=>nop);
98
        bins read_write = (read=>2);
99
        bins read_read  = (read=>read);
100
        bins read_nop   = (read=>nop);
101
     }
102
     mode_trans: coverpoint trans._mode
103
       {
104
        bins text_bin  = (text=>binary);
105
        bins bin_text  = (binary=>text);
106
        bins bin_bin   = (binary=>binary);
107
        bins text_text = (text=>text);
108
        }
109
     mode_x_cmd: cross command,mode_trans
110
       {
111
        illegal_bins text_nop1 = binsof(command.nop_write) && (binsof(mode_trans.text_bin) || binsof(mode_trans.text_text) );
112
        illegal_bins text_nop2 = binsof(command.nop_read)  && (binsof(mode_trans.text_bin) || binsof(mode_trans.text_text) );
113
        illegal_bins text_nop3 = binsof(command.nop_nop)   && (binsof(mode_trans.text_bin) || binsof(mode_trans.text_text) ||
114
                                                               binsof(mode_trans.bin_text));
115
        illegal_bins text_nop4 = binsof(command.write_nop) && (binsof(mode_trans.bin_text) || binsof(mode_trans.text_text) );
116
        illegal_bins text_nop5 = binsof(command.read_nop)  && (binsof(mode_trans.bin_text) || binsof(mode_trans.text_text) );
117
     }
118
 
119
  endgroup // two_bursts
120 4 HanySalah
 
121 18 HanySalah
   covergroup four_bursts ;
122
      command: coverpoint trans._command
123
        {
124
         bins nop_read_write_nop = (nop=>read=>2=>nop);
125
         bins read_write_read_write = (read=>2=>read=>2);
126
         bins read_read_write_read  = (read=>read=>2=>read);
127
         bins write_read_read_write = (2=>read=>read=>2);
128
         bins write_write_read_write= (2=>2=>read=>2);
129
         bins write_write_write_write=(2=>2=>2=>2);
130
         bins read_read_read_read   = (read=>read=>read=>read);
131
         bins nop_nop_nop_nop       = (nop=>nop=>nop=>nop);
132
      }
133
 
134
   endgroup
135
 
136 4 HanySalah
  function new (string name, uvm_component parent);
137
    super.new(name,parent);
138
 
139
    trans_attrib    = new();
140
    text_mode_cov   = new();
141
    binary_mode_cov = new();
142 18 HanySalah
    two_bursts      = new();
143
    four_bursts     = new();
144 4 HanySalah
  endfunction:new
145
 
146
  extern function void build_phase(uvm_phase phase);
147
 
148
  extern function void connect_phase (uvm_phase phase);
149 11 HanySalah
 
150
  extern task run_phase (uvm_phase);
151 4 HanySalah
 
152 13 HanySalah
  extern function void write (uart_transaction t);
153 18 HanySalah
 
154
  extern function void update_cov ();
155 11 HanySalah
 
156 4 HanySalah
endclass:uart_coverage
157
 
158
 
159
function void uart_coverage::build_phase (uvm_phase phase);
160 18 HanySalah
   super.build_phase(phase);
161
   trans  = uart_transaction::type_id::create("trans");
162
   dashboard = uvm_resource_db#(uart_dashboard)::get_by_name("shared_cloud","dashboard").read();
163 4 HanySalah
endfunction:build_phase
164
 
165
function void uart_coverage::connect_phase(uvm_phase phase);
166
endfunction:connect_phase
167
 
168
task uart_coverage::run_phase(uvm_phase phase);
169 13 HanySalah
 
170
endtask:run_phase
171
 
172
function void uart_coverage::write(uart_transaction t);
173
   $cast(trans,t.clone());
174 14 HanySalah
   trans_attrib.sample();
175 4 HanySalah
    if(trans._mode == text)
176
      begin
177
      text_mode_cov.sample();
178
      end
179
    else if (trans._mode == binary)
180
      begin
181
      binary_mode_cov.sample();
182
      end
183 18 HanySalah
   four_bursts.sample();
184
   two_bursts.sample();
185
   update_cov();
186 13 HanySalah
endfunction // write
187 18 HanySalah
 
188
function void uart_coverage::update_cov();
189
   dashboard.trans_attribute_cov=trans_attrib.get_coverage();
190
   dashboard.text_mode_cov = text_mode_cov.get_coverage();
191
   dashboard.binary_mode_cov = binary_mode_cov.get_coverage();
192
   dashboard.two_binary_bursts_cov=two_bursts.get_coverage();
193
   dashboard.four_bursts_cov=four_bursts.get_coverage();
194
   dashboard.evaluate_coverage();
195
endfunction // update_cov

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.