@@ -712,7 +712,8 @@ package axi_test;
712
712
// same direction
713
713
// Dependent parameters, do not override.
714
714
parameter int AXI_STRB_WIDTH = DW / 8 ,
715
- parameter int N_AXI_IDS = 2 ** IW
715
+ parameter int N_AXI_IDS = 2 ** IW ,
716
+ parameter int MAXTHREAD = 0 // the number of partitions supported for cache
716
717
);
717
718
typedef axi_test :: axi_driver # (
718
719
.AW (AW ), .DW (DW ), .IW (IW ), .UW (UW ), .TA (TA ), .TT (TT )
@@ -832,7 +833,23 @@ package axi_test;
832
833
max_cprob = traffic_shape[$].cprob;
833
834
endfunction : add_traffic_shaping_with_size
834
835
835
- function ax_beat_t new_rand_burst (input logic is_read);
836
+ // / Cache-Partition
837
+ // This function is used to generate a random PatID every time send a
838
+ // burst of R/W requests down to the cache. Therefore, within one test,
839
+ // its PatID will be fixed and we can call multiple tests to test the
840
+ // partition functionalities.
841
+ function user_t rand_user (input int unsigned MaxThread);
842
+ static logic rand_success;
843
+ automatic user_t user;
844
+ rand_success = std:: randomize (user) with {
845
+ user >= 0 ; user <= MaxThread- 1 ;
846
+ } ; assert (rand_success);
847
+ // user = 10;
848
+ return user;
849
+ endfunction
850
+
851
+ // Cache-Partition: add user signal as an input
852
+ function ax_beat_t new_rand_burst (input logic is_read, input user_t user);
836
853
automatic logic rand_success;
837
854
automatic ax_beat_t ax_beat = new ;
838
855
automatic addr_t addr;
@@ -946,6 +963,7 @@ package axi_test;
946
963
// currently done in the functions `create_aws()` and `send_ars()`.
947
964
ax_beat.ax_id = id;
948
965
ax_beat.ax_qos = qos;
966
+ ax_beat.ax_user = user;
949
967
return ax_beat;
950
968
endfunction
951
969
@@ -1142,11 +1160,12 @@ package axi_test;
1142
1160
cnt_sem.put ();
1143
1161
endtask
1144
1162
1145
- task send_ars (input int n_reads);
1163
+ // Cache-Partition: add user signal as an input
1164
+ task send_ars (input int n_reads, input user_t user);
1146
1165
automatic logic rand_success;
1147
1166
repeat (n_reads) begin
1148
1167
automatic id_t id;
1149
- automatic ax_beat_t ar_beat = new_rand_burst (1'b1 );
1168
+ automatic ax_beat_t ar_beat = new_rand_burst (1'b1 , user );
1150
1169
while (tot_r_flight_cnt >= MAX_READ_TXNS ) begin
1151
1170
rand_wait (1 , 1 );
1152
1171
end
@@ -1184,7 +1203,8 @@ package axi_test;
1184
1203
end
1185
1204
endtask
1186
1205
1187
- task create_aws (input int n_writes);
1206
+ // Cache-Partition: add user signal as an input
1207
+ task create_aws (input int n_writes, input user_t user);
1188
1208
automatic logic rand_success;
1189
1209
repeat (n_writes) begin
1190
1210
automatic bit excl = 1'b0 ;
@@ -1193,7 +1213,7 @@ package axi_test;
1193
1213
if (excl) begin
1194
1214
aw_beat = excl_queue.pop_front ();
1195
1215
end else begin
1196
- aw_beat = new_rand_burst (1'b0 );
1216
+ aw_beat = new_rand_burst (1'b0 , user );
1197
1217
if (AXI_ATOPS ) rand_atop_burst (aw_beat);
1198
1218
end
1199
1219
while (tot_w_flight_cnt >= MAX_WRITE_TXNS ) begin
@@ -1268,18 +1288,21 @@ package axi_test;
1268
1288
end
1269
1289
endtask
1270
1290
1291
+ // Cache-Partition: add user signal as an input
1271
1292
// Issue n_reads random read and n_writes random write transactions to an address range.
1272
1293
task run (input int n_reads, input int n_writes);
1273
1294
automatic logic ar_done = 1'b0 ,
1274
1295
aw_done = 1'b0 ;
1275
1296
fork
1297
+ // Cache-Partition: randomize the patid
1298
+ automatic user_t user = rand_user (MAXTHREAD );
1276
1299
begin
1277
- send_ars (n_reads);
1300
+ send_ars (n_reads, user );
1278
1301
ar_done = 1'b1 ;
1279
1302
end
1280
1303
recv_rs (ar_done, aw_done);
1281
1304
begin
1282
- create_aws (n_writes);
1305
+ create_aws (n_writes, user );
1283
1306
aw_done = 1'b1 ;
1284
1307
end
1285
1308
send_aws (aw_done);
0 commit comments