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 09-25-2006, 08:12 AM
raghu
Guest
 
Posts: n/a
Default text to binary

Is it possible to convert a text message into a binary format using
verilog language???

Thanks a lot.

Regards,
Raghu

Reply With Quote
  #2 (permalink)  
Old 09-25-2006, 09:03 AM
Ajeetha
Guest
 
Posts: n/a
Default Re: text to binary

May be yes, with %u format - but why would you want to do that? Isn't
Perl/C better fit? What exactly are you trying to do?

Ajeetha, CVC
www.noveldv.com

raghu wrote:
> Is it possible to convert a text message into a binary format using
> verilog language???
>
> Thanks a lot.
>
> Regards,
> Raghu


Reply With Quote
  #3 (permalink)  
Old 09-26-2006, 05:44 AM
raghu
Guest
 
Posts: n/a
Default Re: text to binary

I would like to give the binary output of text message as an input to
an algorithm which i have implemented using verilog.
can you please suggest me how to convert the text to binary.

Hoping for a positive response.

Thanks a lot.

Regards,
Raghu

Reply With Quote
  #4 (permalink)  
Old 09-26-2006, 11:44 PM
[email protected]
Guest
 
Posts: n/a
Default Re: text to binary


raghu wrote:
> I would like to give the binary output of text message as an input to
> an algorithm which i have implemented using verilog.
> can you please suggest me how to convert the text to binary.


You may need to describe more precisely what you are trying to do,
since an English description is not entirely clear.

You have some text. If it is in a file, you can read it with a %s
format into a reg. If it is already in a reg, then you can skip that
step. At this point, the reg contains binary bits that represent the
ASCII encoding of the text characters. If that is what you mean by
converting it to binary, then you don't have to do anything. That is
already how it is stored. Your Verilog algorithm can operate on the
contents of the reg.

If you want to do something else, then you need to describe it more
precisely.

Reply With Quote
  #5 (permalink)  
Old 09-27-2006, 08:24 PM
raghu
Guest
 
Posts: n/a
Default Re: text to binary

Thanks a lot for your valuable response.
As you said that a text in a file can be read with %s format. can you
please give me more detailed description on this. I mean ,the syntax
and where the file should be kept i.e in which directory ,in order to
access the file.

Thanks &Regards,
Raghu



[email protected] wrote:
> raghu wrote:
> > I would like to give the binary output of text message as an input to
> > an algorithm which i have implemented using verilog.
> > can you please suggest me how to convert the text to binary.

>
> You may need to describe more precisely what you are trying to do,
> since an English description is not entirely clear.
>
> You have some text. If it is in a file, you can read it with a %s
> format into a reg. If it is already in a reg, then you can skip that
> step. At this point, the reg contains binary bits that represent the
> ASCII encoding of the text characters. If that is what you mean by
> converting it to binary, then you don't have to do anything. That is
> already how it is stored. Your Verilog algorithm can operate on the
> contents of the reg.
>
> If you want to do something else, then you need to describe it more
> precisely.


Reply With Quote
  #6 (permalink)  
Old 10-02-2006, 06:39 AM
[email protected]
Guest
 
Posts: n/a
Default Re: text to binary


raghu wrote:
> Thanks a lot for your valuable response.
> As you said that a text in a file can be read with %s format. can you
> please give me more detailed description on this. I mean ,the syntax
> and where the file should be kept i.e in which directory ,in order to
> access the file.


Assuming that your simulator supports Verilog-2001 file I/O, you have a
lot of flexibility in this. You can keep the file anywhere you like,
since the filename argument to $fopen can be a full pathname including
directories. For relative paths, I believe $fopen uses the directory
you are running in as the current working directory, in most
implementations. So the simplest thing is to put the file in the
directory you are running in.

Then something like

integer fd, nread;
reg [NBYTES*8:1] message;

initial
begin
fd = $fopen("myfile", "r"); // open for reading
if (!fd)
$display("failed to open myfile");
else
begin
nread = $fscanf(fd, "%s", message);
if (nread != 1)
$display("failed to read message");
end
end

You could also use $fgets to read a line into the message buffer,
instead of $fscanf. Either way, the buffer will end up with the bits
representing the ASCII encoding of the string read in. If the string
is shorter than the buffer, the upper bits will all be zeroes.

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
one-hot to binary Michael Verilog 6 09-22-2006 06:44 PM
Binary divider [email protected] Verilog 0 01-20-2006 06:41 AM
Text Editor for Verilog (also C, PERL, VHDL) A Verilog 12 04-29-2005 12:02 AM
gpl cver binary Jason Zheng Verilog 0 01-12-2005 08:23 PM
Re: UltraEdit Re: Text Editor for Verilog (also C, PERL, VHDL) Pablo Bleyer Kocik Verilog 0 08-18-2004 10:04 PM


All times are GMT +1. The time now is 01:00 AM.


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