Processor's ALU main operations



Hello everyone. Here we will speak about some ALU's main operations based on Ternary  System. This ALU inherits all operations from his predecessor binary system, just with some modifications; instead of two traditional states, it has three states. For the three state system for convention we use positive state (1), negative state (-1) and zero state (0).

Here we are going to describe the next operations:
  • AND
  • OR
  • NOT
  • XOR
  • ADD
  • SUBTRACT
  • MULTIPLY
AND Table of Truth (in binary system):
AND(A, B)
 B
B
0
1
A
0
0
0
1
0
1


Example:
A=1110; B=0111;
A ∧ B=0110;

AND Table of Truth (in ternary system):
AND(A, B)
 B
B
-1
0
1
A
-1
-1
-1
-1
0
-1
0
0
1
-1
0
1
Example:
A=1-1-1-1; B=01-11;
A ∧ B=0-1-1-1;

OR  Table of Truth (in binary system):
OR(A, B)
 B
B
0
1
A
0
0
1
1
1
1
Example:
A=1110; B=0111;
A ∨ B=1111;

OR  Table of Truth (in ternary system):
OR(A, B)
 B
B
-1
0
1
A
-1
-1
0
1
0
0
0
1
1
1
1
1
Example :
A=1-1-1-1; B=01-11;
A ∨ B=11-11;

NOT Table of Truth (in binary system):
NOT(A)
A
¬ A
1
-1
0
0

NOT  Table of Truth (in ternary system):
NOT(A)
A
¬ A
1
-1
0
0
-1
1

XOR or Exclusive OR can be expressed in the following ways :
\begin{matrix}
p \oplus q & = & (p \lor q) \land  \lnot (p \land q) 
\end{matrix}
or
\begin{matrix}
p \oplus q & = & (p \land \lnot q) \lor (\lnot p \land q)
\end{matrix}

XOR Table of Truth (in binary system):
XOR(A, B)
 B
B
0
1
A
0
0
1
1
1
0

XOR Table of Truth (in ternary system):
XOR(A, B)
⊕ B
B
-1
0
1
A
-1
-1
0
1
0
0
0
0
1
1
0
-1

Add Operation Logic (in binary system):

When we add two positive states, we get an extra state that we add in the next operation.

Example Add in binary system:

14+7=21;



Add  Operation Logic (in Ternary system):
In the ternary system, we got two possible ternary states, which are positive and negative.

Example Add in Ternary system:

14+7=21;


SUBSTRACT operation is similar with ADD operation, the only difference we replace second number with its opposite (NOT (Second Number)). The final operation syntax would be like:
First Number + NOT (Second Number) = Result;

MULTIPLY Operation Logic (in binary system):



Example Multiply Operation in binary system. Uses standard decimal steps for calculating the result from multiplying two binary numbers.

14*7=98;


MULTIPLY Operation Logic (in ternary system):


Example Multiply Operation in ternary system. Uses same steps as in binary system.

14*7=98;