Skip to content

Latest commit

 

History

History
693 lines (555 loc) · 19.1 KB

Hardware.md

File metadata and controls

693 lines (555 loc) · 19.1 KB

↩ Return

Hardware


Logic Gates


Nand

Relay (Default on)
x y x < y
0 0 0
0 1 1
1 0 0
1 1 0
graph BT;
    X((X))-->R(Relay);
    Y((Y))-->R;
    R-->O((out))

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relay1 fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X, in1
	class Y, in2
	class O, out1
    class R relay1
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0 stroke:blue,color:blue
	linkStyle 1 stroke:red,color:red
	linkStyle 2 stroke:red,color:red
Loading

y x y < x
0 0 0
1 0 0
0 1 1
1 1 0
graph BT;
    Y((Y))-->R(Relay);
    X((X))-->R;
    R-->O((out))

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relay1 fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class Y, in1
	class X, in2
	class O, out1
    class R relay1
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0 stroke:blue,color:blue
	linkStyle 1 stroke:red,color:red
	linkStyle 2 stroke:red,color:red
Loading

x 1 !x
0 1 1
0 1 1
1 1 0
1 1 0
graph BT;
    X((X))-->R(Relay);
    One((1))-->R;
    R-->O((out))

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relay1 fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X, in1
	class One, in2
	class O, out1
    class R relay1
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0 stroke:blue,color:blue
	linkStyle 1 stroke:red,color:red
	linkStyle 2 stroke:red,color:red
Loading

y 1 !y
0 1 1
0 1 0
1 1 1
1 1 0
graph BT;
    Y((Y))-->R(Relay);
    One((1))-->R;
    R-->O((out))

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relay1 fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class Y, in1
	class One, in2
	class O, out1
    class R relay1
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0 stroke:blue,color:blue
	linkStyle 1 stroke:red,color:red
	linkStyle 2 stroke:red,color:red
Loading

Relay (Default off)
x y x & y
0 0 0
0 1 0
1 0 0
1 1 1
graph BT;
    X((X))-->R(Relay);
    Y((Y))-->R;
    R-->O((out))

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relay1 fill:#f66,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X, in1
	class Y, in2
	class O, out1
    class R relay1
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0 stroke:blue,color:blue
	linkStyle 1 stroke:red,color:red
	linkStyle 2 stroke:grey,color:grey
Loading

Solutions:
  • !( !y < x )
y 1 !y x r < x 1 !r
0 1 1 0 0 1 1
1 1 0 0 0 1 1
0 1 1 1 0 1 1
1 1 0 1 1 1 0
graph LR;
	Y((Y))--0\n1\n0\n1-->R1(Relay);
	One((1))--1\n1\n1\n1-->R1;
    X((X))--0\n0\n1\n1--->R2(Relay);
    R1--1\n0\n1\n0-->R2;
    R2--0\n0\n0\n1-->R3(Relay);
    R3--1\n1\n1\n0-->O((out));
	One((1))--1\n1\n1\n1-->R3;

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relayDefOn fill:#f66,stroke:#000,stroke-width:2px;
    classDef relayDefOff fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X in1
    class Y in1
    class One in2
    class O out1
    class R1,R2,R3 relayDefOff
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0,2 stroke:blue,color:black
	linkStyle 1,3,5,6 stroke:red,color:black,stroke-dasharray:8 3
	linkStyle 4 stroke:violet,color:black
	linkStyle 5 stroke:red,color:black
Loading
  • !( !x < y )
x 1 !x y r < y 1 !r
0 1 1 0 0 1 1
0 1 1 1 0 1 1
1 1 0 0 0 1 1
1 1 0 1 1 1 0
graph LR;
	X((X))--0\n0\n1\n1-->R1(Relay);
	One((1))--1\n1\n1\n1-->R1;
    Y((Y))--0\n1\n0\n1--->R2(Relay);
    R1--1\n1\n0\n0-->R2;
    R2--0\n0\n0\n1-->R3(Relay);
    R3--1\n1\n1\n0-->O((out));
	One((1))--1\n1\n1\n1-->R3;

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relayDefOn fill:#f66,stroke:#000,stroke-width:2px;
    classDef relayDefOff fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X in1
    class Y in1
    class One in2
    class O out1
    class R1,R2,R3 relayDefOff
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0,2 stroke:blue,color:black
	linkStyle 1,3,6 stroke:red,color:black,stroke-dasharray:8 3
	linkStyle 4 stroke:violet,color:black
	linkStyle 5 stroke:red,color:black
