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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [agent/] [transaction/] [uart_transaction.svh] - Blame information for rev 14

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 HanySalah
//-------------------------------------------------------------------------------------------------
2 2 HanySalah
//
3
//                             UART2BUS VERIFICATION
4
//
5 3 HanySalah
//-------------------------------------------------------------------------------------------------
6 2 HanySalah
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : TRANSACTION
9 3 HanySalah
//-------------------------------------------------------------------------------------------------
10 2 HanySalah
// TITLE      : UART Transaction
11 3 HanySalah
// DESCRIPTION: THIS FILE INCLUDES MAIN TRANSACTION ATTRIBUTES, CONSTRAINTS AND DO-COPY OVERRIDE
12
//              FUNCTION
13
//-------------------------------------------------------------------------------------------------
14 2 HanySalah
// LOG DETAILS
15
//-------------
16
// VERSION      NAME        DATE        DESCRIPTION
17
//    1       HANY SALAH    31122015    FILE CREATION
18
//    2       HANY SALAH    01012016    COMPLETE ATTRIBUTES
19 3 HanySalah
//    3       HANY SALAH    26012016    ADD VALID TRANSACTION CONSTRAINTS
20
//    4       HANY SALAH    11022016    IMPROVE BLOCK DESCRIPTION AND ADD CODING COMMENTS
21 14 HanySalah
//    5       HANY SALAH    25062017    ADD DO_COPY, DO_COMPARE METHODS
22 3 HanySalah
//-------------------------------------------------------------------------------------------------
23
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
24
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
25
//-------------------------------------------------------------------------------------------------
26 2 HanySalah
class uart_transaction extends uvm_sequence_item;
27
 
28
  // Represent the mode of operation either to be text or command mode
29
  rand mode        _mode;
30
 
31 3 HanySalah
  // Represent the wrong prefix forced in wrong mode
32
  rand byte        wrong_prefix;
33
 
34 2 HanySalah
  // Represent the type of space either to be single space or tab
35
  rand space_type  _spacetype1,_spacetype2;
36
 
37 3 HanySalah
  // Represent the wrong character used as a white space [Refer To Verification Plan For More
38
  // Information]
39 2 HanySalah
  rand  byte        space_wrong1;
40
 
41 3 HanySalah
  // Represent the wrong character used as a white space [Refer To Verification Plan For More
42
  // Information]
43 2 HanySalah
  rand  byte        space_wrong2;
44
 
45
  // Represent the used data through the stimulus
46
  rand  byte       _data [];
47
 
48 3 HanySalah
  // Represent the false data that is drivin on the serial output bus through the read command
49
  // response
50
  rand  byte       false_data [];
51
 
52 2 HanySalah
  // Represent the length of data used through the stimulus
53
  rand int unsigned length_data;
54
 
55
  // Represent the type of end of line used
56
  rand eol_type     _eoltype;
57
 
58 3 HanySalah
  // Represent the wrong character used as an end of line [Refer To Verification Plan For More
59
  // Information]
60 2 HanySalah
  rand byte         eol_wrong;
61
 
62
  // Represent the used address through the stimulus
63
  rand bit [15:0]   address;
64
 
65
  // Represent the type of command either read, write or no operation
66
  rand command      _command;
67
 
68
  // Represent the acknowledge request
69
  rand req      _reqack;
70
 
71
  // Represent the incremental address request
72
  rand req      _reqinc;
73
 
74
  // Represent the character type of prefix in text mode command
75
  rand char_type    _chartype;
76
 
77
  // Represent the internal bus state either free or busy
78
  rand arbit        _arbit;
79
 
80 3 HanySalah
  // Represent the request to use false data through the read command.
81
  rand req          false_data_en;
82
 
83
  // Represents random idle time before and after the UART stimulus
84 14 HanySalah
  rand int         time_before,time_after;
85 2 HanySalah
 
86 3 HanySalah
  // Represents the acknowledge byte driven by the DUT
87 2 HanySalah
  byte            acknowledge;
88
 
89 3 HanySalah
  // Represent the number of the transaction through the whole sequences
90
  int             _id;
91
 
92
  // Represent the scale that is used to scale the idle time values described above
93 2 HanySalah
  int unsigned scale = 100;
94
 
95 14 HanySalah
  `uvm_object_utils_begin(uart_transaction)
96
     `uvm_field_int(wrong_prefix,UVM_ALL_ON)
