Electronic – Clock signal purpose

clock

I'm a mechE and have been trying to get into the digital world for a bit and need to know why a system would need a clock signal at all. For example, if I have some bit of code getting executed on a device, why can't the logic gates performing code be controlled by logic such as this, "this gate does not open until I receive voltage here:"? and so on. Why does it need to operate by "this gate opens after so many clock signals"?

Thanks

Best Answer

A lot of digital logic, so-called "combinational" logic, indeed does not require a clock. Typically, a clock is used when some value needs to be stored, using what's called a latch or a flip-flop. The clock fixes the time at which the old value is discarded and the new value is accepted. This enables us to guarantee that a new value isn't accepted until all the combinational logic producing that value has "settled", i.e. all changes have propagated from the inputs to the output and the output will not change again.

Clocks are also used to help synchronize a signal, when sending data between two places, i.e. between one device and another. The receiving device can use the clock as a reference to determine when it's time to read the next bit/value. It's possible to transmit data without an explicit clock, but the clock makes decoding the signal easier.

This is in fact also true in the case of digital logic circuits -- it's possible to make complex circuitry without using clock signals, but the clock signals make it much easier. In this case, though, it's extremely difficult to go without a clock; in practice, at present nobody does it except in experimental work. There is a history of "asynchronous" (clockless) computing here: https://en.wikipedia.org/wiki/Asynchronous_circuit -- as far as I know, everything listed there is experimental. Quoting:

"An asynchronous circuit, or self-timed circuit, is a sequential digital logic circuit which is not governed by a clock circuit or global clock signal. Instead it often uses signals that indicate completion of instructions and operations, specified by simple data transfer protocols. This type of circuit is contrasted with synchronous circuits, in which changes to the signal values in the circuit are triggered by repetitive pulses called a clock signal. Most digital devices today use synchronous circuits. However asynchronous circuits have the potential to be faster, and may also have advantages in lower power consumption, lower electromagnetic interference, and better modularity in large systems. Asynchronous circuits are an active area of research in digital logic design."