Loading
  • !( x & y )
x y x & y 1 !r
0 0 0 1 1
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
graph LR;
	X((X))--0\n0\n1\n1-->R1(Relay);
    Y((Y))--0\n1\n0\n1-->R1(Relay);
    R1--1\n1\n1\n0-->R2(Relay);
	One((1))--1\n1\n1\n1-->R1;
	One((1))--1\n1\n1\n1-->R2;
    R2--1\n1\n1\n0-->O((out));

	classDef in1 fill:#333,stroke:#000,stroke-width:2px,color:#55f,font-size:120%;
    classDef in2 fill:#333,stroke:#000,stroke-width:2px,color:#f55,font-size:120%;
    classDef out1 fill:#333,stroke:#000,stroke-width:2px,color:#aaa,font-size:90%;
    classDef relayDefOn fill:#f66,stroke:#000,stroke-width:2px;
    classDef relayDefOff fill:#66f,stroke:#000,stroke-width:2px;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X in1
    class Y in1
    class One in2
    class O out1
    class R2,R3 relayDefOff
    class R1 relayDefOn
	class I inv
	linkStyle default stroke-width:2px,fill:none,stroke:grey
	linkStyle 0,1 stroke:blue,color:black
	linkStyle 3,4 stroke:red,color:black,stroke-dasharray:8 3
	linkStyle 2 stroke:green,color:black
	linkStyle 5 stroke:red,color:black
Loading

Nand


Invert

x out
0 1 !x
1 0

not(x)x nand x

graph LR;
    X((X))--0\n1-->N(NAND);
    X-->N;
    N--1\n0-->O((out))
	classDef in1 fill:#ffff80ff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef out1 fill:#aeff73ff,stroke:#000,stroke-width:2px,font-size:90%;
    classDef nand fill:#222,stroke:#000,stroke-width:2px,color:#fff;
    class X, in1
	class O, out1
    class N nand
	linkStyle default stroke:red,color:black,stroke-width:2px,fill:none,stroke-head:red
Loading

Invert


And

x y out
0 0 0
0 1 0
1 0 0
1 1 1 x & y

x and y(x nand y) nand (x nand y)inv(x nand y)

graph LR;
    X((X))--0\n0\n1\n1-->N(NAND);
    Y((Y))--0\n1\n0\n1-->N;
    N--1\n1\n1\n0-->I{{Invert}};
	I--0\n0\n0\n1-->O((out))

	classDef in1 fill:#ffff80ff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef in2 fill:#00ffffff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef out1 fill:#aeff73ff,stroke:#000,stroke-width:2px,font-size:90%;
    classDef nand fill:#222,stroke:#000,stroke-width:2px,color:#fff;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X, in1
	class Y, in2
	class O, out1
    class N nand
	class I inv
	linkStyle default stroke:red,color:black,stroke-width:2px,fill:none
Loading
Scheme

And gate scheme

And


Or

x y out
0 0 0
0 1 1 !x & y
1 0 1 x & !y
1 1 1 x & y

(not(x) and y) or (x and not(y)) or (x and y)(x nand x) nand (y nand y)inv(x) nand inv(y)

graph LR;
    X((X))--0\n0\n1\n1-->I1{{Invert}}
	I1--1\n1\n0\n0-->N(NAND)
    Y((Y))--0\n1\n0\n1-->I2{{Invert}}
	I2--1\n0\n1\n0-->N(NAND)
    N--0\n1\n1\n1-->O((out))

	classDef in1 fill:#ffff80ff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef in2 fill:#00ffffff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef out1 fill:#aeff73ff,stroke:#000,stroke-width:2px,font-size:90%;
    classDef nand fill:#222,stroke:#000,stroke-width:2px,color:#fff;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    class X in1
	class Y in2
	class O out1
    class N nand
	class I1,I2 inv
	linkStyle default stroke:red,color:black,stroke-width:2px,fill:none
Loading

Or


Base gates

Base gates


Xor

x y out
0 0 0
0 1 1 !x & y
1 0 1 x & !y
1 1 0
  • Solution #1 (not(x) and y) or (x and not(y))((x nand y) nand x) nand ((x nand y) nand y)
