character to std_logic_vector

P

Pedro Claro

Guest
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
 
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=Ralf+Hildebrandt+Hex&hl=de&lr=&ie=UTF-8&selm=b6kouh%246ab5i%243%40ID-8609.news.dfncis.de&rnum=2


Ralf
 
This works for me:

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

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" <camarero@ee.ethz.ch> wrote in message
news:3F28C53B.33AEA689@ee.ethz.ch...
This works for me:
MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),8);
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: jonathan.bromley@doulos.com
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.
 
I tried that. And it worked. :)
Thanks for the replies.

Pedro Claro


Francisco Camarero <camarero@ee.ethz.ch> wrote in message news:<3F28C53B.33AEA689@ee.ethz.ch>...
This works for me:

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

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
 
Jonathan Bromley wrote:
"Francisco Camarero" <camarero@ee.ethz.ch> wrote in message
news:3F28C53B.33AEA689@ee.ethz.ch...
This works for me:
MyStdLogicVector <= CONV_STD_LOGIC_VECTOR(character'pos(MyChar),8);

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 ).
 
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top