Hello Stack exchange community
I was wondering which modification should I have to make in order to enable single-cycle MIPS processor to run a jal(jump and link) command?
My most pressing confusion relating to this command is that I can't figure out a way to derive the address of the next instruction and how to connect it to PC counter.
I would really appreciate if anyone can provide me with some insights concerning this issue.
-
3\$\begingroup\$ This smells like unattempted homework... if it's not, you'll have no difficulty to explain the exact technology in which you plan to implement this. \$\endgroup\$Chris Stratton– Chris Stratton2020年12月03日 21:21:50 +00:00Commented Dec 3, 2020 at 21:21
1 Answer 1
Without giving the solution I can help you to figure out how you can get it.
The instruction jal (jump and link) is an unconditional branch where we consider a specified address (label) in the instruction code to be applied to PC.
What you must do:
- jal must be considered in the decoder in order to get a signal telling that jal is to be executed. You have something to add here:
- The multiplexer applied to PC has initially two inputs. First input for non-branching instructions: PC+4 and second input in the case of a "branch if equal": 16-bit offset in the instruction code, we extend the sign ( to have a 32-bit address offset), we multiply it by 4 (<<2) to get it byte-addressed and we add it to PC+4. The multiplexer now must consider an additional input composed from a part of the instruction (the label coded in the instruction), higher 4 bits of PC + 4, and alignment consideration to 32-bit. You have to add something here:
- Jal must also write PC+4 to the register 31ドル ($ra) which holds the return address if applied. So, you have also to add something here:
-
\$\begingroup\$ I guess, now I have an idea how to implement this, thanks for the insights Paul. \$\endgroup\$Amir– Amir2020年12月04日 11:18:21 +00:00Commented Dec 4, 2020 at 11:18
-
\$\begingroup\$ Is it any other necessary modifications needed to make in order to implement instructions such as "addi"," ori", "andi" and "slti"? I reckon that the current one should would work fine. \$\endgroup\$Amir– Amir2020年12月04日 12:01:53 +00:00Commented Dec 4, 2020 at 12:01
-
\$\begingroup\$ These instructions need to use ALU and does not directly concern PC so it is another problem. \$\endgroup\$Paul Ghobril– Paul Ghobril2020年12月04日 12:03:53 +00:00Commented Dec 4, 2020 at 12:03
-
\$\begingroup\$ by the way ALUOp is already implemented and executes the mentioned instructions \$\endgroup\$Paul Ghobril– Paul Ghobril2020年12月04日 12:15:14 +00:00Commented Dec 4, 2020 at 12:15
-
\$\begingroup\$ Yes, that's what I thought. Thanks for your guidance! \$\endgroup\$Amir– Amir2020年12月04日 12:39:12 +00:00Commented Dec 4, 2020 at 12:39
Explore related questions
See similar questions with these tags.