D = A AND B + C OR D
where A, B, C, and D are four memory locations storing four numbers.
There are two kinds of machines to compute this function. One machine, machine M1, uses the following kind of instructions in which X, A, and B are memory location addresses.
ADD X,A,B /* ADD values of A and B and store into X */
AND X,A,B /* AND values of A and B and store into X */
OR X,A,B /* OR values of A and B and store into X */
When an instruction is fetched, the operation code and the three addresses are stored in registers I0, I1, I2, and I3, respectively. A total of four memory reads are needed to get the instruction itself. The operands are fetched using the addresses in the registers I1 and I2, and I3 and the result is written back using the destination address in register I3.
In the second machine, machine M2, the instructions are of the type
LD R5, A /* Load contents of memory location into register R5 */
ST R5, A /* Store contents of memory location into register R5 */
ADD R3, R4, R5 /* Add contents of registers R4 and R5 and store it into register R3 */
AND R3, R4, R5 /* And contents of registers R4 and R5 and store it into register R3 */
OR R3, R4, R5 /* OR contents of registers R4 and R5 and store it into register R3 */
In LD and ST instructions, a total of two memory locations are read just to fetch an instruction. The address of memory location is first stored into register I1 and then contents of that location are read or written into/from the register. The operation code and the other information like register addresses etc. are stored in register I0.
Write two programs for the above expression, one for each machine. You can assume that there exists operations to read an instruction, which reads all the required information from the program memory and stores them in appropriate registers. Register I0, I1, I2, and I3 are part of register file. It takes four clock cycles to read an instruction in machine M1 and two cycles to read an instruction in machine M2. How many memory locations will be read to fetch instructions, to fetch data, and write results in each case. Write micro sequences for each of the machine instructions in the two sequences for the data path shown below. You can use register R0 and R1 for temporary use. You can use micro sequence instruction like given below.
Fetch an instruction
Transfer I1 into Addr register
Read memory and transfer data into register R1
