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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [defin_lib.svh] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 HanySalah
//-----------------------------------------------------------------------------
2
//
3
//                             UART2BUS VERIFICATION
4
//
5
//-----------------------------------------------------------------------------
6
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : DEFINITION LIBRARY
9
//-----------------------------------------------------------------------------
10
// TITLE      : UART Definition Library
11
// DESCRIPTION: This
12
//-----------------------------------------------------------------------------
13
// LOG DETAILS
14
//-------------
15
// VERSION      NAME        DATE        DESCRIPTION
16
//    1       HANY SALAH    25122015    FILE CREATION
17
//    2       HANY SALAH    31122015    ADD DATA TYPE DEFINITIONS
18
//    3       HANY SALAH    11012016    ADD TIMING PARAMETERS DEFINITION
19
//-----------------------------------------------------------------------------
20
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
21
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
22
// CREATOR'S PERMISSION
23
//-----------------------------------------------------------------------------
24
`timescale 1ns/1ns
25
//------------------------------------------
26
//
27
//  Definition Identifiers
28
//
29
//------------------------------------------
30
 
31
  // Define size of address line
32
  `define size  16
33
 
34
  // 2 power size
35
  `define mem_size 65536
36
 
37
  // ASCII of 'r'
38
  `define r   8'h72
39
 
40
  // ASCII of 'R'
41
  `define R   8'h52
42
 
43
  // ASCII of 'w'
44
  `define w   8'h77
45
 
46
  // ASCII of 'W'
47
  `define W   8'h57
48
 
49
  // BINARY COMMAND PREFIX
50
  `define bin_prfx 8'h0
51
 
52
  // Single Space
53
  `define space 8'h20
54
 
55
  // Signel Tab
56
  `define tab   8'h09
57
 
58
  // LF
59
  `define LF    8'h0A
60
 
61
  // CR
62
  `define CR    8'h0D
63
 
64
  //UNIFIED ACK
65
  `define ACK   8'h5A
66
 
67
  // work on positive edge
68
  `define _posedge      1
69
 
70
  // work on negative edge
71
  `define _negedge      2
72
 
73
  // start with MSB
74
  `define msb_first     1
75
 
76
  // start with LSB
77
  `define lsb_first     2
78
 
79
  // Text Mode Command
80
  `define text_mode     1
81
 
82
  // Binary Mode Command
83
  `define binary_mode   2
84
 
85
  // Wrong Mode Command
86
  `define wrong_mode    3
87
 
88
  // Read Command
89
  `define read_comm     1
90
 
91
  // write Command
92
  `define write_comm    2
93
 
94
  // nop Command
95
  `define nop_comm      3
96
 
97
  // wrong Command
98
  `define wrong_comm    4
99
 
100
  // Use single white space
101
  `define single_space  1
102
 
103
  // Use multiple white space
104
  `define tab_space     2
105
 
106
  // Use wrong space character
107
  `define space_wrong   3
108
 
109
  // use cr as eol
110
  `define cr_eol        1
111
 
112
  // use lf as eol
113
  `define lf_eol        2
114
 
115
  // Use wrong eol
116
  `define eol_wrong     3
117
 
118
  // request either address increment or acknowledge
119
  `define _yes          1
120
 
121
  // don't request either address increment or acknowledge
122
  `define _no           2
123
 
124
  // Use capital Leter
125
  `define capital_let   1
126
 
127
  // Use small letter
128
  `define small_let     2
129
 
130
  // accept arbitration
131
  `define accept        1
132
 
133
  // declain arbitration
134
  `define declain       2
135
 
136
  // Binary represnetation
137
  `define binary_rep    1
138
 
139
  // ASCII Representation
140
  `define ascii_rep     2
141
 
142
  // NOP Control
143
  `define nop_ctrl      2'b00
144
 
145
  // Read Control
146
  `define read_ctrl     2'b01
147
 
148
  // Write Control
149
  `define write_ctrl    2'b10
150
//------------------------------------------
151
//
152
//  Timing Defines
153
//
154
//------------------------------------------
155
  // Define stability time
156
  `define stab               10
157
 
158
  // Define the period of global clock in terms of ns
159
  `define glob_clk_period    25
160
 
161
  // Define the period of baud clock in terms of ns
162
  `define buad_clk_period    8680
163
//------------------------------------------
164
//
165
//  Configuration Data Type
166
//
167
//------------------------------------------
168
 
169
// Represents the active edge
170
typedef enum {pos_edge=1,            // Based on positive edge
171
              neg_edge=2} act_edge;  // Based on negative edge
172
 
173
// Represent the starting bit
174
typedef enum {msb=1,                 // Most Significant bit first
175
              lsb=2}  start_bit;     // Least Significant bit first
176
 
177
//------------------------------------------
178
//
179
//  New Data Type Definitions
180
//
181
//------------------------------------------
182
 
183
  // Represents the mode of command to be one of the following options {text, command, wrong}. Wrong
184
  // command mode is used to send a tricky fault command to test our DUT.
185
  typedef enum {text=1,                    // Communicate using text mode
186
                binary=2,                  // Communicate using command mode
187
                wrong_mode=3} mode;        // Communicate using wrong prefix
188
 
189
  // Represents the type of the used white space to be one of the following options {single, tab, wrong}.
