Java Reference
In-Depth Information
Table 5.6 I O instructions for the CPU
Code
Argument
Description
address
Read information from the I
O and store it in the cell at address
INPUT
address
Read information from the cell at address and send it to I
O
OUTPUT
address
Open a file whose name is found in the cell at address
FOPEN
address
Read information from the currently open file into the cell at address
FREAD
Close the previously opened file
FCLOSE
5.6.2
Design
The new devices are represented by three classes: Display , Keyboard and
HardDisk . They have characteristics similar to the other components of the
system (i.e. CPU and RAM). The structure of the HDL package with the
addition of the new classes is shown in Figure 5.9.
The main issue that we need to address in the development of the three
new components concerns the level of abstraction of their functionalities.
Decision point
How do the keyboard and the display simulate the interaction with the user?
The keyboard and the display are complex devices. We adopt a simplified
model of them: we assume that all the information read from the keyboard
and written on the display is represented by strings. The information goes
directly from the keyboard to the RAM and from the RAM to the display.
When the instruction INPUT is executed the CPU asks the keyboard to
read a line of input from the user. Then, the CPU waits for the user to insert
Computer
! simulate()
CPU
Display
HardDisk
Keyboard
RAM
! execute()
! execute()
! execute()
! execute()
! execute()
Bus
0 data : String
0 command : String
0 address : int
Figure 5.9 Complete computer classes
 
Search WWH ::




Custom Search