Logic Microoperations
Logic microoperations specify binary operations for strings of bits stored in registers. These operations consider each bit of the register separately and treat them as binary variables. For example, the exclusive-OR microoperation with the contents of two registers R1 and R2 is symbolized by the statement:
This specifies a logic microoperation to be executed on the individual bits of the registers provided that the control variable . As a numerical example, assume that each register has four bits. Let the content of be 1010 and the content of be 1100. The exclusive-OR microoperation stated above symbolizes the following logic computation:
- 1010 Content of R1
- 1100 Content of R2
- 0110 Content of R1 after
The content of , after the execution of the microoperation, is equal to the bit-by-bit exclusive-OR operation on pairs of bits in and previous values of . The logic microoperations are seldom used in scientific computations, but they are very useful for bit manipulation of binary data and for making logical decisions.
Special Symbols
Special symbols are adopted for the logic microoperations OR, AND, and complement, to distinguish them from the corresponding symbols used to express Boolean functions. The symbol will be used to denote an OR microoperation and the symbol to denote an AND microoperation. The complement microoperation is the same as the 1's complement and uses a bar on top of the symbol that denotes the register name.
By using different symbols, it is possible to differentiate between a logic microoperation and a control (or Boolean) function. Another reason for adopting two sets of symbols is to be able to distinguish the symbol , when used to symbolize an arithmetic addition, from a logic OR operation. Although the symbol has two meanings, it is possible to distinguish between them by noting the context in which the symbol occurs. When the symbol occurs in a microoperation, it denotes an arithmetic addition. When it occurs in a control (or Boolean) function, it denotes an OR operation. For example, in the statement:
The between and is an OR operation between two binary variables of a control function. The between and specifies an addition microoperation. The OR microoperation is designated by the symbol between registers and .
List of Logic Microoperations
There are 16 different logic operations that can be performed with two binary variables. These operations can be determined from all possible truth tables obtained with two binary variables. The 16 Boolean functions of two variables and are expressed in algebraic form, and the corresponding logic microoperations are derived by replacing variable with the binary content of register and variable with the binary content of register . Each bit of the register is treated as a binary variable and the microoperation is performed on the string of bits stored in the registers.
Boolean Function | Microoperation | Description |
---|---|---|
Clear | ||
AND | ||
AND with NOT B | ||
Transfer A | ||
NOT A AND B | ||
Transfer B | ||
Exclusive-OR | ||
OR | ||
NOR | ||
Exclusive-NOR | ||
Complement B | ||
OR with NOT B | ||
Complement A | ||
NOT A OR B | ||
NAND | ||
Set all bits to 1 |
Hardware Implementation
The hardware implementation of logic microoperations requires that logic gates be inserted for each bit or pair of bits in the registers to perform the required logic function. Although there are 16 logic microoperations, most computers use only four—AND, OR, XOR (exclusive-OR), and complement—from which all others can be derived.
A typical stage of a circuit that generates the four basic logic microoperations consists of four gates and a multiplexer. Each of the four logic operations is generated through a gate that performs the required logic. The outputs of the gates are applied to the data inputs of the multiplexer. The two selection inputs and choose one of the data inputs of the multiplexer and direct its value to the output. This stage must be repeated for each bit in the register.
Applications of Logic Microoperations
Logic microoperations are very useful for manipulating individual bits or a portion of a word stored in a register. They can be used to change bit values, delete a group of bits, or insert new bit values into a register. The following examples illustrate some of these operations:
Selective-Set
The selective-set operation sets to 1 the bits in register where there are corresponding 1's in register . It does not affect bit positions that have 0's in . For example:
- 1010 before
- 1100 (logic operand)
- 1110 after
The OR microoperation can be used to selectively set bits of a register:
Selective-Complement
The selective-complement operation complements bits in where there are corresponding 1's in . It does not affect bit positions that have 0's in . For example:
- 1010 before
- 1100 (logic operand)
- 0110 after
The exclusive-OR microoperation can be used to selectively complement bits of a register:
Selective-Clear
The selective-clear operation clears to 0 the bits in where there are corresponding 1's in . For example:
- 1010 before
- 1100 (logic operand)
- 0010 after
The AND microoperation with the complement of can be used to selectively clear bits of a register:
Mask Operation
The mask operation clears bits in where there are corresponding 0's in . For example:
- 1010 before
- 1100 (logic operand)
- 1000 after masking
The mask operation is an AND microoperation:
Insert Operation
The insert operation inserts a new value into a group of bits. This is done by first masking the bits and then ORing them with the required value. For example, to replace the four leftmost bits of an 8-bit register (01101010) with the value 1001:
-
Mask the four unwanted bits:
- 01101010 (A before)
- 00001111 (B mask)
- 00001010 (A after masking)
-
Insert the new value:
- 00001010 (A before)
- 10010000 (B insert)
- 10011010 (A after insertion)
The insert operation involves both AND and OR microoperations:
Clear Operation
The clear operation compares the words in and and produces an all 0's result if the two numbers are equal. This operation is achieved by an exclusive-OR microoperation:
- 1010
- 1010
- 0000
When and are equal, the result of the exclusive-OR operation is an all-0's word. This result can then be checked to determine if the two numbers were equal.
Logic microoperations are fundamental tools in digital logic design, enabling efficient bit manipulation and logical decision-making in various computing tasks.