
Furber S.ARM system-on-chip architecture.2000
.pdf
|
Appendix: Computer Logic |
Computer logic |
Computer design is based upon Boolean logic where a signal on a wire has one of two |
|
values: true or false. Typically a voltage near ground represents 'false' and one near the |
|
supply voltage represents 'true'; however, any representation that can reliably reflect two |
|
different states can be used. 'True' is sometimes called logic ' 1' and 'false' logic '0'. |
Logic gates |
A logic gate produces a function of one or more logic inputs. A 2-input 'AND' gate, |
|
for example, produces a 'true' output if the first input is 'true' AND the second |
|
input is 'true'. Since each input is either 'true' or 'false', there are only four poss- |
|
ible input combinations, and the complete functionality of the gate can be expressed |
|
in a truth table as shown in Figure A. 1, which also shows the logic symbol for an |
|
AND gate. An AND gate can be extended to more than two inputs (though current |
Figure A.1 The logic symbol and truth table for an AND gate.
CMOS technology limits the practical fan-in to four inputs, reducing to three inputs on some sub-micron process technologies). The output is a ' 1' when all the inputs are T, and the output is '0' when at least one input is '0'.
An OR gate is defined similarly, giving a '0' when all the inputs are '0' and a T when at least one input is a ' 1'. The logic symbol and truth table for a 2-input OR gate are shown in Figure A.2 on page 400.
A vital logic component is the inverter. This has one input and produces the opposite output. Its logic function is NOT. The output is false ('0') if the input is true ('!') and vice versa. An AND gate with an inverter on the output is a NAND (NOT AND) gate, and an OR gate with an inverter on the output is a NOR (NOT OR) gate. Inversion is often denoted by a circular 'bubble' on the input or output of a gate.
399

400 |
Appendix: Computer Logic |
|
Figure A.2 The logic symbol and truth table for an OR gate. |
|
In fact conventional simple CMOS gates are inherently inverting, so NAND is |
|
simpler than AND, the latter being formed by adding an inverter to the former, and |
|
similarly OR gates are formed from NOR gates by adding inverters. |
Boolean algebra |
All logic circuits can be constructed using only 2-input NAND gates. This stems |
|
from the rules of Boolean algebra. First, observe that if both inputs of a NAND gate |
|
are connected to the same signal, the output is the inverse of the input, so we have |
|
an inverter. Next, connect an inverter to each input of a NAND gate. A brief exami- |
|
nation of the truth table reveals that the resulting circuit performs the OR function. |
|
Often logic equations are written using the notation of conventional arithmetic, |
|
using '•' for AND and '+' for OR. Thus 'A AND (B OR Q' is written 'A-(B + Q'. |
|
Logical inversion is denoted by an overbar: 'A NAND 5' is written 'A-B\ This nota- |
|
tion is very convenient provided that the context makes it clear that an equation is a |
|
Boolean logic equation where 1 + 1 = 1. |
Binary numbers |
Numbers are usually represented in computers in binary notation (there is a more |
|
complete discussion of data types and number representation in Section 6.2 on |
|
page 153). Here, instead of using the familiar base 10 number notation where each |
|
digit is in the range 0 to 9 and positions have values which scale by powers of 10 |
|
(units, tens, hundreds,...), binary numbers have digits which are either 0 or 1 and |
|
positions have values that scale by powers of 2 (units, twos, fours, eights, |
|
six-teens,...). Since each binary digit (bit) is restricted to one of two values it can be |
|
represented by a Boolean value, and the complete binary number is represented by |
|
an ordered set of Boolean values. |
Binary addition |
The sum of two single-bit binary numbers can be formed using the logic gates we have |
|
met already. If both bits are zero the sum is zero; the sum of a one and a zero is one, but |
|
the sum of two ones is two, which is represented in binary notation by the two bits ' 10'. |
|
An adder for two single-bit inputs must therefore have two output bits: a sum bit with |
|
the same weight as the input bits and a carry bit which has twice that weight. |