190
  // Wrong type also is used to push tricky byte in the text mode.
191
  typedef enum {single=1,             // Using single space as a white space
192
                tab=2,                // Using tab as a white space
193
                wrong_space=3} space_type;  // Using wrong white space
194
 
195
  // Represents the type of end of line used to be one of the following choices{cr, lf, wrong}.
196
  // Wrong type is also used to push DUT in tricky manner.
197
  typedef enum {cr=1,                      // Using CR as EOL
198
                lf=2,                      // Using LF as EOL
199
                wrong_eol=3} eol_type;    // Using wrong EOL
200
 
201
  // Represents the command either to be one of the following choices {read, write, NOP}
202
  typedef enum {read=1,               // Read Command
203
                write=2,              // Write Command
204
                nop=3,                // Make No Operation
205
                invalid=4} command;   // Invalid command value
206
 
207
  // Represents both acknowledge and incremental address request{yes, no}
208
  typedef enum {yes=1,                // Request Acknowledge
209
                no=2} req;            // Request No Acknowledge
210
 
211
  // Represents the type of prefix in text mode either to be {capital, small}.
212
  typedef enum {cap=1,                // Capital Letter
213
                smal=2} char_type;    // Small Letter
214
 
215
  // Represents the internal bus state either {accept, refuse}
216
  typedef enum {accept=1,             // Accept Bus Grant
217
                declain=2} arbit;     // Refuse Bus Grant
218
 
219
  // Define mode of data {ascii or binary}
220
  typedef enum {bin=1,
221
                ascii=2} data_mode;
222
 
223
  // Define mode of the used parity
224
  typedef enum {parity_off=1,
225
                parity_even=2,
226
                parity_odd=3}  parity_mode ;
227
 
228
//-------------------------------------------------------
229
//
230
//      GLOBAL FUNCTION
231
//
232
//-------------------------------------------------------
233
 
234
// Binary To ASCII Conversion to convert nibble into ASCII byte through the following look-up-table
235
function byte bin_asci_conv (bit[3:0] data);
236
  byte temp;
237
  case (data)
238
    4'h0:
239
      begin
240
      temp = 8'h30;
241
      end
242
    4'h1:
243
      begin
244
      temp = 8'h31;
245
      end
246
    4'h2:
247
      begin
248
      temp = 8'h32;
249
      end
250
    4'h3:
251
      begin
252
      temp = 8'h33;
253
      end
254
    4'h4:
255
      begin
256
      temp = 8'h34;
257
      end
258
    4'h5:
259
      begin
260
      temp = 8'h35;
261
      end
262
    4'h6:
263
      begin
264
      temp = 8'h36;
265
      end
266
    4'h7:
267
      begin
268
      temp = 8'h37;
269
      end
270
    4'h8:
271
      begin
272
      temp = 8'h38;
273
      end
274
    4'h9:
275
      begin
276
      temp = 8'h39;
277
      end
278
    4'hA:
279
      begin
280
      temp = 8'h41;
281
      end
282
    4'hB:
283
      begin
284
      temp = 8'h42;
285
      end
286
    4'hC:
287
      begin
288
      temp = 8'h43;
289
      end
290
    4'hD:
291
      begin
292
      temp = 8'h44;
293
      end
294
    4'hE:
295
      begin
296
      temp = 8'h45;
297
      end
298
    4'hF:
299
      begin
300
      temp = 8'h46;
301
      end
302
  endcase
303
  return temp;
304
endfunction:bin_asci_conv
305
 
306
// ASCII To Binary Conversion is to convert ASCII byte into Binary nibble through the following Look-Up-Table
307
function bit [3:0] asci_bin_conv (byte data);
308
  bit [3:0] temp;
309
  case (data)
310
    8'h30:
311
      begin
312
      temp = 4'h0;
313
      end
314
    8'h31:
315
      begin
316
      temp = 4'h1;
317
      end
318
    8'h32:
319
      begin
320
      temp = 4'h2;
321
      end
322
    8'h33:
323
      begin
324
      temp = 4'h3;
325
      end
326
    8'h34:
327
      begin
328
      temp = 4'h4;
329
      end
330
    8'h35:
331
      begin
332
      temp = 4'h5;
333
      end
334
    8'h36:
335
      begin
336
      temp = 4'h6;
337
      end
338
    8'h37:
339
      begin
340
      temp = 4'h7;
341
      end
342
    8'h38:
343
      begin
344
      temp = 4'h8;
345
      end
346
    8'h39:
347
      begin
348
      temp = 4'h9;
349
      end
350
    8'h41:
351
      begin
352
      temp = 4'hA;
353
      end
354
    8'h42:
355
      begin
356
      temp = 4'hB;
357
      end
358
    8'h43:
359
      begin
360
      temp = 4'hC;
361
      end
362
    8'h44:
363
      begin
364
      temp = 4'hD;
365
      end
366
    8'h45:
367
      begin
368
      temp = 4'hE;
369
      end
370
    8'h46:
371
      begin
372
      temp = 4'hF;
373
      end
374
    default:
375
      begin
376
      $error("undefined ascii symbol");
377
      end
378
  endcase
379
  return temp;
380
endfunction:asci_bin_conv

powered by: WebSVN 2.1.0

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