Skip to content

Commit

Permalink
Check that loaded elf segment does not overlap on last loaded address (
Browse files Browse the repository at this point in the history
  • Loading branch information
Gchauvon authored and rohan-10xe committed Jan 23, 2024
1 parent 9f4ca39 commit 5a04318
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions corev_apu/tb/ariane_tb.sv
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module ariane_tb;
// Note that we are loosing the capabilities to use risc-fesvr though
initial begin
automatic logic [7:0][7:0] mem_row;
longint address, len;
longint address, load_address, last_load_address, len;
byte buffer[];
void'(uvcl.get_arg_value("+elf_file=", binary));

Expand All @@ -147,6 +147,7 @@ module ariane_tb;
// wait with preloading, otherwise randomization will overwrite the existing value
wait(clk_i);

last_load_address = 'hFFFFFFFF;
// while there are more sections to process
while (get_section(address, len)) begin
automatic int num_words = (len+7)/8;
Expand All @@ -160,7 +161,14 @@ module ariane_tb;
for (int j = 0; j < 8; j++) begin
mem_row[j] = buffer[i*8 + j];
end
`MAIN_MEM((address[23:0] >> 3) + i) = mem_row;
load_address = (address[23:0] >> 3) + i;
if (load_address != last_load_address) begin
`MAIN_MEM(load_address) = mem_row;
last_load_address = load_address;
end else begin
`uvm_info( "Debug info", $sformatf(" Address: %x Already Loaded! ELF file might have less than 64 bits granularity on segments.", load_address), UVM_LOW)
end

end
end
end
Expand Down
11 changes: 9 additions & 2 deletions verif/tb/uvmt/cva6_tb_wrapper.sv
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ module cva6_tb_wrapper import uvmt_cva6_pkg::*; #(
);
if(!axi_switch_vif.active) begin
automatic logic [7:0][7:0] mem_row;
longint address;
longint address, load_address, last_load_address;
longint len;
byte buffer[];
void'(uvcl.get_arg_value("+elf_file=", binary));
Expand All @@ -251,6 +251,7 @@ module cva6_tb_wrapper import uvmt_cva6_pkg::*; #(
void'(read_elf(binary));
wait(clk_i);

last_load_address = 'hFFFFFFFF;
// while there are more sections to process
while (get_section(address, len)) begin
automatic int num_words0 = (len+7)/8;
Expand All @@ -264,7 +265,13 @@ module cva6_tb_wrapper import uvmt_cva6_pkg::*; #(
for (int j = 0; j < 8; j++) begin
mem_row[j] = buffer[i*8 + j];
end
`MAIN_MEM((address[23:0] >> 3) + i) = mem_row;
load_address = (address[23:0] >> 3) + i;
if (load_address != last_load_address) begin
`MAIN_MEM(load_address) = mem_row;
last_load_address = load_address;
end else begin
`uvm_info( "Debug info", $sformatf(" Address: %x Already Loaded! ELF file might have less than 64 bits granularity on segments.", load_address), UVM_LOW)
end
end
end
end
Expand Down

0 comments on commit 5a04318

Please sign in to comment.