CPU中的控制信号

控制信号常见答疑

About Extop

https://stackoverflow.com/questions/55290060/what-does-extend-immediate-to-32-bits-mean-in-mips

I-type instructions with 16-bit immediates are different.

  • addi / addiu immediates are sign-extended (by duplicating the top/sign bit of the immediate to all higher bits). https://en.wikipedia.org/wiki/Two%27s_complement#Sign_extension This allows 2’s complement numbers from -2^15 .. +2^15-1 to be encoded. (0xFFFF8000 to 0x00007FFF)
  • ori/andi/xori boolean immediates are zero-extended (by setting all higher bits to zero) This allows unsigned / 2’s complement numbers from 0 .. 2^16-1 to be encoded. (0x00000000 to 0x0000FFFF)

For other instructions see this [instruction-set reference](https://web.cse.ohio-state.edu/~crawfis.3/cse675-02/Slides/MIPS Instruction Set.pdf) which breaks down each instruction showing 016 || [I15..0] for zero-extension or [I15]16 || [I15..0] for sign-extension.

And usually you don’t want to raise an exception on signed overflow, so normally compilers use addu / addiu even on signed integers. addiu is badly named: it’s not “for unsigned integers”, it’s just a wrapping-allowed / never-faulting version of add/addi. It sort of makes sense if you think of C, where signed overflow is undefined behaviour (and thus could use add and raise an exception in that case if the compiler wanted to implement it that way), but unsigned integers have well-defined overflow behaviour: base 2 wraparound.

可以为X的控制信号

  • 控制数据来源的信号(RegDstMemtoReg)等,不需要用到时可以为X。
  • 控制是否执行某操作(RegWrite)等,必须为0/1。
Built with Hugo
Theme Stack designed by Jimmy
visitors: total visits: time(s) reads: time(s)