Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - character to std_logic_vector

 
Thread Tools Search this Thread
Old 07-30-2003, 06:00 PM   #1
Default character to std_logic_vector


Greetings,

I recently tried to open some files for reading and I managed to read
characters and then putting them in hexadecimal format. ( I used HREAD
form ieee.std_textio ). My question is the following: is there anyway
for reading characters ( from 0-255 in ascii ) and then converting them
do a std_logic_vector or an integer.
For example if I have a "K" on the file the output would be "4B" since
its the hexadecimal code of the character "K".

Thanks in advance,

Pedro Claro


Pedro Claro
  Reply With Quote
Old 07-30-2003, 08:13 PM   #2
Ralf Hildebrandt
 
Posts: n/a
Default Re: character to std_logic_vector
Hi Pedro!


> I recently tried to open some files for reading and I managed to read
> characters and then putting them in hexadecimal format.


I've posted a quick&very dirty solution some time ago:
http://groups.google.de/groups?q=Ral...ncis.de&rnum=2


Ralf



Ralf Hildebrandt
  Reply With Quote
Old 07-31-2003, 08:28 AM   #3
Francisco Camarero
 
Posts: n/a
Default Re: character to std_logic_vector


This works for me:

...
use ieee.std_logic_arith.all;
...
MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),;
...

HTH

Francisco Camarero



Pedro Claro wrote:
>
> Greetings,
>
> I recently tried to open some files for reading and I managed to read
> characters and then putting them in hexadecimal format. ( I used HREAD
> form ieee.std_textio ). My question is the following: is there anyway
> for reading characters ( from 0-255 in ascii ) and then converting them
> do a std_logic_vector or an integer.
> For example if I have a "K" on the file the output would be "4B" since
> its the hexadecimal code of the character "K".
>
> Thanks in advance,
>
> Pedro Claro



Francisco Camarero
  Reply With Quote
Old 07-31-2003, 09:38 AM   #4
Jonathan Bromley
 
Posts: n/a
Default Re: character to std_logic_vector
"Francisco Camarero" <> wrote in message
news:...
> This works for me:
> MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),;


Fine for simulation. It doesn't work correctly in most synthesis tools,
sadly.
--

Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.





Jonathan Bromley
  Reply With Quote
Old 08-01-2003, 07:07 PM   #5
Pedro Claro
 
Posts: n/a
Default Re: character to std_logic_vector
I tried that. And it worked.
Thanks for the replies.

Pedro Claro


Francisco Camarero <> wrote in message news:<>...
> This works for me:
>
> ..
> use ieee.std_logic_arith.all;
> ..
> MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),;
> ..
>
> HTH
>
> Francisco Camarero
>
>
>
> Pedro Claro wrote:
> >
> > Greetings,
> >
> > I recently tried to open some files for reading and I managed to read
> > characters and then putting them in hexadecimal format. ( I used HREAD
> > form ieee.std_textio ). My question is the following: is there anyway
> > for reading characters ( from 0-255 in ascii ) and then converting them
> > do a std_logic_vector or an integer.
> > For example if I have a "K" on the file the output would be "4B" since
> > its the hexadecimal code of the character "K".
> >
> > Thanks in advance,
> >
> > Pedro Claro



Pedro Claro
  Reply With Quote
Old 08-04-2003, 09:12 AM   #6
Francisco Camarero
 
Posts: n/a
Default Re: character to std_logic_vector

Jonathan Bromley wrote:
>
> "Francisco Camarero" <> wrote in message
> news:...
> > This works for me:
> > MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),;

>
> Fine for simulation. It doesn't work correctly in most synthesis tools,
> sadly.



I know.

I could assume from Pedro's message that,
if he was opening some files for reading,
he was not trying to synthesize that code.

Fran.



Pedro Claro wrote:
>
> Greetings,
>
> I recently tried to open some files for reading and I managed to read
> characters and then putting them in hexadecimal format. ( I used HREAD
> form ieee.std_textio ).



Francisco Camarero
  Reply With Quote
Old 08-04-2003, 09:18 AM   #7
Francisco Camarero
 
Posts: n/a
Default Re: character to std_logic_vector
Amontec Team wrote:
>
> Pedro Claro wrote:
> > Greetings,
> >
> > I recently tried to open some files for reading and I managed to read
> > characters and then putting them in hexadecimal format. ( I used HREAD
> > form ieee.std_textio ). My question is the following: is there anyway
> > for reading characters ( from 0-255 in ascii ) and then converting them
> > do a std_logic_vector or an integer.
> > For example if I have a "K" on the file the output would be "4B" since
> > its the hexadecimal code of the character "K".
> >
> > Thanks in advance,
> >
> > Pedro Claro

> For synthesis, you have to write a big mux (using case) including all
> conversion (has a rom description).
>
> I wrote this conversion table before.


Excuse me if I don't understand the issue here.

Why would someone want to synthesize a 'character to std_logic_vector' function?

File handling is not synthesizable, and I don't think any synthesis could can
handle character types, can they?

Fran.


Francisco Camarero
  Reply With Quote
Old 10-21-2009, 09:38 AM   #8
Ruudiculus
Junior Member
 
Join Date: Oct 2009
Location: Arnhem, NL
Posts: 1
Default Use of character to std_logic_vector conversion does make sense for synthesis
Hi,

I also use character to std_logic_vector conversion, by means of a charToByte(charIn) function:
Code:
to_unsigned(character'pos(charIn),8);

During simulation I use this to insert characters from files, but I also need it for synthesis, since I have an entity that parses serial data that is in ASCII. For readability in my code it is nicer to do a compare like:
Code:
... if serialByteIn = charToByte('{') then ...

Instead of:
Code:
... if serialByteIn = X"7B" then ...

So I do find it useful for synthesis as well.


Ruudiculus
Ruudiculus is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt parsing xml data with '<' invalid character h_q Software 0 01-03-2008 10:00 PM
Best character reveals JFR DVD Video 16 06-15-2004 10:25 PM
O.T. Battlestar Galactica Chris4V DVD Video 42 01-04-2004 08:19 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46