use textio.all;immediately before every architecture that uses input and output. The name of the library is textio and this statement indicates that you wish to use everything or all of the textio library. Once you have done that, you may use any of the features discussed in this section. Note that although it is not part of the language, the library is standard and will be the same regardless of the VHDL tools you are using.
Text is input and output using textio via a variable of the type line. Since variables are used for textio, input and output is done in processes. The procedure for outputting information is to first place it in text form into the variable of type line and then to request that the line be output. This is shown in the following example.
use textio.all; architecture behavior of check is begin process (x) variable s : line; variable cnt : integer:=0; begin if (x='1' and x'last_value='0') then cnt:=cnt+1; if (cnt>MAX_COUNT) then write(s,"Counter overflow - "); write(s,cnt); writeline(output,s); end if; end if; end process; end behavior;The write function is used to append text information at the end of a line variable which is empty when the simulator is initialized. The function takes two arguments, the first is the name of the line to append to, and the second is the information to be appended. In the example, s is set to "Counter overflow - ", and then the current value of cnt is converted to text and added to the end of that. The writeline function outputs the current value of a line to the monitor, and empties the line for re-use. The first argument of the writeline function just indicates that the text should be output to the screen. If MAX_COUNT were a constant equal to 15 and more than 15 rising edges occur on the signal x, then the message
Counter overflow - 16would be printed on the screen.
The write statement can also be used to append constant values and the value of variables and signals of the types bit, bit_vector, time, integer, and real. Keyboard input is more complex than output, and is not discussed in this tutorial.
The previous section is Behavioral Descriptions - Signals and Processes.
The next section is The End.