97
     `uvm_field_enum(mode,_mode,UVM_ALL_ON)
98
     `uvm_field_enum(eol_type,_eoltype,UVM_ALL_ON)
99
     `uvm_field_enum(space_type,_spacetype1,UVM_ALL_ON)
100
     `uvm_field_enum(space_type,_spacetype2,UVM_ALL_ON)
101
     `uvm_field_enum(command,_command,UVM_ALL_ON)
102
     `uvm_field_enum(req,_reqack,UVM_ALL_ON)
103
     `uvm_field_enum(req,_reqinc,UVM_ALL_ON)
104
     `uvm_field_enum(char_type,_chartype,UVM_ALL_ON)
105
     `uvm_field_enum(arbit,_arbit,UVM_ALL_ON)
106
     `uvm_field_enum(req,false_data_en,UVM_ALL_ON)
107
     `uvm_field_int(wrong_prefix,UVM_ALL_ON)
108
     `uvm_field_int(space_wrong1,UVM_ALL_ON)
109
     `uvm_field_int(space_wrong2,UVM_ALL_ON)
110
     `uvm_field_array_int(_data,UVM_ALL_ON)
111
     `uvm_field_array_int(false_data,UVM_ALL_ON)
112
     `uvm_field_int(length_data,UVM_ALL_ON)
113
     `uvm_field_int(eol_wrong,UVM_ALL_ON)
114
     `uvm_field_int(address,UVM_ALL_ON)
115
     `uvm_field_int(time_before,UVM_ALL_ON)
116
     `uvm_field_int(time_after,UVM_ALL_ON)
117
     `uvm_field_int(acknowledge,UVM_ALL_ON)
118
     `uvm_field_int(_id,UVM_ALL_ON)
119
     `uvm_field_int(scale,UVM_ALL_ON)
120
  `uvm_object_utils_end
121
 
122 2 HanySalah
  function new (string name ="uart_transaction");
123
    super.new(name);
124
  endfunction: new
125
 
126 3 HanySalah
  // This constraint limit the size of unbounded data and false data arrays to be in the range
127
  // between one byte and 256 successive bytes.
128
  // To make Testbench more simple, the length of data is constrained to be less than or equal
129
  // 10 bytes.
130
  // Idle time valu
131 2 HanySalah
  constraint data_length {
132
      _data.size == length_data;
133 3 HanySalah
      false_data.size ==length_data;
134 2 HanySalah
      length_data <= 10;
135 3 HanySalah
      length_data inside {[1:256]};
136 2 HanySalah
      time_before inside {200,300,400,500,600,700,800,900,1000};
137
      time_after  inside {200,300,400,500,600,700,800,900,1000};
138
  }
139
 
140 3 HanySalah
  // This constraint is used to constrain the wrong character not to be as the UART standard
141
  // characters.
142
  // In case of text command, it is critical to make the white space wrong character
143
  // not to be simiar to either single space character or Tab space character.Address and Data
144
  // bytes as well shouldn't be like the standard characters.
145
  // In case of binary command, it is also critical to make the length byte, address bytes, data
146
  // bytes similiar to UART standard characters.
