[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [f-cpu] binary streams
On Thu, Sep 13, 2001 at 03:38:54AM +0200, Yann Guidon wrote:
[...]
> > but I don't know what to do in VHDL. Perhaps you can do something like
> > type octet is 0 to 255;
> > type octet_stream is file of octet;
> i think i tried this already, however i presume that this "subset"
> for the "integer" type keeps the 4-byte encoding (the range is only restricted)
> so if i read a "byte" i will increment the file counter by four.
> i'll try anyway because i better prove it, but it's a gut feeling.
There's a fundamental difference between the declarations
type octet is range 0 to 255; -- i forgot the `range'...
subtype other_octet is integer range 0 to 255;
`other_octet' is a subtype of `integer', and must use the same (4-byte)
encoding, IIRC, while `octet' is a new type that may use a single-byte
representation (vanilla doesn't, unfortunately).
> > If it still stops at a ^Z, I would consider that a bug in Simili.
> simili and vanilla definitely differ !
As well as the underlying OSes.
> > But you'll probably have to write a completely new set of I/O routines
> > for the `octet' type.
> not necessarily, but if it's necessary, i'll do it.
Seems like there are predefined read and write procedures...
> > On the other hand, binary files are evil anyway because they're not
> > portable (imagine you had to transfer them to a big-endian box, like
> > SPARC).
> in this case (random numbers coming from /dev/random or .tgz files)
> it is irrevelant.
In that case, you could also try a `file of integer' or something like
that, and read larger quantities. I've attached an example (works
with vanilla; please try simili yourself, I can't reboot while I'm
writing e-mails ;).
--
Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
"All I wanna do is have a little fun before I die"
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_textio.all;
library std;
use std.textio.all;
entity blah is
end blah;
architecture blah of blah is
type int_stream is file of integer;
file x : int_stream open read_mode is "random";
begin
process
variable y : integer;
variable lout : line;
begin
while not endfile(x) loop
read(x, y);
write(lout, y);
writeline(output, lout);
end loop;
wait;
end process;
end blah;