Академический Документы
Профессиональный Документы
Культура Документы
Basic Input/Output
1
File Objects
Files provides an interface between the VHDL programs and the host environment
VHDL Program
File Type and Declaration Opening and Closing a File of a specified type Reading and Writing from a file
A very useful example of the application of file I/O is the construction of testbenches
Example: the testbench reads test inputs from a file, applies them to the model under test, and records model outputs for analysis
3
Files are distinguished by the type of information stored type textFileType is file of string; type integerFileType is file of integer; File declarations VHDL 1987 file infile: textFileType is in inputdata.txt; file outfile: textFileType is out outputdata.txt; File declarations VHDL 1993 file infile: textFileType open read_mode is inputdata.txt; file outfile: textFileType open write_mode is outputdata.txt;
4
VHDL 1987 provides read(f,value), write(f, value) and endfile(f) It uses implicit file open operations via file declarations
5
VHDL 93 provides READ(file_handle,value), WRITE(file_handle, value) and ENDFILE(file_handle), and also FILE_OPEN() and FILE_CLOSE() VHDL 93 allows both explicit and implicit file open operations procedure FILE_OPEN(file file_handle: FILE_TYPE File_name: in STRING; Open_kind: in FILE_OPEN_KIND := READ_MODE); procedure FILE_OPEN(File_Status:out FILE_OPEN_STATUS; file file_handle: FILE_TYPE File_name: in STRING; Open_kind: in FILE_OPEN_KIND := READ_MODE); procedure FILE_CLOSE(file file_handle: FILE_TYPE)
7
One common approach to I/O for the predefined types of the language is to use the TEXTIO package I/O is text based (ASCII) The TEXTIO package is in the STD library, which is implicitly declared. You do not need to declare the usage of the library STD, however you still need to declare the use of the package contents via the use clause
10
Text based I/O A file is organized by lines read() and write() procedures operate on line data structures readline() and writeline() procedures transfer data from-to files The TEXTIO package is in the library STD and provides: procedures for reading and writing the pre-defined types from lines predefined access to std_input and std_output procedures names are overloaded procedure
11
Result
This is an example of formatted I/O The First Parameter is = 5 The Second Parameter is = 0110 ...and so on 12
Generally input and output are mapped to standard input and standard output respectively
13
Constructing Testbenches
General approach: Apply stimulus vectors and Measure and Record response vectors
If the number of test vectors is too big procedural vectors generation is preferable to FILE I/O vectors generation Clock and reset generation is usually done with procedural stimulus
15
Testbenches: Validation
Compare reference vectors with response vectors and record errors in external files In addition to failed tests record simulation time
17
Designer can report errors at predefined levels: NOTE, WARNING, ERROR and FAILURE (enumerated type) Report argument is a character string written to simulation output TEXTIO may be faster than ASSERT if we do not need to stop the simulation
18
Summary
Basic Input/Output Binary I/O ASCII I/O and the TEXTIO package VHDL 87 vs. VHDL 93
Testbenches The ASSERT statement
19