i. Draw a diagram of bus system using MUX which has four registers of size 4 bits each. ii. Evaluate the arithmetic statement X = A + B * [C * D + E * (F + G)] using a stack organized computer with zero address operation instructions.
i. Draw a diagram of bus system using MUX which has four registers of size 4 bits each. ii. Evaluate the arithmetic statement X = A + B * [C * D + E * (F + G)] using a stack organized computer with zero address operation instructions.
Quick answer
There are four registers A, B, C and D, each of 4 bits. The bus is also 4 bits wide. We need one 4-to-1 multiplexer for each bit, so four multiplexers are used. Bit 0 of every register goes to MUX 0, bit 1 goes to MUX 1, and so on. Two select lines $S_1S_0$ are common to all the multiplexers. They choose which register is placed on the bus.
(i) Bus system using multiplexers
A3..A0 B3..B0 C3..C0 D3..D0
| | | |
v v v v
+------------------------------------+
| MUX 3 | MUX 2 | MUX 1 | MUX 0 | <- S1 S0
+------------------------------------+
| 4-bit common bus |
v v
(loaded into any register by its LOAD input)
The select value 00 chooses A, 01 chooses B, 10 chooses C and 11 chooses D. The bus output is then loaded into a destination register by enabling its load input at a clock pulse. For example, with $S_1S_0 = 10$ and the load input of A enabled, the transfer $A \leftarrow C$ takes place at the next clock edge. The same bus can be used for any transfer between the four registers, but only one transfer can happen in one clock pulse.
(ii) Evaluating X = A + B * [C * D + E * (F + G)]
In a stack computer, every arithmetic instruction takes its operands from the top of the stack, so it needs no address. First we write the expression in reverse Polish notation. The conversion is checked with a program.
$$ABCDEFG++*+$$
Then we scan it from left to right. A letter becomes a PUSH instruction. An operator becomes one instruction without an operand. The program is:
| Instruction | Stack after it (top on the right) |
|---|---|
| PUSH A | A |
| PUSH B | A, B |
| PUSH C | A, B, C |
| PUSH D | A, B, C, D |
| MUL | A, B, (C*D) |
| PUSH E | A, B, (C*D), E |
| PUSH F | A, B, (C*D), E, F |
| PUSH G | A, B, (C*D), E, F, G |
| ADD | A, B, (C*D), E, (F+G) |
| MUL | A, B, (CD), (E(F+G)) |
| ADD | A, B, (CD+E(F+G)) |
| MUL | A, (B*[...]) |
| ADD | (A+B*[...]) |
| POP X | empty, X holds the result |
The program needs 14 instructions. The last instruction stores the result at location X.
As a check, let $A=1, B=2, C=3, D=4, E=5, F=6, G=7$. The stack program computes $CD = 12$, $F+G = 13$, $E13 = 65$, then $12 + 65 = 77$, then $B * 77 = 154$, and finally $A + 154 = 155$. The direct calculation of the expression also gives 155, so the program is correct.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.
Up nextExplain in detail the principle of carry look ahead adder and design 4-bit CLA adder.