27 lines
4.2 KiB
Markdown
27 lines
4.2 KiB
Markdown
![]() |
# Logic Circuit
|
||
|
|
||
|
Logic circuits are circuits made of [logic gates](logic_gate.md) that implement [Boolean functions](bool.md), i.e. they are "schematics to process 1s and 0s". They are used to design [computers](computer.md). Logic circuits are a bit similar to electronic circuits but are a level of [abstraction](abstraction.md) higher: they don't work with continuous [voltages](voltage.md) but rather with [discrete](discrete.md) [binary](binary.md) logic values: 1s and 0s. Logical circuits can be designed and simulated with specialized software and languages such as [VHDL](vhdl.md).
|
||
|
|
||
|
Generally a logic circuit has *N* input bits and *M* output bits. Then we divide logic circuits into two main categories:
|
||
|
|
||
|
- **combinational**: The output values only depend on the input values, i.e. the circuit implements a pure mathematical [function](function.md). Behavior of such circuit can be described with a [truth table](truth_table.md), i.e. a table that for any combination of input values list their corresponding output.
|
||
|
- **sequential**: The output values generally depend on the input values and the internal state of the circuit, i.e. the circuit has a kind of [memory](memory.md) (it can be seen as a [finite state machine](finite_state_machine.md)). The internal state is normally implemented with so called [flip-flops](flip_flop.md) (logic gates that take as input their own output). Truth tables can't be used for describing these circuits. These circuits also often work with **[clock](clock.md)** synchronization, i.e. they have a specialized input called *clock* that periodically switches between 1 and 0 which drives the circuit's operation (this is where [overclocking](overclocking.md) comes from).
|
||
|
|
||
|
With logic circuits it is possible to implement any boolean function; [undecidability](undecidability.md) doesn't apply here as we're not dealing with [Turing machines](turing_machine.md) computations because the output always has a finite, fixed width, the computation can't end up in an infinite loop as there are no repeating steps, just a straightforward propagation of input values to the output. It is always possible to implement any function at least as a [look up table](lut.md) (which can be created with a [multiplexer](multiplexer.md)).
|
||
|
|
||
|
Once we've designed a logic circuit, we can [optimize](optimization.md) it which usually means making it use fewer logic gates, i.e. make it cheaper to manufacture (but optimization can also aim for other things, e.g. shortening the maximum length from input to output, i.e. minimizing the circuit's [delay](delay.md)). The optimization can be done with a number of techniques such as manual simplification of the circuit's logic expression or with [Karnaugh maps](karnaugh_map.md).
|
||
|
|
||
|
Some common logic circuits include:
|
||
|
|
||
|
- **[adder](adder.md)**: Performs addition. It has many parameters such as the bit width, optional carry output etc.
|
||
|
- **[multiplier](multiplier.md)**: Performs multiplication.
|
||
|
- **[multiplexer](multiplexer.md)** (mux): Has *M* address input bits plus another *2^M* data input bits. The output of the gate is the value of *N*th data bit where *N* is the number specified by the address input. I.e. the circuit selects one of its inputs and sends it to the output. This can be used to implement e.g. [memory](memory.md), [look up tables](lut.md), [bus](bus.md) arbiters and many more things.
|
||
|
- **[demultiplexer](demultiplexer.md)** (demux): Does the opposite of multiplexer, i.e. has one *M* address inputs and 1 data input and *2^M* outputs. Depending on the given address, the input is redirected to *N*th output (while other outputs are 0).
|
||
|
- **[decoder](decoder.md)**: Has *M* inputs and *2^M* outputs. It sets *N*th output to 1 (others are 0) where *N* is the binary number on the input. I.e. decoder converts a binary number into one specific signal. It can be implemented as a demultiplexer whose data input is always 1.
|
||
|
- **[encoder](encoder.md)**: Does the opposite of encoder, i.e. has *2^M* inputs and *M* outputs, expects exactly one of the inputs to be 1 and the rest 0s, the output is a binary number representing the input that's 1.
|
||
|
- **[ALU](alu.md)** (arithmetic logic unit): A more complex circuit capable of performing a number of logic and arithmetic operations. It is a part of a [CPU](cpu.md).
|
||
|
- TODO: more
|
||
|
|
||
|
## Example
|
||
|
|
||
|
TODO
|