ALU
Abstraction and Implementation of ALU (Arithmetic Logic Unit) in Hardware Design Language and Java™.
Last updated
Abstraction and Implementation of ALU (Arithmetic Logic Unit) in Hardware Design Language and Java™.
Last updated
The Hack ALU computes a fixed set of functions on given two 16-bit inputs, out of which the function can be one of the possible eighteen functions.
We instruct the ALU which function to compute using six input bits, called control bits to the selected binary values.
Since the overall operation is driven by six control bits, the total number of possible functions that ALU can potientially compute is 2^6 = 64 possible functions.
Control bits:
zx -- essentially named as zerox -- states whether x is 0 or not -- if zx = true, then x = 0.
nx -- essentially named as negationx -- states whether x will undergo negation or not -- if nx = true, then x will undergo negation.
zy -- essentially named as zeroy -- states whether y is 0 or not -- if zy = true, then y = 0.
ny -- essentially named as negationy -- states whether y will undergo negation or not -- if ny = true, then y will undergo negation.
f -- essentially named as function -- states whether addition or and function is selected -- if f = true, then execute function x + y ; else x & y
no -- essentially named as negationout -- states whether output will undergo negaton or not -- if no = true, then out will undergo negation.
Output bits:
While output bits other than out is not shown in the truth table, there are two output bits -- zr & ng -- other than out.
zr -- essentially named as zero -- states whether the final output is zero or not. -- if out = 0; zr = true
ng -- essentially named as negative -- states whether the final output is negative or not. -- if out = negative; ng = true
Remember:
The nx and ny bits cause negation of x and negation of y respectively when true.
Negation (also known as Bitwise negation) of zero (000...00) is essentially (111...11), the 2's complement code of -1.
The ALU can be implemented using some of the gates we've learnt earlier.
Similar to the Implementation in HDL
The Most Significant Bit is dropped.