diff --git a/src/axi_test.sv b/src/axi_test.sv index c9fca2697..a075185e5 100644 --- a/src/axi_test.sv +++ b/src/axi_test.sv @@ -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) @@ -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; @@ -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 @@ -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 @@ -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; @@ -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 @@ -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);