cpu-architectureriscvinstruction-set

Why there are many instructions with zero destination that not affectting the hardware in RISC-V ISA?


The first register is hardware zero in RISC-V ISA. It is used in many cases such as calling zero to another register, and jumping but not storing the address, etc. However, there are many possibilities that don't change the hardware when the destination register is zero and we don't need those possible instructions because they are not used for any porpuse. I feel it is wasting the bits for other functional instructions. What am I missing in this issue? Why it is so? As I know, the bits in ISA are expensive so ISA developers try to keep them as simple and compressed as possible to cover many different functionalities. However, it makes me feel the reverse because of many instructions that use the destination with the first register that is hardwired to zero.

I don't know if they are reserved for future usage or if the first register (x0) can be used without hardwiring zero.


Solution

  • One question the original designers were concerned with answering is: what will cost less hardware for a small embedded system? Having useless instructions like add x0, x0, x0 or even add x0, a0, a1?  Or doing something useful with those otherwise useless encoding?  And the answer is the former, to the question of what will take less hardware.

    Another is: what will allow the most common (and also useful) instructions to execute as quickly as possible.  Decoding and add x0, x0, x0, or, add x0, a0, a1, so that it will do something different (from no-op) can slow down the useful add instructions as follows: while some of that decoding can happen in parallel (with added hardware), ultimately, the two paths, decoding add x0, a0, a1 and decoding a normal add a0, a0, a1 have to merge and that generally happens with muxes.  The more muxes that are introduced, the longer the cycle has to be, so doing that has the effect of slowing down the whole processor.


    The designers of RISC V went to lengths to remove one mux from the decode phase as compared to MIPS, by keeping the target register field in a fixed position for both R- and I-Type instructions.