1 |
2 |
des00 |
//
|
2 |
|
|
// Project : High-Speed SDRAM Controller with adaptive bank management and command pipeline
|
3 |
|
|
//
|
4 |
|
|
// Project Nick : HSSDRC
|
5 |
|
|
//
|
6 |
|
|
// Version : 1.0-beta
|
7 |
|
|
//
|
8 |
|
|
// Revision : $Revision: 1.1 $
|
9 |
|
|
//
|
10 |
|
|
// Date : $Date: 2008-03-06 13:54:00 $
|
11 |
|
|
//
|
12 |
|
|
// Workfile : sdram_transaction_class.sv
|
13 |
|
|
//
|
14 |
|
|
// Description : sdram transaction structure
|
15 |
|
|
//
|
16 |
|
|
// HSSDRC is licensed under MIT License
|
17 |
|
|
//
|
18 |
|
|
// Copyright (c) 2007-2008, Denis V.Shekhalev (des00@opencores.org)
|
19 |
|
|
//
|
20 |
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
21 |
|
|
// this software and associated documentation files (the "Software"), to deal in
|
22 |
|
|
// the Software without restriction, including without limitation the rights to
|
23 |
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
24 |
|
|
// the Software, and to permit persons to whom the Software is furnished to do so,
|
25 |
|
|
// subject to the following conditions:
|
26 |
|
|
//
|
27 |
|
|
// The above copyright notice and this permission notice shall be included in all
|
28 |
|
|
// copies or substantial portions of the Software.
|
29 |
|
|
//
|
30 |
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
31 |
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
32 |
|
|
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
33 |
|
|
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
34 |
|
|
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
35 |
|
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
36 |
|
|
//
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
`include "hssdrc_define.vh"
|
41 |
|
|
`include "tb_define.svh"
|
42 |
|
|
|
43 |
|
|
`ifndef __SDRAM_TRANSACTION_CLASS_SV__
|
44 |
|
|
|
45 |
|
|
`define __SDRAM_TRANSACTION_CLASS_SV__
|
46 |
|
|
|
47 |
|
|
class sdram_transaction_class;
|
48 |
|
|
|
49 |
|
|
// transaction id
|
50 |
|
|
int id;
|
51 |
|
|
// transacton type for driver
|
52 |
|
|
tr_type_e_t tr_type ;
|
53 |
|
|
// input sdram path
|
54 |
|
|
rand tb_ba_t ba ;
|
55 |
|
|
rand tb_rowa_t rowa ;
|
56 |
|
|
rand tb_cola_t cola ;
|
57 |
|
|
rand tb_burst_t burst ;
|
58 |
|
|
rand tb_chid_t chid ;
|
59 |
|
|
// input data path
|
60 |
|
|
rand tb_data_t wdata [0:cBurstMaxValue-1];
|
61 |
|
|
tb_datam_t wdatam [0:cBurstMaxValue-1];
|
62 |
|
|
// output data path
|
63 |
|
|
tb_data_t rdata [0:cBurstMaxValue-1];
|
64 |
|
|
tb_chid_t rchid [0:cBurstMaxValue-1];
|
65 |
|
|
|
66 |
|
|
// random generate controls
|
67 |
|
|
int burst_random_mode = 0;
|
68 |
|
|
int address_random_mode = 0;
|
69 |
|
|
// used in random generate variables
|
70 |
|
|
tb_ba_t last_used_ba;
|
71 |
|
|
tb_rowa_t last_used_rowa;
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
function new (int id = 0, tr_type_e_t tr_type = cTR_WRITE, int ba = 0, rowa = 0, cola = 0, burst = 1, chid = 0);
|
75 |
|
|
|
76 |
|
|
this.id = id;
|
77 |
|
|
this.tr_type = tr_type;
|
78 |
|
|
this.ba = ba;
|
79 |
|
|
this.rowa = rowa;
|
80 |
|
|
this.cola = cola;
|
81 |
|
|
this.burst = burst - 1;
|
82 |
|
|
this.chid = chid;
|
83 |
|
|
|
84 |
|
|
endfunction
|
85 |
|
|
|
86 |
|
|
//
|
87 |
|
|
// function to generate linear data packet
|
88 |
|
|
//
|
89 |
|
|
|
90 |
|
|
function void GetLinearPacket;
|
91 |
|
|
data_t tmp_data;
|
92 |
|
|
begin
|
93 |
|
|
|
94 |
|
|
tmp_data = {ba, rowa, this.cola};
|
95 |
|
|
|
96 |
|
|
for (int i = 0; i <= burst; i++)
|
97 |
|
|
wdata [i] = tmp_data + i + 1;
|
98 |
|
|
|
99 |
|
|
wdatam = '{default : 0};
|
100 |
|
|
end
|
101 |
|
|
endfunction
|
102 |
|
|
|
103 |
|
|
//
|
104 |
|
|
//
|
105 |
|
|
//
|
106 |
|
|
|
107 |
|
|
function void GetRandomPacket;
|
108 |
|
|
data_t tmp_data;
|
109 |
|
|
begin
|
110 |
|
|
|
111 |
|
|
assert ( std::randomize(wdata)) else $error ("random packet generate");
|
112 |
|
|
|
113 |
|
|
wdatam = '{default : 0};
|
114 |
|
|
|
115 |
|
|
end
|
116 |
|
|
endfunction
|
117 |
|
|
|
118 |
|
|
//
|
119 |
|
|
// randomize callback function to store transaction addres's
|
120 |
|
|
//
|
121 |
|
|
function void post_randomize();
|
122 |
|
|
last_used_ba = ba;
|
123 |
|
|
last_used_rowa = rowa;
|
124 |
|
|
endfunction
|
125 |
|
|
|
126 |
|
|
//
|
127 |
|
|
// constraint for use for performance measuring
|
128 |
|
|
//
|
129 |
|
|
|
130 |
|
|
// burst constraint
|
131 |
|
|
|
132 |
|
|
// mode 0 : any birst, no cola allign
|
133 |
|
|
|
134 |
|
|
// mode 1 : fixed burst = 1, cola allign
|
135 |
|
|
constraint burst_constraint_1 { (burst_random_mode == 1) -> burst == 0; }
|
136 |
|
|
// mode 2 : fixed burst = 2, cola allign
|
137 |
|
|
constraint burst_constraint_2 { (burst_random_mode == 2) -> burst == 1; }
|
138 |
|
|
// mode 3 : fixed burst = 4, cola allign
|
139 |
|
|
constraint burst_constraint_3 { (burst_random_mode == 3) -> burst == 3; }
|
140 |
|
|
// mode 4 : fixed burst == 8, cola allign
|
141 |
|
|
constraint burst_constraint_4 { (burst_random_mode == 4) -> burst == 7; }
|
142 |
|
|
// mode 5 : fixed burst == 16, cola allign
|
143 |
|
|
constraint burst_constraint_5 { (burst_random_mode == 5) -> burst == 15; }
|
144 |
|
|
// mode 6 : max performance burst, cola allign
|
145 |
|
|
constraint burst_constraint_6 { (burst_random_mode == 6) -> burst inside {0, 1, 3, 7, 15}; }
|
146 |
|
|
|
147 |
|
|
// cola constraint
|
148 |
|
|
constraint cola_constraint { (burst_random_mode != 0) ->
|
149 |
|
|
(burst == 1) -> (cola[0] == 0);
|
150 |
|
|
(burst == 3) -> (cola[1:0] == 0);
|
151 |
|
|
(burst == 7) -> (cola[2:0] == 0);
|
152 |
|
|
(burst == 15) -> (cola[3:0] == 0);
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
constraint burst_order {solve burst before cola; }
|
156 |
|
|
|
157 |
|
|
// address constraint
|
158 |
|
|
|
159 |
|
|
// mode 0 : same bank same row
|
160 |
|
|
constraint address_constraint_0 { (address_random_mode == 0) -> {
|
161 |
|
|
(ba == last_used_ba);
|
162 |
|
|
(rowa == last_used_rowa);
|
163 |
|
|
}
|
164 |
|
|
}
|
165 |
|
|
// mode 1 : same bank
|
166 |
|
|
constraint address_constraint_1 { (address_random_mode == 1) -> {
|
167 |
|
|
(ba == last_used_ba);
|
168 |
|
|
(rowa != last_used_rowa);
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
// mode 2 : any bank same row
|
172 |
|
|
constraint address_constraint_2 { (address_random_mode == 2) -> {
|
173 |
|
|
(ba != last_used_ba);
|
174 |
|
|
(rowa == last_used_rowa);
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
// mode 3 : linear bank same row
|
178 |
|
|
constraint address_constraint_3 { (address_random_mode == 3) -> {
|
179 |
|
|
(last_used_ba == 0) -> (ba == 1);
|
180 |
|
|
(last_used_ba == 1) -> (ba == 2);
|
181 |
|
|
(last_used_ba == 2) -> (ba == 3);
|
182 |
|
|
(last_used_ba == 3) -> (ba == 0);
|
183 |
|
|
(rowa == last_used_rowa);
|
184 |
|
|
}
|
185 |
|
|
}
|
186 |
|
|
// mode 4 : any bank any row
|
187 |
|
|
constraint address_constraint_4 { (address_random_mode == 4) -> {
|
188 |
|
|
(ba != last_used_ba);
|
189 |
|
|
(rowa != last_used_rowa);
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
|
|
// mode 5 : linear bank any row
|
193 |
|
|
constraint address_constraint_5 { (address_random_mode == 5) -> {
|
194 |
|
|
(last_used_ba == 0) -> (ba == 1);
|
195 |
|
|
(last_used_ba == 1) -> (ba == 2);
|
196 |
|
|
(last_used_ba == 2) -> (ba == 3);
|
197 |
|
|
(last_used_ba == 3) -> (ba == 0);
|
198 |
|
|
(rowa != last_used_rowa);
|
199 |
|
|
}
|
200 |
|
|
}
|
201 |
|
|
// mode 6 : ba varies more often than rowa
|
202 |
|
|
constraint address_constraint_6 { (address_random_mode == 6) -> {
|
203 |
|
|
ba dist { (ba == last_used_ba) := 1, (ba != last_used_ba) :/5}; // 1/6 const ba
|
204 |
|
|
rowa dist { (rowa == last_used_rowa) := 5, (rowa != last_used_rowa) :/1}; // 5/6 const rowa
|
205 |
|
|
}
|
206 |
|
|
}
|
207 |
|
|
// mode 7 : ba varies less often than rowa
|
208 |
|
|
constraint address_constraint_7 { (address_random_mode == 7) -> {
|
209 |
|
|
ba dist { (ba == last_used_ba) := 3, (ba != last_used_ba) :/1}; // 75% const ba
|
210 |
|
|
rowa dist { (rowa == last_used_rowa) := 1, (rowa != last_used_rowa) :/3}; // 25% const rowa
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
endclass
|
215 |
|
|
//
|
216 |
|
|
// mailbox for connet agent with driver
|
217 |
|
|
//
|
218 |
|
|
typedef mailbox #(sdram_transaction_class) sdram_tr_mbx;
|
219 |
|
|
|
220 |
|
|
`endif
|