Discussion:
Design
- Half words:
- Unsigned integers: The program was easily able to multiply and add unsigned integers.
- Maximum size of the matrix: The minimum size is 1×1 but as for the maximum, more details are provided in the first step of Design Considerations.
- Stack versus Heap: In our program, we have used heap to store data, even though the stack has many advantage’s as it provides faster access and better managed space. However, we decided to implement using heap instead because it give us more space and it is preferred when storing because it allows dynamic memory allocation.
- Coprocessor utilization: As can be seen from the list of registers used, the only modification caused by using coprocessor 1 was replacing certain integer registers with single precision FP registers. Within the code, the syscalls and instruction form changed as it dealt with single precision FP. The description of the program that follows, therefore, is identical with and without coprocessor utilization.
Design Considerations
There were several design choices that were made based on the following limitations:
- The data segment of memory in MIPS is 4MB. According to our decision to use just the data portion (to reserve memory), we determined the maximum allowable matrix size. 4MB is 32 million bits: this divided by 32 bits per element leaves 1,000,000 elements in data. Since there is other data stored in the memory besides the 2 matrices’ values, it is safe to assume the program’s data will occupy no more than a third of the space and to therefore estimate that 000 elements can theoretically be stored in each matrix, 1 and 2. In the demonstration attached, 80 was the space allotted for each matrix simply in order for the base addresses in memory of both matrices to be visible at the same time.
- Overflow and underflow while using integer inputs and calculations led us to use single precision floating point input and calculations. In the integer input, the largest integer the user can input is 2^31-1 and the smallest is 1×2^-126. These integers are given half-word (32 bit) space in the memory.
- Due to the above limitation, we implemented the matrix multiplication with single-precision input, which passes values into coprocessor 1 for multiplication and addition, and thereafter prints the result. It uses the exact same procedures except that it allows for larger integer calculations. Specifically, the maximum single-precision input is 1 × 10308, since the matrices are to perform integer operations. The limits of the input are communicated to the user.
- Exceptions should not halt the program. In our program we want to prevent errors and provide alternative code to satisfy exceptions. So our code will detect invalid inputs and the user should re enter the information.