From b08e82534789ab710db4f2bb6b66096dbca361b1 Mon Sep 17 00:00:00 2001 From: Diyou Shen Date: Thu, 15 Jun 2023 11:07:31 +0200 Subject: [PATCH] Add random user signal generation for llc-partition test --- src/axi_test.sv | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/axi_test.sv b/src/axi_test.sv index 6fd789415..63ec1239b 100644 --- a/src/axi_test.sv +++ b/src/axi_test.sv @@ -711,7 +711,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) @@ -816,7 +817,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; @@ -934,6 +951,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 @@ -1112,11 +1130,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 @@ -1152,7 +1171,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; @@ -1161,7 +1181,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 @@ -1236,18 +1256,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);