Skip to content

Commit

Permalink
axi_rand_master: add size input to add_traffic_shaping
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-valente committed Jan 15, 2024
1 parent 0d47468 commit 4ab4bae
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/axi_test.sv
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ package axi_test;

struct packed {
int unsigned len ;
int unsigned size ;
int unsigned cprob;
} traffic_shape[$];
int unsigned max_cprob;
Expand Down Expand Up @@ -812,11 +813,11 @@ package axi_test;
mem_map.delete();
endfunction

function void add_traffic_shaping(input int unsigned len, input int unsigned freq);
function void add_traffic_shaping(input int unsigned len, input int unsigned size, input int unsigned freq);
if (traffic_shape.size() == 0)
traffic_shape.push_back({len, freq});
traffic_shape.push_back({len, size, freq});
else
traffic_shape.push_back({len, traffic_shape[$].cprob + freq});
traffic_shape.push_back({len, size, traffic_shape[$].cprob + freq});

max_cprob = traffic_shape[$].cprob;
endfunction : add_traffic_shaping
Expand Down Expand Up @@ -867,6 +868,7 @@ package axi_test;
for (int i = 0; i < traffic_shape.size(); i++)
if (traffic_shape[i].cprob > cprob) begin
len = traffic_shape[i].len;
size = traffic_shape[i].size;
if (ax_beat.ax_burst == BURST_WRAP) begin
assert (len inside {len_t'(1), len_t'(3), len_t'(7), len_t'(15)});
end
Expand All @@ -875,12 +877,16 @@ package axi_test;

// Randomize address. Make sure that the burst does not cross a 4KiB boundary.
forever begin
rand_success = std::randomize(size) with {
2**size <= AXI_STRB_WIDTH;
2**size <= len;
}; assert(rand_success);
ax_beat.ax_size = size;
ax_beat.ax_len = ((len + (1 << size) - 1) >> size) - 1;
if(size==-1) begin
rand_success = std::randomize(size) with {
2**size <= AXI_STRB_WIDTH;
2**size <= len;
}; assert(rand_success);
ax_beat.ax_size = size;
ax_beat.ax_len = ((len + (1 << size) - 1) >> size) - 1;
end else begin
ax_beat.ax_len = len;
end

rand_success = std::randomize(addr) with {
addr >= mem_region.addr_begin;
Expand Down

0 comments on commit 4ab4bae

Please sign in to comment.