Instructions:
You are encouraged to work on the problem set in groups and turn in
one problem set for the entire group. Remember to put all your names on
the solution sheet. Also remember to put the name of the TA in whose discussion
section you would like the problem set returned to you.
The following program computes the square (k*k) of a positive integer k, stored in location 0x4000 and stores the result in location 0x4002. The result is to be treated as a 16-bit unsigned number.
Assumptions:
.ORIG X3000 AND R0, R0, #0 LEA R3, NUM LDW R3, R3, #0 LDW R1, R3, #0 ADD R2, R1, #0 LOOP ADD R0, R0, R1 ADD R2, R2, #-1 BRP LOOP STW R0, R3, #1 HALT NUM .FILL x4000 .END
Assembler Formats
ADDM DR, SR1, SR2
ADDM DR, SR1, imm5
Encodings
Operation
if (bit[5] == 0) DR = Memory[SR1] + SR2; else DR = Memory[SR1] + SEXT(imm5); setcc(DR);
for(i = 0; i < 8; ++i){ for(j = 0; j < 8; ++j){ sum = sum + A[i][j]; } }The figure below shows an 8-way interleaved, byte-addressable memory. The total size of the memory is 4KB. The elements of the 2-dimensional array, A, are 4-bytes in length and are stored in the memory in column-major order (i.e., columns of A are stored in consecutive memory locations) as shown. The width of the bus is 32 bits, and each memory access takes 10 cycles.
A more detailed picture of the memory chips in Row 0 of Bank 0 is shown below.
Addr[_____:_____]
Addr[_____:_____]
Addr[_____:_____]
Addr[_____:_____]
Construct the truth table to implement the LOGIC block, having inputs SIZE, R/W,
1st or 2nd access, PHYS_ADDR[1:0] and the outputs shown in the above figure. Assume
that the value of SIZE can be Byte (00), HalfWord (01), and Word (10). Clearly
explain what function each output serves.