From 969c91eefafa32700bfc167d27545252778d9b23 Mon Sep 17 00:00:00 2001 From: Guillaume Chauvon <94678394+Gchauvon@users.noreply.github.com> Date: Thu, 11 Jan 2024 11:37:00 +0100 Subject: [PATCH] Check that loaded elf segment does not overlap on last loaded address (#1755) --- corev_apu/tb/ariane_tb.sv | 12 ++++++++++-- verif/tb/uvmt/cva6_tb_wrapper.sv | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/corev_apu/tb/ariane_tb.sv b/corev_apu/tb/ariane_tb.sv index ce85ecdaf9..5808f94351 100644 --- a/corev_apu/tb/ariane_tb.sv +++ b/corev_apu/tb/ariane_tb.sv @@ -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)); @@ -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; @@ -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 diff --git a/verif/tb/uvmt/cva6_tb_wrapper.sv b/verif/tb/uvmt/cva6_tb_wrapper.sv index 8656815831..1241d8b3b6 100644 --- a/verif/tb/uvmt/cva6_tb_wrapper.sv +++ b/verif/tb/uvmt/cva6_tb_wrapper.sv @@ -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)); @@ -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; @@ -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