bnary files

P

PATRICE

Guest
Hello
I am trying to write a binary result file in vhdl.
I tried to write with type character, with narural ranged 0-255,
with array of 8bits but i never had the expected result.
(i expect to write 1 byte)

Can someone help me please

Thanks in advance
 
On Wed, 28 Jul 2004 14:41:40 +0200, PATRICE <patrice.ulrich@evc.net>
wrote:

Hello
I am trying to write a binary result file in vhdl.
I tried to write with type character, with narural ranged 0-255,
with array of 8bits but i never had the expected result.
(i expect to write 1 byte)
In most simulators, "file of character" works OK. Precisely
what features of the result were unexpected?

The following process gives me a binary file containing
256 bytes, with values 0, 1, 2, ... 254, 255.

process
type charfile is file of character;
file f: charfile;
begin
file_open(f, "junk.bin", write_mode);
for i in 0 to 255 loop
write(f, character'val(i));
end loop;
file_close(f);
wait;
end process;

Strictly, this code is not portable across simulators and
operating systems. In practice, though, it works well.

Trying to write a file of "natural range 0 to 255" is
much less likely to work, because "natural range 0 to 255"
is a subtype of integer and therefore each object probably
occupies 32 bits. You can write files like this, with each
32-bit integer representing 4 bytes, but you are then at the
mercy of byte ordering conventions and suchlike.
--
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, 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.
 

Welcome to EDABoard.com

Sponsor

Back
Top