Jump to content

A way of shortening uvm_info filename to ONLY filename, not path/filename?


Recommended Posts

Hi all!

 

I've been trying to completely do without the full path of filename when reporting

 

for example

 

instead of

 

UVM_INFO /1/2/3/4/5/6/7/8/filename.sv (linenum) "Message"

 

I want completely remove or shorten the path

 

UVM_INFO /.../filename.sv (linenum)  "Message"

 

I've tried using


UVM_REPORT_DISABLE_FILE_LINE
UVM_REPORT_DISABLE_FILE

 

But it completely removes the filename and line num from the report.

 

I'm looking into the uvm source code and make my own modifications, but I don't want to mess around with the libraries since I share the installation directories.

 

Anybody has done this before?

 

Thank you!

 

Link to comment
Share on other sites

As per LRM the `__FILE__ expands to the filename as provided to the compiler. So in your compile script if you provide absolute path, you will get /abs/path/to/file, else ../relative_path:

 

For instance try the below code:

 

 

module m; 
  initial begin
    $display ("File: %0s Line: %0d",
              `__FILE__, `__LINE__);
  end
endmodule : m

 

qverilog  C:/tools/cygwin/home/Ajeetha/proj/svlog/FILE_macro_rel_path/FILE_macro_rel_path.sv

 

vs.

 

qverilog ../FILE_macro_rel_path.sv

 

See what happens

 

HTH

Ajeetha, CVC

www.cvcblr.com/blog

 
Link to comment
Share on other sites

  • 2 weeks later...

hi,

Personally, I dont see why you need the line/filename at all. if you are debugging somethign then bring it up in your gui and double click the message and it will take you to the `uvm_info line being called in your code.

Therefore, I compile with the disable FILE_LINE option.

 

However, some people like to see tonnes of messages appear in their logifles and for those they should review Brians' blog:

http://www.vmmcentral.org/vmartialarts/2012/04/customizing-uvm-messages-without-getting-a-sunburn/

 

Link to comment
Share on other sites

  • 6 months later...
As rustagi said, you can extend the uvm_report_server and have your own compose_message function. Here's what I do to have a filename without path and to customize other parts of the message too.
 

 

class custom_report_server extends uvm_report_server;

   virtual function string compose_message
     ( uvm_severity severity,
       string name,
       string id,
       string message,
       string filename,
       int line );

      // Declare function-internal vars
      string filename_nopath = "";
      uvm_severity_type severity_type = uvm_severity_type'( severity );    

      begin

         // Extract just the file name, remove the preceeding path
         foreach(filename[i])
           begin
              if (filename[i]=="/") filename_nopath = "";
              else                  filename_nopath = {filename_nopath,
                                                       filename[i]};
           end

         // number of initial spaces in the second line
         // = 8 + 1(space) + 1(@) + 7 + 2("ns") + 3(spaces) + 2(indentation) = 24
         return $psprintf( "%-8s @%7tns%3s\"%s\" >%s(%0d)\n%24s%s [%s]",             
                           severity_type.name(), $time/1000.00, " ",
                           name, filename_nopath, line, 
                           " ", message, id );   
      end
   endfunction: compose_message
endclass: custom_report_server
 
I would then put this in the base test. It is up to you where you want the new server to be effective: before build, before run, etc.
 
virtual function void build_phase(uvm_phase phase);
      // Set the custom report server to output the uvm_info messages in custom format
      custom_report_server my_server = new;      
      uvm_report_server::set_server( my_server );
      super.build_phase(phase);
      ......
endfunction 
Link to comment
Share on other sites

  • 2 years later...

Based on other replies I have done the following:

class custom_report_server extends uvm_report_server;

   function new(string name="my_report_server");
      super.new();
   endfunction : new

   function string getShortFileName(string s);
      int offset = 0;
      int lastChar;
      string shortFileName;
      int slashPosition;
      
      lastChar = s.len()-1;
      for (int i = lastChar; i >= offset; i=i-1) begin
        if (s.getc(i) inside {"/", "\\"}) begin
          slashPosition = i;
          break;
        end
      end // for loop
          
       shortFileName = s.substr(slashPosition+1, lastChar);
       return shortFileName;
    endfunction

   virtual function string compose_message(
                                           uvm_severity severity,
                                           string name,
                                           string id,
                                           string message,
                                           string filename,
                                           int    line
                                           );
      uvm_severity_type sv;
      string                                      time_str;
      string                                      line_str;
      
      sv = uvm_severity_type'(severity);
      $swrite(time_str, "%0t", $realtime);
      
      case(1)
        (name == "" && filename == ""):
               return {sv.name(), " @ ", time_str, " [", id, "] ", message};
        (name != "" && filename == ""):
               return {sv.name(), " @ ", time_str, ": ", name, " [", id, "] ", message};
        (name == "" && filename != ""):
                 begin
                    $swrite(line_str, "%0d", line);
                    return {sv.name(), " ",getShortFileName(filename), "(", line_str, ")", " @ ", time_str, " [", id, "] ", message};
                 end
        (name != "" && filename != ""):
                 begin
                    $swrite(line_str, "%0d", line);
                    return {sv.name(), " ", getShortFileName(filename), "(", line_str, ")", " @ ", time_str, ": ", name, " [", id, "] ", message};
                 end
      endcase
   endfunction 
endclass: custom_report_server

and in the build_phase of the test

virtual function void build_phase(uvm_phase phase);
      // Set the custom report server to output the uvm_info messages in custom format
      custom_report_server my_server = new;      
      uvm_report_server::set_server( my_server );
      
      super.build_phase(phase);
...

endfunction
Link to comment
Share on other sites

 

Based on other replies I have done the following:

class custom_report_server extends uvm_report_server;
...
endclass: custom_report_server

and in the build_phase of the test

virtual function void build_phase(uvm_phase phase);
...
endfunction

How do you inherit a abstract class (uvm_report_server) with a lot of 'pure virtual' methods overriding only a single 'compose_message' method?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...