FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > Verilog

Verilog comp.lang.verilog newsgroup / usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-10-2007, 10:12 AM
sundar
Guest
 
Posts: n/a
Default how to print a value using $display

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

Reply With Quote
  #2 (permalink)  
Old 10-10-2007, 11:14 AM
Evan Lavelle
Guest
 
Posts: n/a
Default Re: how to print a value using $display

On Wed, 10 Oct 2007 08:12:55 -0000, sundar <[email protected]>
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
Reply With Quote
  #3 (permalink)  
Old 10-10-2007, 06:52 PM
Guest
 
Posts: n/a
Default Re: how to print a value using $display

On Oct 10, 4:12 am, sundar <[email protected]> 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?

Reply With Quote
  #4 (permalink)  
Old 10-11-2007, 10:15 AM
sundar
Guest
 
Posts: n/a
Default Re: how to print a value using $display


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



Reply With Quote
  #5 (permalink)  
Old 10-11-2007, 10:42 AM
Evan Lavelle
Guest
 
Posts: n/a
Default Re: how to print a value using $display

On Thu, 11 Oct 2007 08:15:04 -0000, sundar <[email protected]>
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
Reply With Quote
  #6 (permalink)  
Old 10-11-2007, 12:48 PM
Arsi
Guest
 
Posts: n/a
Default Re: how to print a value using $display

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

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What should be value of the b ( $display (b) ) here [email protected] Verilog 3 06-18-2007 10:25 PM
Output display PLI? ajcrm125 Verilog 0 08-14-2006 05:07 PM
questions about $display Ken Verilog 1 03-23-2006 06:39 PM
Sell Print Circuit Board --(CHINA) [email protected] Verilog 0 03-12-2006 07:56 AM
How to get a module to display it's own instance name? Mike Sendrove Verilog 3 10-21-2003 08:31 PM


All times are GMT +1. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved