salman sheikh said:
Is there any way I can read in a file of negative and positive integers
into my VHDL testbench and convert them to hex values? Or does anybody
have a program to convert them?
Salman
You can read in integers using textio, and just reading into
an integer.
e.g.
use STD.TEXTIO.all;
....
process
variable L : LINE;
variable I : INTEGER;
variable OK : BOOLEAN;
file F : TEXT;
status : FILE_OPEN_STATUS;
begin
file_open(status, F, READ_MODE, "vectors.txt");
assert status OPEN_OK report "file open failure - Doh!";
while not ENDFILE(F) loop
READLINE(F, L);
assert L'LENGTH!=0 report "that's a short line!";
READ(L, I, OK);
assert OK report "file read error - Doh!";
report "I read the value " & INTEGER'IMAGE(I);
-- convert to hex here...
wait for 10 ns; -- or whatever
end;
wait;
end process;
Unfortunately converting to hex is not that easy.
Probably the most straightforward way is to write the values
to a line in the correct format, and then read them back.
There are procedures HREAD and HWRITE in IEEE.STD_LOGIC_TEXTIO
which you can use.
However I would first ask why you want hex and why you are starting
with integers? Can you actually put hex in the file instead?
regards
Alan
--
Alan Fitch
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:
(e-mail address removed)
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.