graph LR;
    X((X))--->N1([NAND])
    Y((Y))--0\n1\n0\n1--->N2([NAND])
    X((X))--0\n0\n1\n1--->N2
    Y((Y))--->N3([NAND])
	N2--1\n1\n1\n0-->N1
	N2--1\n1\n1\n0-->N3
	N1--1\n1\n0\n1-->N4([NAND])
	N3--1\n0\n1\n1-->N4
    N4--0\n1\n1\n0-->O((out))

	classDef in1 fill:#ffff80ff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef in2 fill:#00ffffff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef out1 fill:#aeff73ff,stroke:#000,stroke-width:2px,font-size:90%;
    classDef nand fill:#222,stroke:#000,stroke-width:2px,color:#fff;
    class X in1
	class Y in2
	class O out1
    class N1,N2,N3,N4 nand
	linkStyle default stroke:red,color:black,stroke-width:2px,fill:none
	linkStyle 0,2 stroke:yellow,color:black,stroke-width:2px,fill:none
	linkStyle 1,3 stroke:blue,color:black,stroke-width:2px,fill:none
	linkStyle 5,4 stroke:green,color:black,stroke-width:2px,fill:none
Loading
The simplest possible solution

Xor gate scheme

Xor

  • Solution #2
x y x ^ y x | y r1 & r2
0 0 0 1 0
0 1 1 1 1
1 0 1 1 1
1 1 1 0 0

(x nand y) and (x or y)

Scheme

And gate scheme

graph LR;
    X((X))--0\n0\n1\n1--->N1([NAND])
    Y((Y))--0\n1\n0\n1--->N1
    X((X))--0\n0\n1\n1--->Or1
    Y((Y))--0\n1\n0\n1--->Or1
	N1--1\n1\n1\n0-->And1([AND])
	Or1([OR])--0\n1\n1\n1-->And1
    And1--0\n1\n1\n0-->O((out))

	classDef in1 fill:#ffff80ff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef in2 fill:#00ffffff,stroke:#000,stroke-width:2px,font-size:130%;
    classDef out1 fill:#aeff73ff,stroke:#000,stroke-width:2px,font-size:90%;
    classDef nand fill:#222,stroke:#000,stroke-width:2px,color:#fff;
    classDef inv fill:#f55,stroke:#000,stroke-width:2px;
    classDef or fill:#fa1,stroke:#000,stroke-width:2px;
    classDef and fill:#f55,stroke:#000,stroke-width:2px;
    class X in1
	class Y in2
	class O out1
    class N1 nand
	class Or1 or
	class And1 and
	linkStyle default stroke:red,color:black,stroke-width:2px,fill:none
	linkStyle 0,2 stroke:yellow,color:black,stroke-width:2px,fill:none
	linkStyle 1,3 stroke:blue,color:black,stroke-width:2px,fill:none
	linkStyle 5,4 stroke:green,color:black,stroke-width:2px,fill:none
Loading

Full True Table

True Table


Arithmetics


Half Adder

a b h l high low
0 0 0 0
0 1 0 1 !a & b
1 0 0 1 a & !b
1 1 1 0 a & b
h = a and b
l = a xor b

Half Adder


Full Adder

a b c high low high low
0 0 0 0 1 !a & !b & !c
0 0 1 0 1 !a & !b & c
0 1 0 0 1 !a & b & !c
0 1 1 1 0 !a & b & c
1 0 0 0 1 a & !b & !c
1 0 1 1 0 a & !b & c
1 1 0 1 0 a & b & !c
1 1 1 1 1 a & b & c a & b & c
h = (not(a) and b and c) or (a and not(b) and c) or (a and b and not(c)) or (a and b and c)
l = (not(a) and not(b) and not(c)) or (not(a) and not(b) and c) or (not(a) and b and not(c)) or (a and not(b) and not(c)) or (a and b and c)

Full Adder Full Adder


Multi-bit Adder

Multi-bit Adder


Increment

Increment


Subtraction

Subtraction


Equal to Zero

Equal to Zero


Less than Zero

Less than Zero


Switching


Selector

Selector


Switch

Switch


Arithmetic Logic Unit


Logic Unit

Logic Unit


Arithmetic Unit

Arithmetic Unit


ALU

ALU


Condition

Condition


Memory


Latch

Latch


Data Flip-Flop

Data Flip-Flop


Register

Register


Counter

Counter


RAM

RAM


Processor


Combined Memory

Combined Memory


Instruction

Instruction


Control Unit

Control Unit


Computer

Computer


Input and Output

Input and Output