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 3

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
//-------------------------------------------------------------------------------------------------
22
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
23
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
24
//-------------------------------------------------------------------------------------------------
25 2 HanySalah
class uart_transaction extends uvm_sequence_item;
26
 
27
  // Represent the mode of operation either to be text or command mode
28
  rand mode        _mode;
29
 
30 3 HanySalah
  // Represent the wrong prefix forced in wrong mode
31
  rand byte        wrong_prefix;
32
 
33 2 HanySalah
  // Represent the type of space either to be single space or tab
34
  rand space_type  _spacetype1,_spacetype2;
35
 
36 3 HanySalah
  // Represent the wrong character used as a white space [Refer To Verification Plan For More
37
  // Information]
38 2 HanySalah
  rand  byte        space_wrong1;
39
 
40 3 HanySalah
  // Represent the wrong character used as a white space [Refer To Verification Plan For More
41
  // Information]
42 2 HanySalah
  rand  byte        space_wrong2;
43
 
44
  // Represent the used data through the stimulus
45
  rand  byte       _data [];
46
 
47 3 HanySalah
  // Represent the false data that is drivin on the serial output bus through the read command
48
  // response
49
  rand  byte       false_data [];
50
 
51 2 HanySalah
  // Represent the length of data used through the stimulus
52
  rand int unsigned length_data;
53
 
54
  // Represent the type of end of line used
55
  rand eol_type     _eoltype;
56
 
57 3 HanySalah
  // Represent the wrong character used as an end of line [Refer To Verification Plan For More
58
  // Information]
59 2 HanySalah
  rand byte         eol_wrong;
60
 
61
  // Represent the used address through the stimulus
62
  rand bit [15:0]   address;
63
 
64
  // Represent the type of command either read, write or no operation
65
  rand command      _command;
66
 
67
  // Represent the acknowledge request
68
  rand req      _reqack;
69
 
70
  // Represent the incremental address request
71
  rand req      _reqinc;
72
 
73
  // Represent the character type of prefix in text mode command
74
  rand char_type    _chartype;
75
 
76
  // Represent the internal bus state either free or busy
77
  rand arbit        _arbit;
78
 
79 3 HanySalah
  // Represent the request to use false data through the read command.
80
  rand req          false_data_en;
81
 
82
  // Represents random idle time before and after the UART stimulus
83 2 HanySalah
  rand time         time_before,time_after;
84
 
85 3 HanySalah
  // Represents the acknowledge byte driven by the DUT
86 2 HanySalah
  byte            acknowledge;
87
 
88 3 HanySalah
  // Represent the number of the transaction through the whole sequences
89
  int             _id;
90
 
91
  // Represent the scale that is used to scale the idle time values described above
92 2 HanySalah
  int unsigned scale = 100;
93
 
94
  `uvm_object_utils(uart_transaction)
95
 
96
  function new (string name ="uart_transaction");
97
    super.new(name);
98
  endfunction: new
99
 
100 3 HanySalah
  // This constraint limit the size of unbounded data and false data arrays to be in the range
101
  // between one byte and 256 successive bytes.
102
  // To make Testbench more simple, the length of data is constrained to be less than or equal
103
  // 10 bytes.
104
  // Idle time valu
105 2 HanySalah
  constraint data_length {
106
      _data.size == length_data;
107 3 HanySalah
      false_data.size ==length_data;
108 2 HanySalah
      length_data <= 10;
109 3 HanySalah
      length_data inside {[1:256]};
110 2 HanySalah
      time_before inside {200,300,400,500,600,700,800,900,1000};
111
      time_after  inside {200,300,400,500,600,700,800,900,1000};
112
  }
113
 
114 3 HanySalah
  // This constraint is used to constrain the wrong character not to be as the UART standard
115
  // characters.
116
  // In case of text command, it is critical to make the white space wrong character
117
  // not to be simiar to either single space character or Tab space character.Address and Data
118
  // bytes as well shouldn't be like the standard characters.
119
  // In case of binary command, it is also critical to make the length byte, address bytes, data
120
  // bytes similiar to UART standard characters.
121
  constraint transaction_valid {
122
      !(space_wrong1 inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
123
      !(space_wrong2 inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
124
      !(eol_wrong inside {`space,`tab,`w,`W,`bin_prfx,`CR,`LF});
125
      if (_mode inside {wrong_mode_text,wrong_mode_bin})
126
        {
127
          !(space_wrong1 inside {`w,`W,`r,`R,`bin_prfx});
128
          !(space_wrong2 inside {`w,`W,`r,`R,`bin_prfx});
129
          !(address [15:08] inside {`w,`W,`r,`R,`bin_prfx});
130
          !(address [07:00] inside {`w,`W,`r,`R,`bin_prfx});
131
          foreach(_data[i])
132
            !(_data[i] inside {`w,`W,`r,`R,`bin_prfx});
133
 
134
          !(length_data inside {`w,`W,`r,`R,`bin_prfx});
135
 
136
 
137
        }
138
  }
139
 
140
  // This constraint is used to re-distribute the random enable bit of the false data usage
141
  constraint read_data_constraints{
142
 
143
      if(_command == read)
144
      {
145
        false_data_en dist {no:=8, yes:=2};
146
      }
147
  }
148
 
149 2 HanySalah
  extern function void do_copy (uvm_object rhs);
150 3 HanySalah
 
151 2 HanySalah
endclass:uart_transaction
152
 
153
 
154
function void uart_transaction::do_copy (uvm_object rhs);
155
  uart_transaction _trans;
156
  if (!$cast(_trans,rhs))
157
    begin
158
    `uvm_fatal("TYPE MISMATCH", "Type mismatch through do_copy method")
159
    end
160
  super.do_copy (_trans);
161
  _mode       =_trans._mode;
162
  _spacetype1 =_trans._spacetype1;
163
  _spacetype2 =_trans._spacetype2;
164
  space_wrong1=_trans.space_wrong1;
165
  space_wrong2=_trans.space_wrong2;
166
  _data       =_trans._data;
167
  length_data =_trans.length_data;
168
  _eoltype    =_trans._eoltype;
169
  eol_wrong   =_trans.eol_wrong;
170
  address     =_trans.address;
171
  _command    =_trans._command;
172
  _reqack     =_trans._reqack;
173
  _reqinc     =_trans._reqinc;
174
  _chartype   =_trans._chartype;
175
  _arbit      =_trans._arbit;
176
  time_before =_trans.time_before;
177
  time_after  =_trans.time_after;
178
  acknowledge = _trans.acknowledge;
179 3 HanySalah
  wrong_prefix=_trans.wrong_prefix;
180
  false_data  =_trans.false_data;
181
  false_data_en =_trans.false_data_en;
182
  _id           =_trans._id;
183 2 HanySalah
endfunction:do_copy

powered by: WebSVN 2.1.0

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