1 |
44 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2018 Authors and OPENCORES.ORG ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This source file may be used and distributed without ////
|
6 |
|
|
//// restriction provided that this copyright statement is not ////
|
7 |
|
|
//// removed from the file and that any derivative work contains ////
|
8 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// This source file is free software; you can redistribute it ////
|
11 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
12 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
13 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
14 |
|
|
//// later version. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source is distributed in the hope that it will be ////
|
17 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
18 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
19 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
20 |
|
|
//// details. ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
23 |
|
|
//// Public License along with this source; if not, download it ////
|
24 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
25 |
|
|
//// ////
|
26 |
|
|
//////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
class fifo_sequence_item
|
29 |
|
|
extends uvm_sequence_item;
|
30 |
|
|
`uvm_object_utils(fifo_sequence_item)
|
31 |
|
|
|
32 |
|
|
// --------------------------------------------------------------------
|
33 |
|
|
rand int delay;
|
34 |
|
|
rand fifo_command_t command;
|
35 |
|
|
rand logic [W-1:0] wr_data;
|
36 |
|
|
|
37 |
|
|
// --------------------------------------------------------------------
|
38 |
|
|
logic wr_full;
|
39 |
|
|
logic rd_empty;
|
40 |
|
|
logic [W-1:0] rd_data;
|
41 |
|
|
logic [UB:0] count;
|
42 |
|
|
|
43 |
|
|
// --------------------------------------------------------------------
|
44 |
|
|
constraint delay_c
|
45 |
|
|
{
|
46 |
|
|
delay dist {0 := 90, [1:2] := 7, [3:7] := 3};
|
47 |
|
|
}
|
48 |
|
|
|
49 |
|
|
// --------------------------------------------------------------------
|
50 |
|
|
function new(string name = "");
|
51 |
|
|
super.new(name);
|
52 |
|
|
endfunction : new
|
53 |
|
|
|
54 |
|
|
// --------------------------------------------------------------------
|
55 |
|
|
function bit do_compare(uvm_object rhs, uvm_comparer comparer);
|
56 |
|
|
fifo_sequence_item tested;
|
57 |
|
|
bit same;
|
58 |
|
|
|
59 |
|
|
if (rhs==null)
|
60 |
|
|
`uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
|
61 |
|
|
|
62 |
|
|
if (!$cast(tested,rhs))
|
63 |
|
|
same = 0;
|
64 |
|
|
else
|
65 |
|
|
same = super.do_compare(rhs, comparer);
|
66 |
|
|
|
67 |
|
|
return same;
|
68 |
|
|
endfunction : do_compare
|
69 |
|
|
|
70 |
|
|
// --------------------------------------------------------------------
|
71 |
|
|
function void do_copy(uvm_object rhs);
|
72 |
|
|
fifo_sequence_item item;
|
73 |
|
|
assert(rhs != null) else
|
74 |
|
|
`uvm_fatal(get_type_name(), "| %m | copy null transaction");
|
75 |
|
|
super.do_copy(rhs);
|
76 |
|
|
assert($cast(item,rhs)) else
|
77 |
|
|
`uvm_fatal(get_type_name(), "| %m | failed cast");
|
78 |
|
|
delay = item.delay;
|
79 |
|
|
command = item.command;
|
80 |
|
|
wr_full = item.wr_full;
|
81 |
|
|
rd_empty = item.rd_empty;
|
82 |
|
|
wr_data = item.wr_data;
|
83 |
|
|
rd_data = item.rd_data;
|
84 |
|
|
count = item.count;
|
85 |
|
|
endfunction : do_copy
|
86 |
|
|
|
87 |
|
|
// --------------------------------------------------------------------
|
88 |
|
|
function string convert2string();
|
89 |
|
|
string s0, s1, s2, s3;
|
90 |
|
|
s0 = $sformatf( "| %m | wr | rd | full | empty |\n");
|
91 |
|
|
s1 = $sformatf( "| %m | %1h | %1h | %1h | %1h |\n"
|
92 |
|
|
, (command == FIFO_WR) || (command == FIFO_BOTH)
|
93 |
|
|
, (command == FIFO_RD) || (command == FIFO_BOTH)
|
94 |
|
|
, wr_full
|
95 |
|
|
, rd_empty
|
96 |
|
|
);
|
97 |
|
|
s2 = $sformatf("| %m | wr_data: %h\n" , wr_data);
|
98 |
|
|
s3 = $sformatf("| %m | rd_data: %h\n" , rd_data);
|
99 |
|
|
|
100 |
|
|
if(command == FIFO_NULL)
|
101 |
|
|
return {s1, s0};
|
102 |
|
|
else if(command == FIFO_BOTH)
|
103 |
|
|
return {s3, s2, s1, s0};
|
104 |
|
|
else if(command == FIFO_WR)
|
105 |
|
|
return {s2, s1, s0};
|
106 |
|
|
else if(command == FIFO_RD)
|
107 |
|
|
return {s3, s1, s0};
|
108 |
|
|
endfunction : convert2string
|
109 |
|
|
|
110 |
|
|
// --------------------------------------------------------------------
|
111 |
|
|
endclass : fifo_sequence_item
|