106 Flashcards
What does ALU stand for?
An Arithmatic Logic Unit
What does an ALU do?
> Preforms arithmetic and logical operations on binary numbers
Typically there are 2 input numbers and a single output
Control bits are used to select which operation to carry out on the inputs
What is a BUS?
An example of a parallel connection
What are the conventions for drawing busses?
> Thick line
Black Arrows
Single lines crossed with diagonal lines
What are some Logic operations that can be accomplished with an ALU?
> Bitwise operations
Negation operations
Bit inverse clear operations
What are bitwise operations?
> Different logic gate functions. e.g. AND, OR etc
> Applied to bit pairs
What are negation operations?
> Inversion or complementing
> This can be done with logic gates in parallel
What are bit inverse clear operations?
> This is for ARM Processors
This is used to set any bit in a binary number to 0.
Two inputs: A (Binary number) & B (Used to select which bit is to be set to 0)
How it works:
B is inverted
An AND function is applied to both bits
A.!B
What are some Arithmatic operations that can be done on an ALU?
> Addition
Subtraction
Most ALU’s will implement a carry look-ahead adder because they are quicker than a ripple adder
Some microprocessors may also have hardware multipliers
How is binary subtraction done?
> Using ripple adders and 2s complement
If 2’s complement is applied to the second value then the two number can be added together and this produces the subtracted numbers.
Y = A + (-B)
Y = A + B ̅ + 1
How can 2’s complement be applied to a binary number for subtraction?
The second binary number is inverted (1’s Complement) and then when added with the first binary number the carry in on the ripple adder is set to 1
What is the 3rd type of operation that an ALU can preform?
A data movement operation
What decides what function an ALU preforms?
The control bits
What do the ALU control bits do?
Control various multiplexers in the ALU to route the bus to the correct operation
LEARN THE MULTIPLEXER ARCHETECTURE OF AN ALU
DO IT
What are the common operations of an ALU?
> A+B > A-B > B-A > A AND B > A OR B > A XOR B > A AND !B > B > !B
What are OP codes?
> Operation codes
> This is the binary number that controls the ALU and select which operation is to be preformed
How are these operations named?
With a mnemonic
What are the different mnemonics of an ALU?
> ADD - A+B > SUB - A-B > RSB - B-A > AND - A AND B > ORR - A OR B > BIC - A XOR B > EOR - A AND !B > MOV - B > MVN - !B
What are flags?
These indicate particular situations that can occur from preforming an operation on an ALU
What are 4 typical flags?
C – A final carry-out has been generated
V – Overflow has occurred
N – The ALU output is negative
Z – The ALU output is zero
What does the carry flag indicate?
> From the final carry out of the ripple adder
This is meaningless when considering signed numbers
This shows that the output number is too large for the ALU
What does the overflow flag indicate?
> If the result is out of the range for that number of bits then
This is meaningless for unsigned numbers
It occurs when the sign bit changes
Overflow occurs when for the most significant bit, the carry-in and carry-out bits are different
What does the zero flag indicate?
> To detect whether the output is zero
> This is done by having a NOR gate with multiple inputs connected to the ALU output
What does the negative flag indicate?
> This is the sign bit of the output bus (most significant bit)
This is irrelevant when considering unsigned numbers
This is also meaningless for purely logical operations