FPGA Center


File is an object that can be used as a data type in VHDL designs after its declaration. This type helps us to create a file in computer file system and to access them.

type FT is file of data_type; --FT: File Type

procedure FILE_OPEN ( file anonymous: FT;
name: in STRING;
Open_Kind: in FILE_OPEN_KIND := READ_MODE );

procedure FILE_OPEN ( durum: out FILE_OPEN_STATUS;
file anonymous: DT;
name: in STRING;
Open_Kind: in FILE_OPEN_KIND := READ_MODE );

procedure FILE_CLOSE ( file anonymous: FT );

READ ( file anonymous: FT; value: out data_type);

WRITE ( file anonymous: FT; value: in data_type);

ENDFILE ( file anonim: FT ) return BOOLEAN;

File Declaration :

file identifier : sub_type file_open_information ::= [ open file_open_kind_expression ] is file_name


Example 1 (File Declaration):

type POSITIVE_FILE is file of POSITIVE;                                  --a file consists of positive numbers
type BIT_VECTOR_FILE is file of BIT_VECTOR ( 0 to 7 );    --a file consists of 8-bits vectors
type STRING_FILE is file of STRING;                                      --a file consists of strings of unknown numbers

Example 2:

type IntegerFile is file of INTEGER;
file D1: IntegerFile; --FILE_OPEN is not used during declaration

Example 3:

type IntegerFile is file of INTEGER;
file D2: IntegerFile is "readme.dat"; --FILE_OPEN is used.
--OPEN_KIND parameter is in read mode by default.

Example 4:

type IntegerFile is file of INTEGER;
file D3: IntegerFile open WRITE_MODE is "test.dat";  --FILE_OPEN s used.
--OPEN_KIND parameter is in write mode.


A file can be declared in architecture, block, package or subprograms. File can be different types in VHDL.

type_name defines subtypes of values in file. Subtypes can be constrained or unconstrained.

Files or access types can not be subtypes. If a composit type is used, the elements can not be in accesss type. Arrays used in design should be one dimensional.

By using file type, you can do some processes like openning files, closing files, writing to files, checking end of the files.

ÔÇťfile_open_kind" expression defines how to open a physical file. This expression is defined in Standard package.

If ÔÇťfile_open_informationÔÇŁ ┬áexpression is used in file declaration, file can be opened with FILE_OPEN.

If "file_open_kind" expression is not used in ÔÇťfile_open_informationÔÇŁ, READ_MODE is used.

ÔÇťfile_nameÔÇŁ represents the logical file name and should be in STRING type.

Files can be declared in subprograms. When the subprogram is instantiated, file is opened. After the subprogram ends, file is closed automatically.








Home | Fpga | VHDL | VHDL Dictionary | Digital Design | Simulation | PCB | Examples | Contact Us
Copyright © 2010 - 2013 FPGAcenter. All Rights Reserved.