System Operation
The CPU controls the system data transfers via the data and address buses and additional control lines. A clock circuit, usually containing a crystal oscillator (as found in digital watches), is required; this produces a precise fixed frequency signal that drives the microprocessor along. The CPU operations are triggered on the rising and falling edges of the clock signal, allowing their exact timing to be defined. This allows events in the CPU to be completed in the correct sequence, with sufficient time allowed for each step. The CPU generates all the main control signals based on the clock. A given CPU can be used in different system designs, depending on the type of application, the amount of memory needed, the I/O requirements and so on.
The address decoder controls access to memory and I/O registers for a particular design.
Typically, a programmable logic device (PLD) is used to allocate each memory chip to a specific range of addresses. An input address code in a particular range generates a chip select output, which enables that device. The I/O port registers, which are set up to handle the data transfer in and out of the system, are also allocated particular addresses by the same mechanism, and accessed by the CPU in the same way as memory locations. The allocation of addresses to particular peripheral devices is called a memory map (Figure 1.6b).
Program Execution
The ROM and RAM will contain program code and data in numbered locations, that are selected by a binary code at its address inputs. If the program is in ROM, it can start immediately (as in the PC BIOS), but RAM must be loaded from a non-volatile program store, such as a hard disk.
A register is a temporary store for data within the CPU or port. In the port chip, it holds working data or a control code which sets up how the port will operate. For example, the bits in the data direction register control whether each port pin operates as an input or an output. The data being sent in or out is then stored temporarily in the port data register.
The program consists of a list of instructions in binary code stored in memory, with each instruction and any associated data (operands) being stored in sequential locations. The program instruction codes are fetched into the CPU and decoded. The CPU sets up the internal and external control lines as necessary and carries out the operation specified in the program, such as read a character code from the serial port into the CPU. The instructions are executed in order of their addresses, unless the instruction itself causes a jump to another point in the program, or an ‘interrupt’ (signal) is received from an internal or external source. The program counter keeps track of the current step.