We are told that the command add $7, $15, $31 is located at address 0xFFFF0000 in the main memory. Additionally, it is given that the registers are initialized with values equal to their register number multiplied by 8888 (for example, register 1 has a value of 8888, register 2 has a value of 17776, register 3 has a value of 26664, and so on).
The command is executed on the MIPS processor shown in the following diagram.
In this diagram, three NEG components have been added, which perform a two’s complement (sign reversal):
One NEG component at the output of the PC+4 adder.
A second NEG component at the output of Read Data 1 from the register file.
A third NEG component at the lower input (connected to 0) of the MemtoReg multiplexer.
There are 10 markings, S1 to S10. You are required to write the values passing through the marked lines in hexadecimal (base 16).
Assume that the information is checked at the end of the clock cycle while executing the add $7, $15, $31 command.
Unknown values should be marked as X. The S3 marking is for the 32 bits of the jump target.
Present all your answers in hexadecimal (base 16).
the result i got is:
S1 = 0xFFFF0000 (PC)
S2 = 0x01F7C020 (Instruction: add $7, $15, $31)
S3 = X (Not used for this instruction)
S4 = 0x0000FFFC (PC + 4 after NEG)
S5 (Read Data 1) = 0x33340, S5 (Read Data 2) = 0x1B108
S6 (ALU Input 1) = 0x33340, S6 (ALU Input 2) = 0x1B108
S7 = 0x4E448 (ALU Result)
S8 = X (Not used for this instruction)
S9 = X (Not used for this instruction)
S10 = 0xB1BB8 (Write back result after NEG)
but i am not sure it is correct
any suggestions?
2
S1
— asking for the “Next PC”, i.e. input to the PC register for the next clock cycle, rather than for the existing PC. Thus, you have to trace from 0xFFFF0000 (existing PC) through the PC+4..NEG..S4.. path to find the value.
S2
— you have encoded add $24,$15,$23, so typo somewhere.
S3
— while it is true that the S3
path (value) is ignored for this instruction, since S3
only applies to Jump instructions — however, let’s note that the value there is not unknown — it can be exactly computed!
S4
— agree.
S5
— read data 1 comes from the register named by rs
, here that is $15, because add rd=$7, rs=$15, rt=$31
. So, we would expect 8888*15 in $15, and after the odd negation inserted, then the 2’s complement of that.
S6
— this is the ALU output, so have to compute the $31 value (this one not negated, of course), and add to the S5
value.
S7
— this is the ALU control signal. That is a 4 (or maybe 5) bit signal and should indicate a code for addition
. You’ll have to consult your other material to find the value for that.
S8
— this is the Write Data, which comes from Read Data 2, aka the value in register the rt
register field. Yes, not used for this instruction since it is not a store — but still the value can be exactly computed.
S9
— This value is not only unused for this instruction, but we cannot even compute what it might be since it represents a read from memory that doesn’t happen. So, yes, unknown. (Possibly deterministic if you know the prior read instructions.)
S10
— the negated S6
value (ALU output), if you started with the correct value for that.