BIT151 ยท 2080 ยท 5 marks
What is selective set logical operation? Draw the hardware circuit of selective set logical operation.
What is selective set logical operation? Draw the hardware circuit of selective set logical operation. [5]
Quick answer
Selective Set is a logical operation that uses the OR operation to selectively set (force to 1) specific bits of a register (operand A) based on a mask operand (operand B), while leaving the remaining bits unchanged.
Selective Set Logical Operation
Definition
- If a bit in the mask (B) = 1, the corresponding bit in the result is set to 1 (regardless of A).
- If a bit in the mask (B) = 0, the corresponding bit in the result remains unchanged (retains the value of A).
The operation is defined as:
$$A \leftarrow A \text{ OR } B$$
Key Principle
| A | B (Mask) | A OR B (Result) |
|---|---|---|
| 0 | 0 | 0 (unchanged) |
| 1 | 0 | 1 (unchanged) |
| 0 | 1 | 1 (set to 1) |
| 1 | 1 | 1 (set to 1) |
- Wherever B = 1, the bit is forced/set to 1.
- Wherever B = 0, the bit is left as it is.
Example
Let A = 1010 0110 and B (mask) = 0000 1111
A = 1010 0110
B = 0000 1111
---------
A OR B= 1010 1111
The lower 4 bits are all set to 1 by the mask.
Hardware Circuit of Selective Set Operation
The circuit uses OR gates for each bit position. Each OR gate takes one bit from register A and the corresponding bit from mask B as inputs.
Bit position: n-1 ... 1 0
| | |
A[n-1] --+--\ A[1] -+--\ A[0] -+--\
| OR --> R[n-1] | OR->R[1] | OR --> R[0]
B[n-1] --+--/ B[1] -+--/ B[0] -+--/
Detailed Single-Bit Circuit (for one bit position):
A[i] ----\
[OR Gate] -----> Result R[i]
B[i] ----/
Full n-bit Circuit Diagram:
A[n-1] ---| A[1] ---| A[0] ---|
| OR|-->R[n-1] | OR|-->R[1] | OR|-->R[0]
B[n-1] ---| B[1] ---| B[0] ---|
(Each bit position has one OR gate)
+-------+ +-------+ +-------+ +-------+
| A[n-1]| | A[2] | | A[1] | | A[0] |
+---+---+ +---+---+ +---+---+ +---+---+
| | | |
[OR] [OR] [OR] [OR]
| | | |
+---+---+ +---+---+ +---+---+ +---+---+
| B[n-1]| | B[2] | | B[1] | | B[0] |
+-------+ +-------+ +-------+ +-------+
| | | |
R[n-1] R[2] R[1] R[0]
Summary
| Feature | Detail |
|---|---|
| Operation | A OR B |
| Gate Used | OR Gate (one per bit) |
| Effect of B=1 | Sets corresponding bit to 1 |
| Effect of B=0 | Leaves corresponding bit as-is |
| Application | Setting specific bits in a register without disturbing others |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.