Search code examples
cpuinstruction-set

Is every cpu instruction implemented by logic gates at its core?


Is every operation done by the CPU implemented by simple logic gates such as AND, OR, XOR gates?

For example a half adder is implemented with an AND + XOR gate. What about:

  • The rest of the Arithmetic Logic Unit (subtraction, multiplication, div)
  • The floating point unit
  • Shift operations
  • More complex instructions such as counting leading zeros, bit rotation, etc.

Is every instruction implemented by combining logic gates?


Solution

  • Practically speaking, all of the digital operations on a chip are implemented as logic gates or ROM lookups (and a ROM is just some logic gates for the address decoder, plus some wires that either are or aren't present).

    And theoretically speaking, any boolean function can be implemented as logic gates. In fact, any boolean function of any number of arguments can be implemented using enough copies of just one logic gate.