2

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?

Dan
  • 2,694
  • 1
  • 6
  • 19

2 Answers2

1

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.

hobbs
  • 223,387
  • 19
  • 210
  • 288
-1

Not every instruction. Many of the instructions you use while writing are actually a combination of simpler instructions (mov, add, sub, mul. etc.). But yes, most of them are implemented with logic gates.

Kshitij Joshi
  • 137
  • 1
  • 10
  • Thank you, would you know of other common method which get used to implement other instructions? – Dan Jul 27 '21 at 03:27
  • As far as I know, these are the only two methods, but I am not very sure. – Kshitij Joshi Jul 27 '21 at 03:34
  • Are you talking about pseudo-instructions, e.g. MIPS `li $t0, 0x12345678` that assembles to `lui` + `addiu`? That's not a *cpu* instruction, it's an assembly source-level pseudo-instruciton. – Peter Cordes Aug 03 '21 at 02:17