Skip to content

Commit

Permalink
test(dma): Support specifying an injection ratio of the DMA model
Browse files Browse the repository at this point in the history
  • Loading branch information
fischeti committed Nov 21, 2024
1 parent 6495c42 commit 44a31d9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ VCS_ARGS += -j 8
ifdef JOB_NAME
VSIM_FLAGS += +JOB_NAME=$(JOB_NAME)
endif
ifdef TRAFFIC_INJ_RATIO
VSIM_FLAGS += +TRAFFIC_INJ_RATIO=$(TRAFFIC_INJ_RATIO)
endif
ifdef JOB_DIR
VSIM_FLAGS += +JOB_DIR=$(JOB_DIR)
endif
Expand Down
63 changes: 40 additions & 23 deletions hw/test/floo_dma_test_node.sv
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ module floo_dma_test_node #(
`include "tb_tasks.svh"

//--------------------------------------
// Read Job queue from File
//--------------------------------------
// Read Job queue from File
//--------------------------------------
initial begin
string job_file, job_name, job_dir;
if ($value$plusargs ("JOB_NAME=%s", job_name)) begin
Expand Down Expand Up @@ -374,6 +374,7 @@ module floo_dma_test_node #(
axi_pkg::resp_t cause;
addr_t burst_addr;
int err_idx [$];
real injection_ratio;

initial begin
// reset driver
Expand All @@ -382,35 +383,51 @@ module floo_dma_test_node #(
wait (rst_ni);
// print a job summary
print_summary(req_jobs);
// wait some additional time
if (!$value$plusargs("TRAFFIC_INJ_RATIO=%f", injection_ratio)) begin
injection_ratio = 1.0;
$display("[DMA%0d] Using default injection ratio of 1.0", JobId + 1);
end else begin
$display("[DMA%0d] Using injection ratio of %f", JobId + 1, injection_ratio);
end

// wait some additional time
#2ns;

// run all requests in queue
while (req_jobs.size() != 0) begin
// pop front to get a job
automatic tb_dma_job_t now = req_jobs.pop_front();
// print job to terminal
if (EnableDebug) $display("[DMA%0d]%s", JobId, now.pprint());
// launch DUT
drv.launch_tf(
now.length,
now.src_addr,
now.dst_addr,
now.src_protocol,
now.dst_protocol,
now.aw_decoupled,
now.rw_decoupled,
$clog2(now.max_src_len),
$clog2(now.max_dst_len),
now.max_src_len != 'd256,
now.max_dst_len != 'd256,
now.id
);
automatic tb_dma_job_t now;
// Inject delay based on injection ratio
// Compute whether to inject in the next cycle based on the injection ratio
if (!($urandom_range(0, 100) < (injection_ratio * 100))) begin
// Wait for the next cycle
if (EnableDebug && (JobId == 100)) $display("[DMA%0d] Delay", JobId + 1);
@(posedge clk_i);
continue;
end
// pop front to get a job
now = req_jobs.pop_front();
// print job to terminal
if (EnableDebug) $display("[DMA%0d]%s", JobId, now.pprint());
// launch DUT
drv.launch_tf(
now.length,
now.src_addr,
now.dst_addr,
now.src_protocol,
now.dst_protocol,
now.aw_decoupled,
now.rw_decoupled,
$clog2(now.max_src_len),
$clog2(now.max_dst_len),
now.max_src_len != 'd256,
now.max_dst_len != 'd256,
now.id
);
end
// once done: launched all transfers
$display("[DMA%0d] Launched all Transfers.", JobId + 1);

end
end

initial begin
end_of_sim_o = 1'b0;
Expand Down

0 comments on commit 44a31d9

Please sign in to comment.