Skip to content

Commit

Permalink
Add random user signal generation for llc-partition test
Browse files Browse the repository at this point in the history
  • Loading branch information
DiyouS authored and micprog committed May 8, 2024
1 parent e60e969 commit 80a215b
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions src/axi_test.sv
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ package axi_test;
// same direction
// Dependent parameters, do not override.
parameter int AXI_STRB_WIDTH = DW/8,
parameter int N_AXI_IDS = 2**IW
parameter int N_AXI_IDS = 2**IW,
parameter int MAXTHREAD = 0 // the number of partitions supported for cache
);
typedef axi_test::axi_driver #(
.AW(AW), .DW(DW), .IW(IW), .UW(UW), .TA(TA), .TT(TT)
Expand Down Expand Up @@ -817,7 +818,23 @@ package axi_test;
max_cprob = traffic_shape[$].cprob;
endfunction : add_traffic_shaping

function ax_beat_t new_rand_burst(input logic is_read);
/// Cache-Partition
// This function is used to generate a random PatID every time send a
// burst of R/W requests down to the cache. Therefore, within one test,
// its PatID will be fixed and we can call multiple tests to test the
// partition functionalities.
function user_t rand_user(input int unsigned MaxThread);
static logic rand_success;
automatic user_t user;
rand_success = std::randomize(user) with {
user >= 0; user <= MaxThread-1;
}; assert(rand_success);
// user = 10;
return user;
endfunction

// Cache-Partition: add user signal as an input
function ax_beat_t new_rand_burst(input logic is_read, input user_t user);
automatic logic rand_success;
automatic ax_beat_t ax_beat = new;
automatic addr_t addr;
Expand Down Expand Up @@ -935,6 +952,7 @@ package axi_test;
// currently done in the functions `create_aws()` and `send_ars()`.
ax_beat.ax_id = id;
ax_beat.ax_qos = qos;
ax_beat.ax_user = user;
return ax_beat;
endfunction

Expand Down Expand Up @@ -1113,11 +1131,12 @@ package axi_test;
cnt_sem.put();
endtask

task send_ars(input int n_reads);
// Cache-Partition: add user signal as an input
task send_ars(input int n_reads, input user_t user);
automatic logic rand_success;
repeat (n_reads) begin
automatic id_t id;
automatic ax_beat_t ar_beat = new_rand_burst(1'b1);
automatic ax_beat_t ar_beat = new_rand_burst(1'b1, user);
while (tot_r_flight_cnt >= MAX_READ_TXNS) begin
rand_wait(1, 1);
end
Expand Down Expand Up @@ -1153,7 +1172,8 @@ package axi_test;
end
endtask

task create_aws(input int n_writes);
// Cache-Partition: add user signal as an input
task create_aws(input int n_writes, input user_t user);
automatic logic rand_success;
repeat (n_writes) begin
automatic bit excl = 1'b0;
Expand All @@ -1162,7 +1182,7 @@ package axi_test;
if (excl) begin
aw_beat = excl_queue.pop_front();
end else begin
aw_beat = new_rand_burst(1'b0);
aw_beat = new_rand_burst(1'b0, user);
if (AXI_ATOPS) rand_atop_burst(aw_beat);
end
while (tot_w_flight_cnt >= MAX_WRITE_TXNS) begin
Expand Down Expand Up @@ -1237,18 +1257,21 @@ package axi_test;
end
endtask

// Cache-Partition: add user signal as an input
// Issue n_reads random read and n_writes random write transactions to an address range.
task run(input int n_reads, input int n_writes);
automatic logic ar_done = 1'b0,
aw_done = 1'b0;
fork
// Cache-Partition: randomize the patid
automatic user_t user = rand_user(MAXTHREAD);
begin
send_ars(n_reads);
send_ars(n_reads, user);
ar_done = 1'b1;
end
recv_rs(ar_done, aw_done);
begin
create_aws(n_writes);
create_aws(n_writes, user);
aw_done = 1'b1;
end
send_aws(aw_done);
Expand Down

0 comments on commit 80a215b

Please sign in to comment.