Hardware Reference
In-Depth Information
performed simultaneously by different circuits whereas the opcode tells the multiplexer to
select one of the four units' outputs as the result. The adder is used to perform addition
and subtraction operations.
The four-operation ALU operates in the following manner:
When opcode 5 00 , the adder selects the n -bit A as its X input, the n -bit B as its Y input,
and CIN as its Carry input ( ci ) and generates SUM and Carry. MUX3 selects SUM to become
Result whereas Carry is connected to Cout directly. For this opcode, the ALU performs the ADD
operation.
When opcode 5 01 , the comparator output is 1, the inversion of the B input is selected as
the Y input, and 1 is selected as the ci to the adder. The adder essentially adds the two's comple-
ment of B to A , which is equivalent to performing the SUB operation. Since opcode is 01 and
SUM is connected to both the 00 and 01 inputs, it will be selected and sent to Result . For this
opcode, the ALU performs the SUB operation.
When opcode 5 10 , the MUX3 multiplexer selects the value connected to the 10 input and
sends it to Result. Therefore, the ALU performs the AND operation.
When opcode 5 11 , the MUX3 multiplexer selects the value connected to the 11 input and
sends it to Result. Therefore, the ALU performs the OR operation.
An ALU that performs more operations can be implemented by expanding the circuit
shown in Figure 1.1.
C ONTROL U NIT
From the beginning, the electronic digital computer is designed to execute machine
instructions only. A machine instruction is a combination of 0s and 1s. To simplify the com-
puter hardware design, most computers limit the instruction length to a few choices that are
a multiple of 8 bits. For example, the HCS12 microcontroller from Freescale has instructions
that are 8 bits, 16 bits, 24 bits, 32 bits, 40 bits, and 48 bits. You don't see instructions that are
13 bits, 29 bits, and so on.
A machine instruction has several fields. A mandatory field for every instruction is opcode,
which tells the ALU what operation to perform. Other fields are optional; when they exist, they
specify the operand(s) to be operated on.
To make the instruction execution time predictable, a clock signal is used to synchronize
and set the pace of instruction execution. A clock signal is also needed to control the access of
registers in the processor and external memory. The clock frequencies of the 8-bit and 16-bit
microcontrollers range from a few MHz to over 100 MHz.
Since a program consists of many machine instructions, there is a need to keep track of
what instruction to execute next. The control unit has a register called program counter (PC)
that serves this function. Whenever the processor fetches an instruction from memory, the pro-
gram counter will be incremented by the length of that instruction so that it points to the next
instruction. The fetched instruction will be placed in the instruction register (IR), decoded, and
executed. During this process, appropriate control signals will be generated to control the hard-
ware circuit operation.
A program is normally not sequential. The execution order of machine instructions may
be changed due to the need to execute instructions on the basis of the value of a certain
condition or to repeat a group of instructions. This is called program flow control . The
decision to change program flow is often based on certain conditions, for example, whether
the previous instruction caused Carry out to be 1, whether the result of the previous opera-
tion is 0, or whether the result of the previous operation is negative. These conditions are
often collected in a status register so that they can be used to make a decision. This type of
program flow change is implemented by a conditional branch instruction (may also be called
 
Search WWH ::




Custom Search