Appendix: Computer Logic |
401 |
If the inputs are A and B, the sum and carry are formed as follows:
sum |
= A-B+A-B |
Equation 18 |
carry = A-B |
Equation 19 |
The sum function arises frequently in digital logic and is called the exclusive OR or XOR function. It is 'exclusive' because it is true if A is true, or B is true, but not if they are both true. It has its own logic symbol which is shown in Figure A.3 along with a (non-obvious) implementation which uses four NAND gates.
Figure A.3 The logic symbol and NAND circuit for an XOR gate.
An adder for N-bit binary numbers can be constructed from single-bit adders, but all bits except the first may have to accept a carry input from the next lower stage. Each bit of the adder produces a sum and a carry-out from the inputs and the carry-in:
sum, |
=^4j-5j-Ci.1 +Ai-Bi-Ci.l + Ai-Bi-Ci.l+A^-B^C^ |
Equation 20 |
Q |
=y41-5i+/4i-Ci.i+5i-C1.1 |
Equation 21 |
Here the equations apply for i= 1 toN and C0 is zero.
Multiplexers |
A common requirement in a processor implementation is to select the source of an |
|
operand from a number of alternative inputs on a cycle-by-cycle basis. The logic |
|
component that performs this function is a multiplexer (or simply a 'mux'). A 2- |
|
input multiplexer has a Boolean select input (S) and two binary input values A-t and |
< r > . |
BI, where 1 <i<NandN is the number of bits in each binary value. When 5 is zero, |
.-• - - |
the output Z; should equal^j and when S is one Z\ should equal Br This is a straight- |
|
forward logic function: |
|
Equation 22 |

402 Appendix: Computer Logic
Clocks |
Almost all processors are controlled by a free-running timing reference signal called |
|
a clock. (But not quite all; see Chapter 14 on page 374 for details of the AMULET |
|
processor cores that operate without any external timing reference signal). The |
|
clock controls the state changes within the processor. |
|
Generally, all the state is held within registers. During the clock cycle combinato- |
|
rial logic (logic whose outputs depend only on the current input values) works out the |
|
next state values using Boolean logic gates as described above. At the end of the clock |
|
cycle the active clock edge causes all the registers to switch simultaneously to the next |
|
state. For maximum performance the clock frequency is set at the highest rate at |
|
which all the combinatorial logic can be guaranteed to complete, under worst-case |
|
conditions, in time for the next active clock edge. |
Sequential |
A register stores the state between active clock edges and changes its contents on |
circuits |
the active edge. It is a sequential logic circuit; its outputs depend not only on the |
|
current input values, but also on how they have changed in the past. |
|
The simplest sequential circuit is the R-S (Reset-Set) flip-flop. This is a circuit |
|
whose output is set high whenever the Set input is active and is reset low whenever the |
|
Reset input is active. If both inputs are active at the same time the flip-flop behaviour |
|
depends on the implementation; if both are inactive the flip-flop remembers the last |
|
state it was put into. An implementation of an R-S flip-flop using two NOR gates is |
|
shown in Figure A.4 with its sequence table; this is no longer a simple truth table |
|
since the output is not a combinatorial function of the current input values. |
|
Figure A.4 An R-S flip-flop circuit and sequence table. |
Transparent |
A transparent (or D-type) latch has a data input (D) and an enable signal (En); the output |
latches |
follows the D input whenever En is high, but remains constant at whatever value applied |
|
just before En went low while En stays low. This can be constructed from an R-S flip-flop |
|
by generating R and S from D and En as shown in Figure A.5 on page 403. |


404 |
Appendix: Computer Logic |
Figure A.6 A D-type edge-triggered latch symbol, circuit and sequence table.
line to the edge-triggered latches. If we use negative-edge triggered latches, an AND gate will remove the entire high-going clock pulse provided the enable input is low before the clock goes high and stays low until the clock has gone low again. (These are the set-up and hold conditions for the enable input.) If the enable is, itself, produced from a similar register running off the same clock, it will meet these constraints. The register circuit is shown in Figure A.7.
Figure A.7 A register with a clock enable control signal.