Skip to content

Commit fc498c3

Browse files
committed
Add random user signal generation for llc-partition test
1 parent 39f5f2d commit fc498c3

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/axi_test.sv

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,8 @@ package axi_test;
712712
// same direction
713713
// Dependent parameters, do not override.
714714
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
716717
);
717718
typedef axi_test::axi_driver #(
718719
.AW(AW), .DW(DW), .IW(IW), .UW(UW), .TA(TA), .TT(TT)
@@ -832,7 +833,23 @@ package axi_test;
832833
max_cprob = traffic_shape[$].cprob;
833834
endfunction : add_traffic_shaping_with_size
834835

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);
836853
automatic logic rand_success;
837854
automatic ax_beat_t ax_beat = new;
838855
automatic addr_t addr;
@@ -946,6 +963,7 @@ package axi_test;
946963
// currently done in the functions `create_aws()` and `send_ars()`.
947964
ax_beat.ax_id = id;
948965
ax_beat.ax_qos = qos;
966+
ax_beat.ax_user = user;
949967
return ax_beat;
950968
endfunction
951969

@@ -1142,11 +1160,12 @@ package axi_test;
11421160
cnt_sem.put();
11431161
endtask
11441162

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);
11461165
automatic logic rand_success;
11471166
repeat (n_reads) begin
11481167
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);
11501169
while (tot_r_flight_cnt >= MAX_READ_TXNS) begin
11511170
rand_wait(1, 1);
11521171
end
@@ -1184,7 +1203,8 @@ package axi_test;
11841203
end
11851204
endtask
11861205

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);
11881208
automatic logic rand_success;
11891209
repeat (n_writes) begin
11901210
automatic bit excl = 1'b0;
@@ -1193,7 +1213,7 @@ package axi_test;
11931213
if (excl) begin
11941214
aw_beat = excl_queue.pop_front();
11951215
end else begin
1196-
aw_beat = new_rand_burst(1'b0);
1216+
aw_beat = new_rand_burst(1'b0, user);
11971217
if (AXI_ATOPS) rand_atop_burst(aw_beat);
11981218
end
11991219
while (tot_w_flight_cnt >= MAX_WRITE_TXNS) begin
@@ -1268,18 +1288,21 @@ package axi_test;
12681288
end
12691289
endtask
12701290

1291+
// Cache-Partition: add user signal as an input
12711292
// Issue n_reads random read and n_writes random write transactions to an address range.
12721293
task run(input int n_reads, input int n_writes);
12731294
automatic logic ar_done = 1'b0,
12741295
aw_done = 1'b0;
12751296
fork
1297+
// Cache-Partition: randomize the patid
1298+
automatic user_t user = rand_user(MAXTHREAD);
12761299
begin
1277-
send_ars(n_reads);
1300+
send_ars(n_reads, user);
12781301
ar_done = 1'b1;
12791302
end
12801303
recv_rs(ar_done, aw_done);
12811304
begin
1282-
create_aws(n_writes);
1305+
create_aws(n_writes, user);
12831306
aw_done = 1'b1;
12841307
end
12851308
send_aws(aw_done);

0 commit comments

Comments
 (0)