147
  constraint transaction_valid {
148
      !(space_wrong1 inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
149
      !(space_wrong2 inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
150
      !(eol_wrong inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
151
      if (_mode inside {wrong_mode_text,wrong_mode_bin})
152
        {
153
          !(space_wrong1 inside {`w,`W,`r,`R,`bin_prfx});
154
          !(space_wrong2 inside {`w,`W,`r,`R,`bin_prfx});
155
          !(address [15:08] inside {`w,`W,`r,`R,`bin_prfx});
156
          !(address [07:00] inside {`w,`W,`r,`R,`bin_prfx});
157
          foreach(_data[i])
158
            !(_data[i] inside {`w,`W,`r,`R,`bin_prfx});
159
 
160
          !(length_data inside {`w,`W,`r,`R,`bin_prfx});
161
 
162
 
163
        }
164
  }
165
 
166
  // This constraint is used to re-distribute the random enable bit of the false data usage
167
  constraint read_data_constraints{
168
 
169
      if(_command == read)
170
      {
171
        false_data_en dist {no:=8, yes:=2};
172
      }
173
  }
174
 
175 2 HanySalah
  extern function void do_copy (uvm_object rhs);
176 3 HanySalah
 
177 14 HanySalah
  //extern function bit do_compare(uvm_object rhs);
178
 
179
  extern function void do_print(uvm_printer printer=null);
180 13 HanySalah
 
181
 
182 2 HanySalah
endclass:uart_transaction
183
 
184
 
185
function void uart_transaction::do_copy (uvm_object rhs);
186
  uart_transaction _trans;
187
  if (!$cast(_trans,rhs))
188
    begin
189
    `uvm_fatal("TYPE MISMATCH", "Type mismatch through do_copy method")
190
    end
191
  super.do_copy (_trans);
192
  _mode       =_trans._mode;
193
  _spacetype1 =_trans._spacetype1;
194
  _spacetype2 =_trans._spacetype2;
195
  space_wrong1=_trans.space_wrong1;
196
  space_wrong2=_trans.space_wrong2;
197
  _data       =_trans._data;
198
  length_data =_trans.length_data;
199
  _eoltype    =_trans._eoltype;
200
  eol_wrong   =_trans.eol_wrong;
201
  address     =_trans.address;
202
  _command    =_trans._command;
203
  _reqack     =_trans._reqack;
204
  _reqinc     =_trans._reqinc;
205
  _chartype   =_trans._chartype;
206
  _arbit      =_trans._arbit;
207
  time_before =_trans.time_before;
208
  time_after  =_trans.time_after;
209
  acknowledge = _trans.acknowledge;
210 3 HanySalah
  wrong_prefix=_trans.wrong_prefix;
211
  false_data  =_trans.false_data;
212
  false_data_en =_trans.false_data_en;
213
  _id           =_trans._id;
214 13 HanySalah
endfunction:do_copy
215
 
216
 
217 14 HanySalah
/*function bit uart_transaction::do_compare(uvm_object rhs,
218 13 HanySalah
                                          uvm_comparer comparer);
219
   uart_transaction t;
220
   do_compare=super.do_compare(rhs,comparer);
221
   $cast(t,rhs);
222
   do_compare &= comparer.compare_field_ ("_mode",_mode,rhs._mode);
223
   do_compare &= comparer.compare_field_ ("_spacetype1",_spacetype1, rhs._spacetype1);
224
   do_compare &= comparer.compare_field_ ("_spacetype2",_spacetype2, rhs._spacetype2);
225
   do_compare &= comparer.compare_field_ ("space_wrong1",space_wrong1, rhs.space_wrong1);
226
   do_compare &= comparer.compare_field_ ("space_wrong2",space_wrong2, rhs.space_wrong2);
227
   do_compare &= comparer.compare_field_ ("_data",_data, rhs._data);
228
   do_compare &= comparer.compare_field_ ("length_data",length_data, rhs.length_data);
229
   do_compare &= comparer.compare_field_ ("_eoltype",_eoltype, rhs._eoltype);
230
   do_compare &= comparer.compare_field_ ("eol_wrong",eol_wrong, rhs.eol_wrong);
231
   do_compare &= comparer.compare_field_ ("address",address, rhs.address);
232
   do_compare &= comparer.compare_field_ ("_command",_command, rhs._command);
233
   do_compare &= comparer.compare_field_ ("_reqack",_reqack, rhs._reqack);
234
   do_compare &= comparer.compare_field_ ("_reqinc",_reqinc, rhs._reqinc);
235
   do_compare &= comparer.compare_field_ ("_chartype",_chartype, rhs._chartype);
236
   do_compare &= comparer.compare_field_ ("_arbit",_arbit, rhs._arbit);
237
   do_compare &= comparer.compare_field_ ("time_before",time_before, rhs.time_before);
238
   do_compare &= comparer.compare_field_ ("time_after",time_after, rhs.time_after);
239
   do_compare &= comparer.compare_field_ ("acknowledge",acknowledge, rhs.acknowledge);
240
   do_compare &= comparer.compare_field_ ("wrong_prefix",wrong_prefix, rhs.wrong_prefix);
241
   do_compare &= comparer.compare_field_ ("false_data",false_data, rhs.false_data);
242
   do_compare &= comparer.compare_field_ ("false_data_en",false_data_en, rhs.false_data_en);
243
   do_compare &= comparer.compare_field_ ("_id",_id, rhs._id);
244 14 HanySalah
endfunction // do_compare*/
245
 
246
function void uart_transaction::do_print(uvm_printer printer=null);
247
   super.do_print(printer);
248
endfunction // do_print

powered by: WebSVN 2.1.0

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