1

enter image description hereThis is my first post here and I'm glad to join this great community and I hope to learn a lot here and help if I can(though i am a very beginner).

I have a theoretical question:

I am trying to add to the single cycle datapath the following command jm IMM($rs), that will, using address in the command, will jump by the value of a word taken from the data memory. (the offset is 16 bits)

So basically the result will be: j MEM[$rs+ sign extend(IMM)].

My question is: Is it actually possible to increase/extend the offset(add/imm) in the given command? If so, what's necessary to implement it?

From what I understand, loading a word from an effective address($rs + offset) is actually quite similar to 'lw', whereas in lw we would put it in the register, but I think that now the we need to put it in the pc.

Would really appreciate learning from your explanations.

Edit: Another question rose when I looked at it. if i want to fill the details in the table for jmp(the bottom one) - Does the values remain the same as for J or do you you calculate using the offset? would really be interested in understanding this.

csnoobie
  • 21
  • 2
  • This would depend entirely on what kind of architecture you were trying to add it to, what the data paths were, available ALU resources, etc. Do you have an architecture diagram or similar we could work from? – Jules Aug 22 '18 at 21:07
  • At the very least, the timing constraints for fetching from memory and adding an offset in a single cycle would be tricky in most circumstances, but again that depends on your existing implementation. – Jules Aug 22 '18 at 21:09
  • typically, jump instructions take the effective address of the addressing mode (more like an `lea` (load effective address) rather than the word from memory, though you could certainly load the word from memory into the pc. It should be possible to extend the range of the immediate as follows: zero extend it to get a bit more positive range at the expense of negative ranges; assume the location is word aligned, so shift the immediate left by 1 before using it: that will by another bit at the expense of addressing odd bytes. – Erik Eidt Aug 22 '18 at 21:11
  • @Jules: i didn't know how to upload an image here. adding it now. thank you very much for your comments – csnoobie Aug 22 '18 at 22:16

1 Answers1

2

Your architecture doesn't have a direct path from memory to the PC - the only thing that can be done with the result of a memory read is storing it in a register.

In order to implement an indirect jump, you'd need to add a path from memory to the data path that is used to update the program counter. That's quite simply achieved by adding an additional mux after the two that are already on the return path to PC (running back at the top of the diagram), with its additional input coming from the memory read line.

Regarding extending the range, it is worth noting that your instruction format has two 4-bit fields to select registers, but only one of those is actually used by such an instruction. By adding an alternative path around the 'sign extend' block going to the bottom entry of the ALU you could provide an option to use those 4 bits as part of the immediate offset, thus allowing 20 bit offsets rather than 16 for this instruction, which would allow a substantial amount of additional range (+/- 512KiB rather than +/- 32KiB with the existing arrangement).

Jules
  • 17,614
  • 2
  • 33
  • 63
  • thanks for very much for your answer. so if i'm trying to fill the last row of the table(the jm, below the j), basically the j values are the same as the jm? – csnoobie Aug 23 '18 at 07:24