View Single Post
  #6 (permalink)  
Old 08-07-2007, 03:27 PM
Paul Uiterlinden
Guest
 
Posts: n/a
Default Re: How do I declare CFILE variables with global visibility?

G Iveco wrote:

> CFILE is an integer subtype.
>
> SUBTYPE CFILE IS INTEGER;
>
> With this package, one can write fprintf and printf as if it's in C
> language..
>
>
> Here are some examples,
>
> variable fout: CFILE; --FILE fout: text; --FILE *fout;
> variable fin: CFILE; --FILE fin: text; --FILE *fin;
> variable fout1:CFILE; --FILE fout1:text;
> variable fout2:CFILE; --FILE fout2:text;
>
>
> fout1:=fopen("xxx_fout1.txt", "w"); --file_open(fout1,
> "xxx_fout1.txt", WRITE_MODE);
> fprintf(fout1, " Hello, World\n 123\n 9bc ");
> fclose(fout1); --fclose(fbuf1, fout1);


Based on those examples, I suppose these variables can be made shared
variables (or rather: protected shared variables) declared in a package.
Then you can print from different processes to the same file. But still you
should be carefull not to open the file more than once.

Apart from everything, I don't like the idea of trying to mimic the C-style
print procedures in VHDL. This is my personal taste, based on the fact that
VHDL lacks variable argument lists. So there always be limitations. I'd
rather stick to VHDL and use type LINE from std.textio to build the strings
I want to print. Together with some home brew print procedures and
conversion functions things are quite manageable.

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.
Reply With Quote