RTL Building Block: Nguyễn Thị Ngọc Huyền Trần Trung Hiếu
RTL Building Block: Nguyễn Thị Ngọc Huyền Trần Trung Hiếu
• Electronic register
• Data
• A basic ALU has three parallel data buses consisting of two input operands (A and B) and a result output (Y).
• Opcode
• The opcode input is a parallel bus that conveys to the ALU an operation selection code, which is an
enumerated value that specifies the desired arithmetic or logic operation to be performed by the ALU. The
opcode size (its bus width) determines the maximum number of different operations the ALU can perform;
for example, a four-bit opcode can specify up to sixteen different ALU operations.
Arithmetic logic unit
• Status
• Outputs
• The status outputs are various individual signals that convey supplemental information about the result of
the current ALU operation. General-purpose ALUs commonly have status signals such as:
• Carry-out, which conveys the carry resulting from an addition operation, the borrow resulting from a
subtraction operation, or the overflow bit resulting from a binary shift operation.
• Zero, which indicates all bits of Y are logic zero.
• Negative, which indicates the result of an arithmetic operation is negative.
• Overflow, which indicates the result of an arithmetic operation has exceeded the numeric range of Y.
• Parity, which indicates whether an even or odd number of bits in Y are logic one.
• Inputs
• The status inputs allow additional information to be made available to the ALU when performing an
operation. Typically, this is a single "carry-in" bit that is the stored carry-out from a previous ALU operation.
Functions of ALU
• Arithmetic operation
• Add: A and B are summed and the sum appears at Y and carry-out.
• Add with carry: A, B and carry-in are summed and the sum appears at Y and carry-out.
• Subtract: B is subtracted from A (or vice versa) and the difference appears at Y and carry-
out. For this function, carry-out is effectively a "borrow" indicator. This operation may
also be used to compare the magnitudes of A and B; in such cases the Y output may be
ignored by the processor, which is only interested in the status bits (particularly zero and
negative) that result from the operation.
• Subtract with borrow: B is subtracted from A (or vice versa) with borrow (carry-in) and
the difference appears at Y and carry-out (borrow out).
• Two's complement (negate): A (or B) is subtracted from zero and the difference appears
at Y.
• Increment: A (or B) is increased by one and the resulting value appears at Y.
• Decrement: A (or B) is decreased by one and the resulting value appears at Y.
• Pass through: all bits of A (or B) appear unmodified at Y. This operation is typically used
to determine the parity of the operand or whether it is zero or negative, or to load the
operand into a processor register.
Functions of ALU
• Bitwise logical operations
• AND: the bitwise AND of A and B appears at Y.
• OR: the bitwise OR of A and B appears at Y.
• Exclusive-OR: the bitwise XOR of A and B appears at Y.
• Ones' complement: all bits of A (or B) are inverted and appear at Y.
• The binary word to be stored is applied to the four D inputs and is remembered
by the flip-flops at the rising edge of the next clock (CK) pulse. The stored data
can then be read from the Q outputs at any time, as long as power is maintained,
or until a change of data on the D inputs is stored by a further clock pulse, which
overwrites the previous data.
Parallel In/Parallel Out’ (PIPO) register
• A simple 4-bit register is illustrated in Fig. 5.7.1 and consists of four D Type flip-
flops, sharing a common clock input, providing synchronous operation ensuring
all bits are stored at exactly the same time.
Ripple carry adder circuit.
• Multiple full adder circuits can be cascaded in parallel to add an N-bit
number. For an N- bit parallel adder, there must be N number of full
adder circuits. A ripple carry adder is a logic circuit in which the carry-
out of each full adder is the carry in of the succeeding next most
significant full adder
Full adder
• Full adder is a logic circuit that adds two input operand bits plus a
Carry in bit and outputs a Carry out bit and a sum bit.. The Sum
out (Sout) of a full adder is the XOR of input operand bits A, B and
the Carry in (Cin) bit. Truth table and schematic of a 1 bit Full adder is
shown below
• Logic simulation tools may use a design's RTL description to verify its correctness.