How can i display hex content

Status
Not open for further replies.

mssajwan

Full Member level 1
Joined
May 19, 2006
Messages
95
Helped
12
Reputation
24
Reaction score
2
Trophy points
1,288
Location
Banaglore
Activity points
1,798
Hello,

I have a register

reg [31:0] test;
test=32'h12345678;
now when i display its content like
$display("Test=%0d",test);

what i get is Test =12345678;

But what i want it to print is Test =1234_5678

How can i accomplish this. any thoughts



-Manmohan
 

You shouldn't get Test=12345678 with that decimal format specifier.

I haven't seen any way to automatically insert underscore separators.
Try this:
$display("Test=%x_%x", test[31:16], test[15:0]);
 

    mssajwan

    Points: 2
    Helpful Answer Positive Rating
Hi I am sorry for the mistake.
yeah thats %0h.
the solution u have provided sounds good.
but actually when i have a queue like
bit [31:0] Q[16];
printing all the content will be to complex.
This is what i want,all the contents of this Q in hex format with underscore.
Any how thanks a lot for ur suggestion.
I try to figure out something.

-Manmohan
 

SystemVerilog, I see!

How about a "for" loop?
Code:
integer n;
...
for (n=0; n<16; n=n+1)
  $display("Q[%0d]=%x_%x", n, Q[n][31:16], Q[n][15:0]);
 


In SV, try using a foreach loop - you don't need to worry about the index length then!

However I don't believe you will get the "_" as you wished - perhaps you are used to Specman/E? That's a wonderful verification tool. Nothing can match that usability really.


Ajeetha, CVC
www.noveldv.com
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…