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 16

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

powered by: WebSVN 2.1.0

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