[dv sw_logger_if] Update to use str_utils_pkg

Signed-off-by: Srikrishna Iyer <sriyer@google.com>
diff --git a/hw/dv/sv/sw_logger_if/sw_logger_if.core b/hw/dv/sv/sw_logger_if/sw_logger_if.core
index d50663b..0ca0359 100644
--- a/hw/dv/sv/sw_logger_if/sw_logger_if.core
+++ b/hw/dv/sv/sw_logger_if/sw_logger_if.core
@@ -9,6 +9,7 @@
   files_dv:
     depend:
       - lowrisc:dv:dv_macros
+      - lowrisc:dv:str_utils
     files:
       - sw_logger_if.sv
     file_type: systemVerilogSource
diff --git a/hw/dv/sv/sw_logger_if/sw_logger_if.sv b/hw/dv/sv/sw_logger_if/sw_logger_if.sv
index 697b44e..9cad8fd 100644
--- a/hw/dv/sv/sw_logger_if/sw_logger_if.sv
+++ b/hw/dv/sv/sw_logger_if/sw_logger_if.sv
@@ -52,6 +52,7 @@
 `ifdef UVM
   import uvm_pkg::*;
 `endif
+  import str_utils_pkg::*;
 
   // macro includes
   `include "dv_macros.svh"
@@ -92,7 +93,7 @@
 
   // struct to hold the complete log data
   typedef struct {
-    string          name;       // Name of the SW image.
+    string          name;         // Name of the SW image.
     log_severity_e  severity;
     log_verbosity_e verbosity;
     string          file;         // Name of the C file invoking the log.
@@ -124,13 +125,22 @@
   event  printed_log_event;
   string printed_log;
 
-  // Set the sw_name, The logger assumes that there are two files placed in the rundir -
-  // <sw_name>_logs.txt: contains logs split as fields of `sw_log_t`
-  // <sw_name>_rodata.txt: contains constants from the read-only sections.
-  function automatic void set_sw_name(string sw_name);
+  // Sets the sw_name with the provided path.
+  //
+  // The sw_name is assumed to be the full path to the SW image (example: /path/to/sometest.elf).
+  // The logger expects two files to be available in the same directory as the image -
+  // <sw_name>.logs.txt: contains logs split as fields of `sw_log_t`
+  // <sw_name>.rodata.txt: contains constants from the read-only sections.
+  // These are generated by `util/device_sw_utils/extract_sw_logs.py`. The meson build system
+  // already generates it for the 'sim_dv' build device.
+  function automatic void set_sw_name(string sw_image);
+    string sw_dir;
+    string sw_basename;
     if (_ready) `DV_FATAL("This function cannot be called after calling ready()")
-    sw_log_db_files[sw_name] = {sw_name, "_logs.txt"};
-    sw_rodata_db_files[sw_name] = {sw_name, "_rodata.txt"};
+    sw_dir = str_utils_pkg::str_path_dirname(sw_image);
+    sw_basename = str_utils_pkg::str_path_basename(.filename(sw_image), .drop_extn(1'b1));
+    sw_log_db_files[sw_basename] = {sw_dir, "/", sw_basename, ".logs.txt"};
+    sw_rodata_db_files[sw_basename] = {sw_dir, "/", sw_basename, ".rodata.txt"};
   endfunction
 
   // signal to indicate that this monitor is good to go - all initializations are done