how to print a value using $display

S

sundar

Guest
hi,
i wanted to print 32'hex value
when i gave
$display( "data = %h", data);
this prints hex value but how to print for 32 size...

thanks in adv,
sundar
 
On Wed, 10 Oct 2007 08:12:55 -0000, sundar <sundar.ece@gmail.com>
wrote:

hi,
i wanted to print 32'hex value
when i gave
$display( "data = %h", data);
this prints hex value but how to print for 32 size...
do you mean in binary? Your question isn't clear - you need to give an
example of the output you're getting, and the output you want to get.

There's no way to specify the required output field size. "%h" will
give you 8 characters for a 32-bit number; "%b" will give you 32
characters for a 32-bit number. "%0h" and "%0b" will suppress leading
zeros, giving a more compact output.

Evan
 
On Oct 10, 4:12 am, sundar <sundar....@gmail.com> wrote:
hi,
i wanted to print 32'hex value
when i gave
$display( "data = %h", data);
this prints hex value but how to print for 32 size...
Assign it to a variable that is 32 bits wide and print that instead?
 
output [31:0] data;
.....
data <= 8'h0000ffff

$display( "data = %h", data);

data <= 2'b11

$display( "data = %h", data);
......

my expected display output is

data = 0000ffff
data = 00000003

means i want to print total of 8 bit positions in hex format
 
On Thu, 11 Oct 2007 08:15:04 -0000, sundar <sundar.ece@gmail.com>
wrote:

output [31:0] data;
....
data <= 8'h0000ffff
don't you get a warning when you compile this? You've got 32 bits, so
it should be 32'h0000ffff.

$display( "data = %h", data);

data <= 2'b11

$display( "data = %h", data);
.....

my expected display output is

data = 0000ffff
data = 00000003

means i want to print total of 8 bit positions in hex format
That's 32 bit positions, not 8. You don't say what you're actually
getting. If you're getting 'xxxxxxxx' and 'xxxxxxxx', that's because
you're using '<=' and 'data' hasn't been written to before you call
$display. If you're getting '000000ff' and '00000003', that's because
of your "8'h0000ffff".

Evan
 
hi!

i hope that u all r fne.Can any one has a good project(semester
project) idea in verilog .or any other helping material to do my
project for this semester.

arsi
 

Welcome to EDABoard.com

Sponsor

Back
Top