Jump to content

AND Gate: Difference between revisions

From Logic World Wiki
add component infobox
mNo edit summary
 
(16 intermediate revisions by 2 users not shown)
Line 3: Line 3:
| id          = MHG.AndGate
| id          = MHG.AndGate
| caption    = AND gate with two inputs
| caption    = AND gate with two inputs
| minInputs   = 2
| configurable = 1
| maxInputs   = 4
| io.minInputs       = 2
| outputs     = 1
| io.maxInputs       = 4
| propagationDelay = 1
| io.outputs         = 1
| io.propagationDelay = 1
}}
}}


The '''AND gate''' is a basic digital logic component who's output will be active if '''all''' its inputs are active.
The '''AND Gate''' is a [[component]] used for [[digital logic]]. The AND Gate has one output and 2 to 4 inputs. The output will be {{on}} if and only if '''all''' of the inputs are {{on}}.


For a 2 input AND gate, it is 1 tile wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.
An AND Gate with two inputs [[Measurements|measures]] 1 tile wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.


An AND gate with 2 inputs will demonstrate the following behavior:
== Behavior ==
{| class="wikitable"
The AND Gate's output will only be active if all of its inputs are {{on}}. This is true no matter how many inputs the AND gate has.
|+AND Gate Truth Table
!INPUT A
!INPUT B
!OUTPUT
|-
|LOW
|LOW
|LOW
|-
|LOW
|HIGH
|LOW
|-
|HIGH
|LOW
|LOW
|-
|HIGH
|HIGH
|HIGH
|}


== Timing ==
<tabber>
The AND gate's output will only be active if all of its inputs are active. This is true no matter how many inputs the AND gate has.
|-|2 Inputs=
[[File:And gate activation delay.png|thumb|A demonstration of two AND gates being activated. The top AND gate has both its inputs active, but its output is not yet active because a delay of 1 tick has not yet passed. The bottom AND gate has had both its inputs active for at least 1 tick, and its output is therefore active.]]
{{Truth table auto
The AND gate has a latency of 1 tick, so in the instance when all inputs are active, the output will become active 1 tick later. As demonstrated in the example on the right.
| inputs=2
| outputs=1
| caption=AND Gate Truth Table (2 inputs)
| expr1=a & b
}}
|-|3 Inputs=
{{Truth table auto
| inputs=3
| outputs=1
| caption=AND Gate Truth Table (3 inputs)
| expr1=a & b & c
}}
|-|4 Inputs=
{{Truth table auto
| inputs=4
| outputs=1
| caption=AND Gate Truth Table (4 inputs)
| expr1=a & b & c & d
}}
</tabber>
 
The AND Gate takes one [[tick]] to update the state of its output after a change to the state of its inputs.


== Configurability ==
== Configurability ==
Pressing the edit button on an AND gate allows you to change the number of inputs it has. You can select 2, 3, or 4 inputs.


Changing the number of inputs on an AND gate does not change its latency, but it does make the components bigger, with their width changing from 1 tile wide with 2 inputs to a little less than 2 tiles wide with 3 inputs, to 2 tiles wide with 4 inputs.
Pressing the edit button on an AND Gate allows you to change the number of inputs it has. You can select 2, 3, or 4 inputs.
 
Changing the number of inputs on an AND Gate does not change its latency, but it does make the components bigger, with their width changing from 1 tile wide with 2 inputs to a little less than 2 tiles wide with 3 inputs, to 2 tiles wide with 4 inputs.
 
{{todo|image of the menu for editing AND Gates and the 3 vanilla varieties}}
 
The game can be modified to allow AND Gates with an unlimited number of inputs. {{todo|details of how to do this}} {{todo|image of an AND Gates with >4 inputs}}
 
== Placement ==
 
AND Gates with 2 or 3 inputs can be placed in the center of a [[Circuit Board]] square or on top of a [[Mount]], and can be fine-rotated.
 
AND Gates with 4 inputs (or more, if the game is modified to allow more inputs) have multiple attachment points, one for each square covered by the body of the component, and cannot be fine-rotated.
 
{{todo|image of different ways AND Gates can be placed}}


Note that when an AND gate has 3 inputs, while its width is less than 2 tiles, the component is centered on a tile, causing it to require 3 tiles of width.
{{Navbox components}}


Smaller components such as pegs and other 3 input AND gates can still occupy the adjacent tile. But other components that take up a full tile will need to be moved over.
[[Category:Vanilla components]]
[[Category:Circuitry components]]

Latest revision as of 22:53, 8 September 2025

AND gate

AND gate with two inputs
Component info
Internal ID MHG.AndGate
Configurable Yes
Input and output
Input count Adjustable from 2 to 4
Output count 1
Propagation delay 1 tick

The AND Gate is a component used for digital logic. The AND Gate has one output and 2 to 4 inputs. The output will be ON if and only if all of the inputs are ON.

An AND Gate with two inputs measures 1 tile wide and 1 tile tall, and its body is 1 tile long, but its inputs and outputs extend its area to 3 tiles.

Behavior

The AND Gate's output will only be active if all of its inputs are ON. This is true no matter how many inputs the AND gate has.

AND Gate Truth Table (2 inputs)
Input 1Input 2Output
000
010
100
111

AND Gate Truth Table (3 inputs)
Input 1Input 2Input 3Output
0000
0010
0100
0110
1000
1010
1100
1111

AND Gate Truth Table (4 inputs)
Input 1Input 2Input 3Input 4Output
00000
00010
00100
00110
01000
01010
01100
01110
10000
10010
10100
10110
11000
11010
11100
11111

The AND Gate takes one tick to update the state of its output after a change to the state of its inputs.

Configurability

Pressing the edit button on an AND Gate allows you to change the number of inputs it has. You can select 2, 3, or 4 inputs.

Changing the number of inputs on an AND Gate does not change its latency, but it does make the components bigger, with their width changing from 1 tile wide with 2 inputs to a little less than 2 tiles wide with 3 inputs, to 2 tiles wide with 4 inputs.


TODO: image of the menu for editing AND Gates and the 3 vanilla varieties

The game can be modified to allow AND Gates with an unlimited number of inputs. TODO: details of how to do this TODO: image of an AND Gates with >4 inputs

Placement

AND Gates with 2 or 3 inputs can be placed in the center of a Circuit Board square or on top of a Mount, and can be fine-rotated.

AND Gates with 4 inputs (or more, if the game is modified to allow more inputs) have multiple attachment points, one for each square covered by the body of the component, and cannot be fine-rotated.


TODO: image of different ways AND Gates can be placed