Jump to content
karlzhao

How can I print out Logs left-aligned?

Recommended Posts

Hi Guys,

I want to print out some info in the log file as bellow:

TEST0001: seed = 12                Out_Str: Hello_test                  Out_Num: 64

TEST0002: seed = 12345678    Out_Str: Hello_Public_test     Out_Num: 1024

 

I have do this as follows:

$fdisplay("TEST%04d: seed = %d    Out_str: %s    Out_Num: %d", index, seed, out_str, out_num);

 

But I can not got the format which I wanted.

 

Can you tell me how can I do this?

 

Thanks a lot!

Share this post


Link to post
Share on other sites

try this.  the '-' means left aligned.  choose a size larger than your max, for each field, as in my example.

class Packet;
  int  seed[]='{54445,745,11209};
  string out_str[]='{"imabigstring","tiny","medium"};
  int out_num[]='{88,353,1};

  function display ();
    foreach (out_num)
      $display("TEST%04d: seed=%-8d Out_str: %-16s Out_Num: %-8d", i, seed, out_str, out_num);
  endfunction
endclass 

https://www.edaplayground.com/x/2_vR

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×