There are four types of data objects in VHDL:
- signals
- variables
- constants
- files
Signal
The signal represents interconnection wires between ports
it may be declared in the declaration part of
- packages
- entities
- architectures
- blocks
In this course, we don’t address the block statement syntax. The block statement is a concurrent VHDL construct that is not often used to design hardware. We want to give you an operative VHDL without wasting time describing all the VHDL constructs that you will not use in the future. The signal declaration is
signal signal_name : signal_type;
Signal assignment: <=
Variable
The variable locally stores temporary data and it is used only inside a sequential statement that means
- process
- function
- procedures
The variable is visible only inside processes and subprograms in which it is declared. The variable declaration is
variable variable_name : variable_type;
Variable assignment: :=
Constant
The constant names specific values to make the model better documented and easy to update.
The constant can be declared in all the declarative VHDL statement,
- sequential
- concurrent
that means it may be declared in the declaration section of packages, entities, architectures, processes, subprograms and blocks
The constant declaration is
constant constant_name : constant_type := value;
File
The File type is used to access File on disk.
It is used only in test bench; in fact File type cannot be implemented in hardware.
In order to use the FILE type you shall include the TextIO package that contains all procedures and functions that allow you to read from and write to formatted text files.
Input ASCII files are handled as file of lines, where a line is a string, terminated by a carriage return.
TextIO package declares a type line used to hold
- a line read from an input file
- a line to write to an output file
process_write_file : process(...) file file_name_write : text; -- declare file variable row : line; -- line to access file variable integer_value : integer; -- integer value write to file begin -- open file write mode file_open(file_name_read, “file_to_write.txt”, write_mode); -- read line from file and then read integer value writeline(file_name_write,row); write(row,integer_value); ... end process process_write_file;
process_read_file : process(...) file file_name_read : text; -- declare file variable row : line; -- line to access file variable integer_value : integer; -- integer value read from file begin -- open file read mode file_open(file_name_read, “file_to_read.txt”, read_mode); -- read line from file and then read integer value readline(file_name_read,row); read(row,integer_value); ... end process process_read_file;
Previous –