regards NULL character reading

V

vijayakumar

Guest
Hi VHDL users,

this is vijayakumar, any one help me how read NULL character from
file.

thank you for yours kind attention,

regards,

vijayakumar
 
"vijayakumar" <regupathivijayakumar@gmail.com> wrote in message
news:1166085927.201053.165730@t46g2000cwa.googlegroups.com...
Hi VHDL users,

this is vijayakumar, any one help me how read NULL character from
file.

thank you for yours kind attention,
Inside a procedure (I'll call it readfile), open the file as a bit_vector
file....

type bit_vector_file is file of bit_vector;
variable Bit_Vec: bit_vector(0 to 9999);
FILE InFile: bit_vector_file;
......
file_open(FILEOPEN_OK, InFile, File_Name, READ_MODE);

Then read in some number of characters using the read function

read(InFile, Bit_Vec, Bytes_Read);

Convert those bit vectors into integers by using the 'pos attribute
Data(n) := bit'pos(Bit_Vec(i));

where Data is an array of integers (actually I use an array of type byte
where 'byte' is an integer subtype in the range 0 to 255). The important
point is that each element of 'Data' is an integer and you'll find that it
equals whatever binary value it is that is in the file that you read from.

This approach lets you read in any binary file at all, NULL characters, CR,
LF don't matter at all. Package it up inside a procedure that you can call
and you'll be all set.

In order to test that your readfile procedure is really working you might
want to also write a similar writefile procedure that can write out an
arbitrary binary file as well. Then your testbench can set up an integer
array, write out a binary file and read it back and check that each and
every character is correct plus open the file that was created in a binary
file viewer and verify it again. Once you have readfile and writefile
procedures that can write binary files you'll be freed from the shackles of
text only mode.

KJ
 
vijayakumar wrote:

this is vijayakumar, any one help me how read NULL character from
file.
also see:
http://home.comcast.net/~mike_treseler/char_file.vhd
 
Mike Treseler wrote:
vijayakumar wrote:

this is vijayakumar, any one help me how read NULL character from
file.

also see:
http://home.comcast.net/~mike_treseler/char_file.vhd
i am realy thank full to you. i try this code . this code working fine.

once again thanks to you..

with regards
vijayakumar
 

Welcome to EDABoard.com

Sponsor

Back
Top