![]() |
|
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
"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 |
|
|
|
#5 |
|
Posts: n/a
|
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 |
|
|
|
#6 |
|
Posts: n/a
|
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 |
|
|
|
#7 |
|
Posts: n/a
|
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 |
|
|
|
#8 |
|
Junior Member
Join Date: Oct 2009
Location: Arnhem, NL
Posts: 1
|
Hi,
I also use character to std_logic_vector conversion, by means of a charToByte(charIn) function: Code:
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:
Instead of: Code:
So I do find it useful for synthesis as well. Ruudiculus |
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |