Init nand2tetris

This commit is contained in:
Sven Riwoldt
2023-03-22 19:51:12 +01:00
commit 4c52d4ba55
496 changed files with 88269 additions and 0 deletions

BIN
projects/01/.DS_Store vendored Normal file

Binary file not shown.

5
projects/01/And.cmp Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

19
projects/01/And.hdl Normal file
View File

@@ -0,0 +1,19 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And.hdl
/**
* And gate:
* out = 1 if (a == 1 and b == 1)
* 0 otherwise
*/
CHIP And {
IN a, b;
OUT out;
PARTS:
Nand(a=a ,b=b ,out=nandout);
Not(in=nandout ,out=out);
}

5
projects/01/And.out Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

29
projects/01/And.tst Normal file
View File

@@ -0,0 +1,29 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And.tst
load And.hdl,
output-file And.out,
compare-to And.cmp,
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
set a 0,
set b 0,
eval,
output;
set a 0,
set b 1,
eval,
output;
set a 1,
set b 0,
eval,
output;
set a 1,
set b 1,
eval,
output;

7
projects/01/And16.cmp Normal file
View File

@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 0000000000000000 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 0000000000000000 |
| 0011110011000011 | 0000111111110000 | 0000110011000000 |
| 0001001000110100 | 1001100001110110 | 0001000000110100 |

18
projects/01/And16.hdl Normal file
View File

@@ -0,0 +1,18 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And16.hdl
/**
* 16-bit bitwise And:
* for i = 0..15: out[i] = (a[i] and b[i])
*/
CHIP And16 {
IN a[16], b[16];
OUT out[16];
PARTS:
Nand16(a=a,b=b,out=outnand);
Not16(in=outnand,out=out);
}

7
projects/01/And16.out Normal file
View File

@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 0000000000000000 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 0000000000000000 |
| 0011110011000011 | 0000111111110000 | 0000110011000000 |
| 0001001000110100 | 1001100001110110 | 0001000000110100 |

39
projects/01/And16.tst Normal file
View File

@@ -0,0 +1,39 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And16.tst
load And16.hdl,
output-file And16.out,
compare-to And16.cmp,
output-list a%B1.16.1 b%B1.16.1 out%B1.16.1;
set a %B0000000000000000,
set b %B0000000000000000,
eval,
output;
set a %B0000000000000000,
set b %B1111111111111111,
eval,
output;
set a %B1111111111111111,
set b %B1111111111111111,
eval,
output;
set a %B1010101010101010,
set b %B0101010101010101,
eval,
output;
set a %B0011110011000011,
set b %B0000111111110000,
eval,
output;
set a %B0001001000110100,
set b %B1001100001110110,
eval,
output;

5
projects/01/DMux.cmp Normal file
View File

@@ -0,0 +1,5 @@
| in | sel | a | b |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |

20
projects/01/DMux.hdl Normal file
View File

@@ -0,0 +1,20 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux.hdl
/**
* Demultiplexor:
* {a, b} = {in, 0} if sel == 0
* {0, in} if sel == 1
*/
CHIP DMux {
IN in, sel;
OUT a, b;
PARTS:
Not(in=sel, out=notsel);
And(a=in,b=notsel,out=a);
And(a=sel,b=in,out=b);
}

5
projects/01/DMux.out Normal file
View File

@@ -0,0 +1,5 @@
| in | sel | a | b |
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |

27
projects/01/DMux.tst Normal file
View File

@@ -0,0 +1,27 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux.tst
load DMux.hdl,
output-file DMux.out,
compare-to DMux.cmp,
output-list in%B3.1.3 sel%B3.1.3 a%B3.1.3 b%B3.1.3;
set in 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set in 1,
set sel 0,
eval,
output;
set sel 1,
eval,
output;

9
projects/01/DMux4Way.cmp Normal file
View File

@@ -0,0 +1,9 @@
| in | sel | a | b | c | d |
| 0 | 00 | 0 | 0 | 0 | 0 |
| 0 | 01 | 0 | 0 | 0 | 0 |
| 0 | 10 | 0 | 0 | 0 | 0 |
| 0 | 11 | 0 | 0 | 0 | 0 |
| 1 | 00 | 1 | 0 | 0 | 0 |
| 1 | 01 | 0 | 1 | 0 | 0 |
| 1 | 10 | 0 | 0 | 1 | 0 |
| 1 | 11 | 0 | 0 | 0 | 1 |

22
projects/01/DMux4Way.hdl Normal file
View File

@@ -0,0 +1,22 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux4Way.hdl
/**
* 4-way demultiplexor:
* {a, b, c, d} = {in, 0, 0, 0} if sel == 00
* {0, in, 0, 0} if sel == 01
* {0, 0, in, 0} if sel == 10
* {0, 0, 0, in} if sel == 11
*/
CHIP DMux4Way {
IN in, sel[2];
OUT a, b, c, d;
PARTS:
DMux(in=in, sel=sel[1], a=dmuxouta, b=dmuxoutb);
DMux(in=dmuxouta, sel=sel[0], a=a, b=b);
DMux(in=dmuxoutb, sel=sel[0], a=c, b=d);
}

9
projects/01/DMux4Way.out Normal file
View File

@@ -0,0 +1,9 @@
| in | sel | a | b | c | d |
| 0 | 00 | 0 | 0 | 0 | 0 |
| 0 | 01 | 0 | 0 | 0 | 0 |
| 0 | 10 | 0 | 0 | 0 | 0 |
| 0 | 11 | 0 | 0 | 0 | 0 |
| 1 | 00 | 1 | 0 | 0 | 0 |
| 1 | 01 | 0 | 1 | 0 | 0 |
| 1 | 10 | 0 | 0 | 1 | 0 |
| 1 | 11 | 0 | 0 | 0 | 1 |

43
projects/01/DMux4Way.tst Normal file
View File

@@ -0,0 +1,43 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux4Way.tst
load DMux4Way.hdl,
output-file DMux4Way.out,
compare-to DMux4Way.cmp,
output-list in%B2.1.2 sel%B2.2.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2;
set in 0,
set sel %B00,
eval,
output;
set sel %B01,
eval,
output;
set sel %B10,
eval,
output;
set sel %B11,
eval,
output;
set in 1,
set sel %B00,
eval,
output;
set sel %B01,
eval,
output;
set sel %B10,
eval,
output;
set sel %B11,
eval,
output;

17
projects/01/DMux8Way.cmp Normal file
View File

@@ -0,0 +1,17 @@
| in | sel | a | b | c | d | e | f | g | h |
| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
| 1 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |

23
projects/01/DMux8Way.hdl Normal file
View File

@@ -0,0 +1,23 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux8Way.hdl
/**
* 8-way demultiplexor:
* {a, b, c, d, e, f, g, h} = {in, 0, 0, 0, 0, 0, 0, 0} if sel == 000
* {0, in, 0, 0, 0, 0, 0, 0} if sel == 001
* etc.
* {0, 0, 0, 0, 0, 0, 0, in} if sel == 111
*/
CHIP DMux8Way {
IN in, sel[3];
OUT a, b, c, d, e, f, g, h;
PARTS:
DMux(in=in, sel=sel[2], a=dmuxouta, b=dmuxoutb);
DMux4Way(in=dmuxouta, sel=sel[0..1], a=a, b=b, c=c, d=d);
DMux4Way(in=dmuxoutb, sel=sel[0..1], a=e, b=f, c=g, d=h);
// Put your code here:
}

16
projects/01/DMux8Way.out Normal file
View File

@@ -0,0 +1,16 @@
| in | sel | a | b | c | d | e | f | g | h |
| 0 | 000 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 001 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 010 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 011 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 100 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 101 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 111 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 000 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 001 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 010 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 011 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
| 1 | 100 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| 1 | 101 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 1 | 110 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |

75
projects/01/DMux8Way.tst Normal file
View File

@@ -0,0 +1,75 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/DMux8Way.tst
load DMux8Way.hdl,
output-file DMux8Way.out,
compare-to DMux8Way.cmp,
output-list in%B2.1.2 sel%B2.3.2 a%B2.1.2 b%B2.1.2 c%B2.1.2 d%B2.1.2 e%B2.1.2 f%B2.1.2 g%B2.1.2 h%B2.1.2;
set in 0,
set sel %B000,
eval,
output;
set sel %B001,
eval,
output;
set sel %B010,
eval,
output;
set sel %B011,
eval,
output;
set sel %B100,
eval,
output;
set sel %B101,
eval,
output;
set sel %B110,
eval,
output;
set sel %B111,
eval,
output;
set in 1,
set sel %B000,
eval,
output;
set sel %B001,
eval,
output;
set sel %B010,
eval,
output;
set sel %B011,
eval,
output;
set sel %B100,
eval,
output;
set sel %B101,
eval,
output;
set sel %B110,
eval,
output;
set sel %B111,
eval,
output;

9
projects/01/Mux.cmp Normal file
View File

@@ -0,0 +1,9 @@
| a | b | sel | out |
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |

21
projects/01/Mux.hdl Normal file
View File

@@ -0,0 +1,21 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux.hdl
/**
* Multiplexor:
* out = a if sel == 0
* b otherwise
*/
CHIP Mux {
IN a, b, sel;
OUT out;
PARTS:
Not(in=sel,out=notsel);
And(a=a,b=notsel,out=outand1);
And(a=sel,b=b,out=outand2);
Or(a=outand1,b=outand2,out=out);
}

9
projects/01/Mux.out Normal file
View File

@@ -0,0 +1,9 @@
| a | b | sel | out |
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |

49
projects/01/Mux.tst Normal file
View File

@@ -0,0 +1,49 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux.tst
load Mux.hdl,
output-file Mux.out,
compare-to Mux.cmp,
output-list a%B3.1.3 b%B3.1.3 sel%B3.1.3 out%B3.1.3;
set a 0,
set b 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a 0,
set b 1,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a 1,
set b 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a 1,
set b 1,
set sel 0,
eval,
output;
set sel 1,
eval,
output;

9
projects/01/Mux16.cmp Normal file
View File

@@ -0,0 +1,9 @@
| a | b | sel | out |
| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 |
| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 |
| 1001100001110110 | 0000000000000000 | 1 | 0000000000000000 |
| 1010101010101010 | 0101010101010101 | 0 | 1010101010101010 |
| 1010101010101010 | 0101010101010101 | 1 | 0101010101010101 |

21
projects/01/Mux16.hdl Normal file
View File

@@ -0,0 +1,21 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux16.hdl
/**
* 16-bit multiplexor:
* for i = 0..15 out[i] = a[i] if sel == 0
* b[i] if sel == 1
*/
CHIP Mux16 {
IN a[16], b[16], sel;
OUT out[16];
PARTS:
Not(in=sel,out=notsel);
And16(a=a,b[0]=notsel,b[1]=notsel,b[2]=notsel,b[3]=notsel,b[4]=notsel,b[5]=notsel,b[6]=notsel,b[7]=notsel,b[8]=notsel,b[9]=notsel,b[10]=notsel,b[11]=notsel,b[12]=notsel,b[13]=notsel,b[14]=notsel,b[15]=notsel,out=outand1);
And16(a[0]=sel,a[1]=sel,a[2]=sel,a[3]=sel,a[4]=sel,a[5]=sel,a[6]=sel,a[7]=sel,a[8]=sel,a[9]=sel,a[10]=sel,a[11]=sel,a[12]=sel,a[13]=sel,a[14]=sel,a[15]=sel,b=b,out=outand2);
Or16(a=outand1,b=outand2,out=out);
}

6
projects/01/Mux16.out Normal file
View File

@@ -0,0 +1,6 @@
| a | b | sel | out |
| 0000000000000000 | 0000000000000000 | 0 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 1 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 0 | 0000000000000000 |
| 0000000000000000 | 0001001000110100 | 1 | 0001001000110100 |
| 1001100001110110 | 0000000000000000 | 0 | 1001100001110110 |

49
projects/01/Mux16.tst Normal file
View File

@@ -0,0 +1,49 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux16.tst
load Mux16.hdl,
output-file Mux16.out,
compare-to Mux16.cmp,
output-list a%B1.16.1 b%B1.16.1 sel%D2.1.2 out%B1.16.1;
set a 0,
set b 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a %B0000000000000000,
set b %B0001001000110100,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a %B1001100001110110,
set b %B0000000000000000,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set a %B1010101010101010,
set b %B0101010101010101,
set sel 0,
eval,
output;
set sel 1,
eval,
output;

View File

@@ -0,0 +1,9 @@
| a | b | c | d | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 |

22
projects/01/Mux4Way16.hdl Normal file
View File

@@ -0,0 +1,22 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux4Way16.hdl
/**
* 4-way 16-bit multiplexor:
* out = a if sel == 00
* b if sel == 01
* c if sel == 10
* d if sel == 11
*/
CHIP Mux4Way16 {
IN a[16], b[16], c[16], d[16], sel[2];
OUT out[16];
PARTS:
Mux16(a=a,b=b,sel=sel[0],out=mux16out1);
Mux16(a=c,b=d,sel=sel[0],out=mux16out2);
Mux16(a=mux16out1,b=mux16out2,sel=sel[1],out=out);
}

View File

@@ -0,0 +1,9 @@
| a | b | c | d | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 00 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 01 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 10 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 11 | 0000000000000000 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 00 | 0001001000110100 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 01 | 1001100001110110 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 10 | 1010101010101010 |
| 0001001000110100 | 1001100001110110 | 1010101010101010 | 0101010101010101 | 11 | 0101010101010101 |

49
projects/01/Mux4Way16.tst Normal file
View File

@@ -0,0 +1,49 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux4Way16.tst
load Mux4Way16.hdl,
output-file Mux4Way16.out,
compare-to Mux4Way16.cmp,
output-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 sel%B2.2.2 out%B1.16.1;
set a 0,
set b 0,
set c 0,
set d 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set sel 2,
eval,
output;
set sel 3,
eval,
output;
set a %B0001001000110100,
set b %B1001100001110110,
set c %B1010101010101010,
set d %B0101010101010101,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set sel 2,
eval,
output;
set sel 3,
eval,
output;

17
projects/01/Mux8Way16.cmp Normal file
View File

@@ -0,0 +1,17 @@
| a | b | c | d | e | f | g | h | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 |

24
projects/01/Mux8Way16.hdl Normal file
View File

@@ -0,0 +1,24 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux8Way16.hdl
/**
* 8-way 16-bit multiplexor:
* out = a if sel == 000
* b if sel == 001
* etc.
* h if sel == 111
*/
CHIP Mux8Way16 {
IN a[16], b[16], c[16], d[16],
e[16], f[16], g[16], h[16],
sel[3];
OUT out[16];
PARTS:
Mux4Way16(a=a,b=b,c=c,d=d,sel=sel[0..1],out=mux4way1);
Mux4Way16(a=e,b=f,c=g,d=h,sel=sel[0..1],out=mux4way2);
Mux16(a=mux4way1,b=mux4way2,sel=sel[2],out=out);
}

17
projects/01/Mux8Way16.out Normal file
View File

@@ -0,0 +1,17 @@
| a | b | c | d | e | f | g | h | sel | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 000 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 001 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 010 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 011 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 100 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 101 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 110 | 0000000000000000 |
| 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 0000000000000000 | 111 | 0000000000000000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 000 | 0001001000110100 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 001 | 0010001101000101 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 010 | 0011010001010110 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 011 | 0100010101100111 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 100 | 0101011001111000 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 101 | 0110011110001001 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 110 | 0111100010011010 |
| 0001001000110100 | 0010001101000101 | 0011010001010110 | 0100010101100111 | 0101011001111000 | 0110011110001001 | 0111100010011010 | 1000100110101011 | 111 | 1000100110101011 |

89
projects/01/Mux8Way16.tst Normal file
View File

@@ -0,0 +1,89 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Mux8Way16.tst
load Mux8Way16.hdl,
output-file Mux8Way16.out,
compare-to Mux8Way16.cmp,
output-list a%B1.16.1 b%B1.16.1 c%B1.16.1 d%B1.16.1 e%B1.16.1 f%B1.16.1 g%B1.16.1 h%B1.16.1 sel%B2.3.2 out%B1.16.1;
set a 0,
set b 0,
set c 0,
set d 0,
set e 0,
set f 0,
set g 0,
set h 0,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set sel 2,
eval,
output;
set sel 3,
eval,
output;
set sel 4,
eval,
output;
set sel 5,
eval,
output;
set sel 6,
eval,
output;
set sel 7,
eval,
output;
set a %B0001001000110100,
set b %B0010001101000101,
set c %B0011010001010110,
set d %B0100010101100111,
set e %B0101011001111000,
set f %B0110011110001001,
set g %B0111100010011010,
set h %B1000100110101011,
set sel 0,
eval,
output;
set sel 1,
eval,
output;
set sel 2,
eval,
output;
set sel 3,
eval,
output;
set sel 4,
eval,
output;
set sel 5,
eval,
output;
set sel 6,
eval,
output;
set sel 7,
eval,
output;

28
projects/01/Nand16.hdl Normal file
View File

@@ -0,0 +1,28 @@
/**
* 16-bit bitwise And:
* for i = 0..15: out[i] = (a[i] and b[i])
*/
CHIP Nand16 {
IN a[16], b[16];
OUT out[16];
PARTS:
Nand(a=a[0],b=b[0],out=out[0]);
Nand(a=a[1],b=b[1],out=out[1]);
Nand(a=a[2],b=b[2],out=out[2]);
Nand(a=a[3],b=b[3],out=out[3]);
Nand(a=a[4],b=b[4],out=out[4]);
Nand(a=a[5],b=b[5],out=out[5]);
Nand(a=a[6],b=b[6],out=out[6]);
Nand(a=a[7],b=b[7],out=out[7]);
Nand(a=a[8],b=b[8],out=out[8]);
Nand(a=a[9],b=b[9],out=out[9]);
Nand(a=a[10],b=b[10],out=out[10]);
Nand(a=a[11],b=b[11],out=out[11]);
Nand(a=a[12],b=b[12],out=out[12]);
Nand(a=a[13],b=b[13],out=out[13]);
Nand(a=a[14],b=b[14],out=out[14]);
Nand(a=a[15],b=b[15],out=out[15]);
}

3
projects/01/Not.cmp Normal file
View File

@@ -0,0 +1,3 @@
| in | out |
| 0 | 1 |
| 1 | 0 |

18
projects/01/Not.hdl Normal file
View File

@@ -0,0 +1,18 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not.hdl
/**
* Not gate:
* out = not in
*/
CHIP Not {
IN in;
OUT out;
PARTS:
Nand(a=in,b=in,out=out);
// Put your code here:
}

3
projects/01/Not.out Normal file
View File

@@ -0,0 +1,3 @@
| in | out |
| 0 | 1 |
| 1 | 0 |

17
projects/01/Not.tst Normal file
View File

@@ -0,0 +1,17 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not.tst
load Not.hdl,
output-file Not.out,
compare-to Not.cmp,
output-list in%B3.1.3 out%B3.1.3;
set in 0,
eval,
output;
set in 1,
eval,
output;

6
projects/01/Not16.cmp Normal file
View File

@@ -0,0 +1,6 @@
| in | out |
| 0000000000000000 | 1111111111111111 |
| 1111111111111111 | 0000000000000000 |
| 1010101010101010 | 0101010101010101 |
| 0011110011000011 | 1100001100111100 |
| 0001001000110100 | 1110110111001011 |

32
projects/01/Not16.hdl Normal file
View File

@@ -0,0 +1,32 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not16.hdl
/**
* 16-bit Not:
* for i=0..15: out[i] = not in[i]
*/
CHIP Not16 {
IN in[16];
OUT out[16];
PARTS:
Not(in=in[0],out=out[0]);
Not(in=in[1],out=out[1]);
Not(in=in[2],out=out[2]);
Not(in=in[3],out=out[3]);
Not(in=in[4],out=out[4]);
Not(in=in[5],out=out[5]);
Not(in=in[6],out=out[6]);
Not(in=in[7],out=out[7]);
Not(in=in[8],out=out[8]);
Not(in=in[9],out=out[9]);
Not(in=in[10],out=out[10]);
Not(in=in[11],out=out[11]);
Not(in=in[12],out=out[12]);
Not(in=in[13],out=out[13]);
Not(in=in[14],out=out[14]);
Not(in=in[15],out=out[15]);
}

6
projects/01/Not16.out Normal file
View File

@@ -0,0 +1,6 @@
| in | out |
| 0000000000000000 | 1111111111111111 |
| 1111111111111111 | 0000000000000000 |
| 1010101010101010 | 0101010101010101 |
| 0011110011000011 | 1100001100111100 |
| 0001001000110100 | 1110110111001011 |

29
projects/01/Not16.tst Normal file
View File

@@ -0,0 +1,29 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Not16.tst
load Not16.hdl,
output-file Not16.out,
compare-to Not16.cmp,
output-list in%B1.16.1 out%B1.16.1;
set in %B0000000000000000,
eval,
output;
set in %B1111111111111111,
eval,
output;
set in %B1010101010101010,
eval,
output;
set in %B0011110011000011,
eval,
output;
set in %B0001001000110100,
eval,
output;

5
projects/01/Or.cmp Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |

20
projects/01/Or.hdl Normal file
View File

@@ -0,0 +1,20 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or.hdl
/**
* Or gate:
* out = 1 if (a == 1 or b == 1)
* 0 otherwise
*/
CHIP Or {
IN a, b;
OUT out;
PARTS:
Not(in=a,out=nota);
Not(in=b,out=notb);
Nand(a=nota,b=notb,out=out);
}

5
projects/01/Or.out Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |

29
projects/01/Or.tst Normal file
View File

@@ -0,0 +1,29 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or.tst
load Or.hdl,
output-file Or.out,
compare-to Or.cmp,
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
set a 0,
set b 0,
eval,
output;
set a 0,
set b 1,
eval,
output;
set a 1,
set b 0,
eval,
output;
set a 1,
set b 1,
eval,
output;

7
projects/01/Or16.cmp Normal file
View File

@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 1111111111111111 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 1111111111111111 |
| 0011110011000011 | 0000111111110000 | 0011111111110011 |
| 0001001000110100 | 1001100001110110 | 1001101001110110 |

19
projects/01/Or16.hdl Normal file
View File

@@ -0,0 +1,19 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or16.hdl
/**
* 16-bit bitwise Or:
* for i = 0..15 out[i] = (a[i] or b[i])
*/
CHIP Or16 {
IN a[16], b[16];
OUT out[16];
PARTS:
Not16(in=a,out=nota);
Not16(in=b,out=notb);
Nand16(a=nota,b=notb,out=out);
}

7
projects/01/Or16.out Normal file
View File

@@ -0,0 +1,7 @@
| a | b | out |
| 0000000000000000 | 0000000000000000 | 0000000000000000 |
| 0000000000000000 | 1111111111111111 | 1111111111111111 |
| 1111111111111111 | 1111111111111111 | 1111111111111111 |
| 1010101010101010 | 0101010101010101 | 1111111111111111 |
| 0011110011000011 | 0000111111110000 | 0011111111110011 |
| 0001001000110100 | 1001100001110110 | 1001101001110110 |

39
projects/01/Or16.tst Normal file
View File

@@ -0,0 +1,39 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or16.tst
load Or16.hdl,
output-file Or16.out,
compare-to Or16.cmp,
output-list a%B1.16.1 b%B1.16.1 out%B1.16.1;
set a %B0000000000000000,
set b %B0000000000000000,
eval,
output;
set a %B0000000000000000,
set b %B1111111111111111,
eval,
output;
set a %B1111111111111111,
set b %B1111111111111111,
eval,
output;
set a %B1010101010101010,
set b %B0101010101010101,
eval,
output;
set a %B0011110011000011,
set b %B0000111111110000,
eval,
output;
set a %B0001001000110100,
set b %B1001100001110110,
eval,
output;

6
projects/01/Or8Way.cmp Normal file
View File

@@ -0,0 +1,6 @@
| in | out |
| 00000000 | 0 |
| 11111111 | 1 |
| 00010000 | 1 |
| 00000001 | 1 |
| 00100110 | 1 |

23
projects/01/Or8Way.hdl Normal file
View File

@@ -0,0 +1,23 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or8Way.hdl
/**
* 8-way Or:
* out = (in[0] or in[1] or ... or in[7])
*/
CHIP Or8Way {
IN in[8];
OUT out;
PARTS:
Or(a=in[0],b=in[1],out=or1);
Or(a=or1,b=in[2],out=or2);
Or(a=or2,b=in[3],out=or3);
Or(a=or3,b=in[4],out=or4);
Or(a=or4,b=in[5],out=or5);
Or(a=or5,b=in[6],out=or6);
Or(a=or6,b=in[7],out=out);
}

6
projects/01/Or8Way.out Normal file
View File

@@ -0,0 +1,6 @@
| in | out |
| 00000000 | 0 |
| 11111111 | 1 |
| 00010000 | 1 |
| 00000001 | 1 |
| 00100110 | 1 |

29
projects/01/Or8Way.tst Normal file
View File

@@ -0,0 +1,29 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Or8Way.tst
load Or8Way.hdl,
output-file Or8Way.out,
compare-to Or8Way.cmp,
output-list in%B2.8.2 out%B2.1.2;
set in %B00000000,
eval,
output;
set in %B11111111,
eval,
output;
set in %B00010000,
eval,
output;
set in %B00000001,
eval,
output;
set in %B00100110,
eval,
output;

5
projects/01/Xor.cmp Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |

21
projects/01/Xor.hdl Normal file
View File

@@ -0,0 +1,21 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Xor.hdl
/**
* Exclusive-or gate:
* out = not (a == b)
*/
CHIP Xor {
IN a, b;
OUT out;
PARTS:
Not(in=a, out=nota);
Not(in=b, out=notb);
Nand(a=nota, b=b, out=nandout1);
Nand(a=a, b=notb, out=nandout2);
Nand(a=nandout1, b=nandout2, out=out);
}

5
projects/01/Xor.out Normal file
View File

@@ -0,0 +1,5 @@
| a | b | out |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |

29
projects/01/Xor.tst Normal file
View File

@@ -0,0 +1,29 @@
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/Xor.tst
load Xor.hdl,
output-file Xor.out,
compare-to Xor.cmp,
output-list a%B3.1.3 b%B3.1.3 out%B3.1.3;
set a 0,
set b 0,
eval,
output;
set a 0,
set b 1,
eval,
output;
set a 1,
set b 0,
eval,
output;
set a 1,
set b 1,
eval,
output;

BIN
projects/01/and.pdf Normal file

Binary file not shown.

246
projects/01/and.svg Normal file
View File

@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="182.004"
height="51.450668"
viewBox="0 0 182.004 51.450668"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs6" />
<g
id="g8"
transform="matrix(1.3333333,0,0,-1.3333333,41.474666,-51.61733)">
<g
id="g10">
<g
id="g12" />
<g
id="g14">
<g
id="g16">
<g
id="g18">
<path
d="m -15.62973,-50.34404 h -8.88902 m 8.88902,-12.69914 h -8.88902"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path20" />
<g
id="g22">
<path
d="m -15.62973,-43.99446 h 18.5603 c 7.01363,0 12.69916,-5.68552 12.69916,-12.69916 0,-7.01362 -5.68553,-12.69914 -12.69916,-12.69914 h -18.5603 z"
style="fill:none;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path24" />
</g>
</g>
<path
d="m 19.54123,-56.69362 h 4.97752"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path26" />
<g
id="g28">
<g
id="g30"
transform="translate(17.586,-56.693)">
<g
id="g32" />
<g
id="g34"
transform="translate(-17.586,56.693)" />
</g>
<g
id="g36">
<g
id="g38">
<path
d="m 19.54123,-56.69362 c 0,1.08014 -0.87563,1.95575 -1.95575,1.95575 -1.08014,0 -1.95575,-0.87561 -1.95575,-1.95575 0,-1.08012 0.87561,-1.95575 1.95575,-1.95575 1.08012,0 1.95575,0.87563 1.95575,1.95575 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path40" />
</g>
</g>
</g>
<g
id="g42"
transform="translate(0,-56.693)">
<g
id="g44" />
<g
id="g46"
transform="translate(0,56.693)" />
</g>
</g>
<g
id="g48">
<g
id="g50">
<path
d="M 45.6958,-56.69362 H 36.80678"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path52" />
<g
id="g54">
<path
d="M 45.6958,-43.99446 67.69142,-56.69362 45.6958,-69.39276 Z"
style="fill:none;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path56" />
</g>
</g>
<path
d="m 71.60292,-56.69362 h 4.97752"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path58" />
<g
id="g60">
<g
id="g62"
transform="translate(69.647,-56.693)">
<g
id="g64" />
<g
id="g66"
transform="translate(-69.647,56.693)" />
</g>
<g
id="g68">
<g
id="g70">
<path
d="m 71.60292,-56.69362 c 0,1.08014 -0.87561,1.95575 -1.95575,1.95575 -1.08012,0 -1.95575,-0.87561 -1.95575,-1.95575 0,-1.08012 0.87563,-1.95575 1.95575,-1.95575 1.08014,0 1.95575,0.87563 1.95575,1.95575 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path72" />
</g>
</g>
</g>
<g
id="g74"
transform="translate(56.693,-56.693)">
<g
id="g76" />
<g
id="g78"
transform="translate(-56.693,56.693)" />
</g>
</g>
<path
d="m -24.51875,-50.34404 v 0"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path80" />
<g
id="g82">
<g
id="g84"
transform="translate(-27.009,-46.824)">
<g
id="g86">
<g
id="g88"
transform="translate(-4.097,-30.477)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,4.097,30.477)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text92"><tspan
x="0"
y="0"
id="tspan90">a</tspan></text>
<g
id="g94"
transform="translate(4.097,30.477)" />
</g>
</g>
<g
id="g96"
transform="translate(27.009,46.824)" />
</g>
</g>
<path
d="m -24.51875,-63.04318 v 0"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path98" />
<g
id="g100">
<g
id="g102"
transform="translate(-27.286,-73.481)">
<g
id="g104">
<g
id="g106"
transform="translate(-3.82,-3.82)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,3.82,3.82)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text110"><tspan
x="0"
y="0"
id="tspan108">b</tspan></text>
<g
id="g112"
transform="translate(3.82,3.82)" />
</g>
</g>
<g
id="g114"
transform="translate(27.286,73.481)" />
</g>
</g>
<path
d="m 24.51875,-56.69362 h 7.08669"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path116" />
<g
id="g118">
<g
id="g120"
transform="translate(35.125,-56.693)">
<g
id="g122" />
<g
id="g124"
transform="translate(-35.125,56.693)" />
</g>
</g>
<path
d="M 24.51875,-56.69362 H 36.80678"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path126" />
<path
d="m 76.58044,-56.69362 h 7.08669"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path128" />
<g
id="g130">
<g
id="g132"
transform="translate(87.186,-59.757)">
<g
id="g134">
<g
id="g136"
transform="translate(-118.292,-17.544)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,118.292,17.544)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text140"><tspan
x="0 4.9812999 10.516521"
y="0"
id="tspan138">out</tspan></text>
<g
id="g142"
transform="translate(118.292,17.544)" />
</g>
</g>
<g
id="g144"
transform="translate(-87.186,59.757)" />
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.3 KiB

53
projects/01/and.tex Normal file
View File

@@ -0,0 +1,53 @@
%!tikz editor 1.0
\documentclass{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, arrows.meta, quotes, calc, babel, fadings,quotes}
\usetikzlibrary{intersections,through,backgrounds}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
%!tikz preamble begin
\pgfplotsset{compat=1.18}
%!tikz preamble begin
%!tikz preamble begin
\usepackage{circuitikz}
%!tikz preamble begin
%!tikz preamble end
\begin{document}
%!tikz source begin
\begin{tikzpicture}
% Circuit style
\ctikzset{
logic ports=ieee,
logic ports/scale=0.8,
% logic ports/fill=lightgray
}
\node[nand port] (Nand) at (0,-2){};
\node[not port] (Not) at (2,-2){};
\draw (Nand.in 1) -- ++(-0,0) node[near end,above]{a};
\draw (Nand.in 2) -- ++(-0,0) node[near end,below]{b};
\draw (Nand.out) -- ++(0.25,0) node[right]{};
\draw (Nand.out) -- (Not.in);
\draw (Not.out) -- ++(0.25,0) node[right]{out};
%https://d1lvwzdke54ywg.cloudfront.net/computersystem-1/
\end{tikzpicture}
%!tikz source end
\end{document}

59
projects/01/cir_ex_01.tex Normal file
View File

@@ -0,0 +1,59 @@
%!tikz editor 1.0
\documentclass{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, arrows.meta, quotes, calc, babel, fadings,quotes}
\usetikzlibrary{intersections,through,backgrounds}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
%!tikz preamble begin
\pgfplotsset{compat=1.18}
%!tikz preamble begin
%!tikz preamble begin
\usepackage{circuitikz}
%!tikz preamble begin
%!tikz preamble end
\begin{document}
%!tikz source begin
\begin{circuitikz}
\draw
(0,2) node (myand1) [xshift=1cm,and port] {}
(myand1.out) node [anchor=south west] {\it A.B}
(myand1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
(myand1.in 2) node (B1) [anchor=east,xshift=-1cm,yshift=-.7cm] {B}
(0,0) node (mynot1) [not port, scale=.5] {}
(mynot1.out) node [anchor=south west] {$\bar{B}$}
(2.5,-.280) node (myor1) [or port] {}
(myor1.out) node [anchor=south west,xshift=.05cm] {$\bar{B}\texttt{+}C$}
(4,1.72) node (myor2) [or port] {}
(myor1.in 2) node (C1) [anchor=east,xshift=-2.5cm] {C}
(myor2.out) node [anchor=south west] {{\it A.B}\texttt{+}$(\bar{B}$\texttt{+}$C)$};
\draw (myor2.out) -- ++(1cm,0);
\draw (myand1.in 2) |- (mynot1.in);
\draw (mynot1.out) -| (myor1.in 1);
\draw (myand1.out) -- (myor2.in 1);
\draw (myor1.out) -- (myor2.in 2);
\draw (myand1.in 1) -- (A1);
\foreach \Point in {(A1),(B1), (C1)}{
\node [xshift=.2cm] at \Point {\textbullet};
}
\node [xshift=1.25cm] at (B1) {$\bullet$};
\node [xshift=1cm] at (myor2.out) {$\bullet$};
\draw (B1) -- ++(1.25cm,0);
\draw (myor1.in 2) -- (C1);
\end{circuitikz}
\end{document}

4
projects/01/convert2svg.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
#/opt/homebrew/bin/inkscape --without-gui --file=$1.pdf --export-plain-svg=$1.svg
inkscape --without-gui --file=$1.pdf --export-plain-svg=$1.svg

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
projects/01/not.pdf Normal file

Binary file not shown.

225
projects/01/not.svg Normal file
View File

@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="153.00932"
height="51.450668"
viewBox="0 0 153.00932 51.450668"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs6" />
<g
id="g8"
transform="matrix(1.3333333,0,0,-1.3333333,81.894665,-51.61733)">
<g
id="g10">
<g
id="g12" />
<g
id="g14">
<g
id="g16">
<g
id="g18">
<path
d="m -15.62973,-50.34404 h -8.88902 m 8.88902,-12.69914 h -8.88902"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path20" />
<g
id="g22">
<path
d="m -15.62973,-43.99446 h 18.5603 c 7.01363,0 12.69916,-5.68552 12.69916,-12.69916 0,-7.01362 -5.68553,-12.69914 -12.69916,-12.69914 h -18.5603 z"
style="fill:none;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path24" />
</g>
</g>
<path
d="m 19.54123,-56.69362 h 4.97752"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path26" />
<g
id="g28">
<g
id="g30"
transform="translate(17.585,-56.693)">
<g
id="g32" />
<g
id="g34"
transform="translate(-17.585,56.693)" />
</g>
<g
id="g36">
<g
id="g38">
<path
d="m 19.54123,-56.69362 c 0,1.08014 -0.87563,1.95575 -1.95575,1.95575 -1.08014,0 -1.95575,-0.87561 -1.95575,-1.95575 0,-1.08012 0.87561,-1.95575 1.95575,-1.95575 1.08012,0 1.95575,0.87563 1.95575,1.95575 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.797;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path40" />
</g>
</g>
</g>
<g
id="g42"
transform="translate(0,-56.693)">
<g
id="g44" />
<g
id="g46"
transform="translate(0,56.693)" />
</g>
</g>
<path
d="m -24.51875,-50.34404 v 0"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path48" />
<g
id="g50">
<g
id="g52"
transform="translate(-27.009,-46.823)">
<g
id="g54">
<g
id="g56"
transform="translate(-34.412,-30.478)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,34.412,30.478)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text60"><tspan
x="0"
y="0"
id="tspan58">a</tspan></text>
<g
id="g62"
transform="translate(34.412,30.478)" />
</g>
</g>
<g
id="g64"
transform="translate(27.009,46.823)" />
</g>
</g>
<path
d="m -24.51875,-63.04318 v 0"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path66" />
<g
id="g68">
<g
id="g70"
transform="translate(-27.286,-73.48)">
<g
id="g72">
<g
id="g74"
transform="translate(-34.135,-3.821)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,34.135,3.821)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text78"><tspan
x="0"
y="0"
id="tspan76">b</tspan></text>
<g
id="g80"
transform="translate(34.135,3.821)" />
</g>
</g>
<g
id="g82"
transform="translate(27.286,73.48)" />
</g>
</g>
<g
id="g84">
<path
d="m -24.51875,-63.04318 v 12.69914"
style="fill:none;stroke:#000000;stroke-width:0.79701;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path86" />
<g
id="g88">
<g
id="g90"
transform="translate(-24.519,-56.693)">
<g
id="g92" />
<g
id="g94"
transform="translate(24.519,56.693)" />
</g>
</g>
</g>
<path
d="m -24.51875,-56.69362 h -21.2601"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path96" />
<g
id="g98">
<g
id="g100"
transform="translate(-57.6,-60.02)">
<g
id="g102">
<g
id="g104"
transform="translate(-3.821,-17.281)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,3.821,17.281)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text108"><tspan
x="0 2.7676103"
y="0"
id="tspan106">in</tspan></text>
<g
id="g110"
transform="translate(3.821,17.281)" />
</g>
</g>
<g
id="g112"
transform="translate(57.6,60.02)" />
</g>
</g>
<path
d="m 24.51875,-56.69362 h 7.08669"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="path114" />
<g
id="g116">
<g
id="g118"
transform="translate(35.125,-59.757)">
<g
id="g120">
<g
id="g122"
transform="translate(-96.546,-17.544)">
<text
xml:space="preserve"
transform="matrix(1,0,0,-1,96.546,17.544)"
style="font-variant:normal;font-weight:normal;font-size:9.9626px;font-family:CMR10;-inkscape-font-specification:CMR10;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="text126"><tspan
x="0 4.9812999 10.516521"
y="0"
id="tspan124">out</tspan></text>
<g
id="g128"
transform="translate(96.546,17.544)" />
</g>
</g>
<g
id="g130"
transform="translate(-35.125,59.757)" />
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.3 KiB

45
projects/01/not.tex Normal file
View File

@@ -0,0 +1,45 @@
%!tikz editor 1.0
\documentclass{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, arrows.meta, quotes, calc, babel, fadings,quotes}
\usetikzlibrary{intersections,through,backgrounds}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
%!tikz preamble begin
\usepackage{circuitikz}
%!tikz preamble end
\begin{document}
%!tikz source begin
\begin{tikzpicture}
% Circuit style
\ctikzset{
logic ports=ieee,
logic ports/scale=0.8,
% logic ports/fill=lightgray
}
\node[nand port] (Nand) at (0,-2){};
\draw (Nand.in 1) -- ++(-0,0) node[near end,above]{a};
\draw (Nand.in 2) -- ++(-0,0) node[near end,below]{b};
\draw[thick] (Nand.in 2) -- (Nand.in 1)node[midway](in){};
\draw (in.center) -- ++(-0.75,0) node[left]{in};
\draw (Nand.out) -- ++(0.25,0) node[right]{out};
%\draw (Not.in 1) -| (Not.in 2);
\end{tikzpicture}
%!tikz source end
\end{document}

BIN
projects/01/or.pdf Normal file

Binary file not shown.

60
projects/01/or.tex Normal file
View File

@@ -0,0 +1,60 @@
%!tikz editor 1.0
\documentclass{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, arrows.meta, quotes, calc, babel, fadings,quotes}
\usetikzlibrary{intersections,through,backgrounds}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
%!tikz preamble begin
\pgfplotsset{compat=1.18}
%!tikz preamble begin
%!tikz preamble begin
\usepackage{circuitikz}
%!tikz preamble begin
%!tikz preamble end
\begin{document}
%!tikz source begin
\begin{tikzpicture}
% Circuit style
\ctikzset{
logic ports=ieee,
logic ports/scale=0.8,
% logic ports/fill=lightgray
}
\node[nand port] (Nand) at (2,0){};
\node[not port] (Nota) at (0,1.2){};
\node[not port] (Notb) at (0,-1.2){};
\draw (Nota.in) node[left]{a};
\draw (Notb.in) node[left]{b};
\draw (Nota.out) node[right, xshift=1, yshift=-10]{nota};
\draw (Notb.out) node[right, xshift=1, yshift=10]{notb};
\draw (Nota.out) |- (Nand.in 1);
\draw (Notb.out) |- (Nand.in 2);
%\draw (Nand.in 1) -- ++( -0,0) node[near end,above]{a};
%\draw (Nand.in 2) -- ++(-0,0) node[near end,below]{b};
%\draw (Nand.out) -- ++(0.25,0) node[right]{};
\draw (Nand.out) node[right]{out};
%\draw (Nota.out) -- ++(0.25,0) node[right]{out};
%https://d1lvwzdke54ywg.cloudfront.net/computersystem-1/
\end{tikzpicture}
%!tikz source end
\end{document}

BIN
projects/01/project1.zip Normal file

Binary file not shown.

BIN
projects/01/xor.pdf Normal file

Binary file not shown.

36
projects/01/xor.pgf Normal file
View File

@@ -0,0 +1,36 @@
\begin{circuitikz} \draw
(0,0) node (nota) [not port] {}
(nota.in) node (A1) [anchor=east,xshift=-1cm] {a}
(A1) -- (nota.in)
(0,-2.6) node (notb) [not port] {}
(notb.in) node (B1) [anchor=east,xshift=-1cm] {b}
(B1) -- (notb.in)
(2.5,-0.7) node (nand1) [nand port] {}
(nota.out) -| (nand1.in 1)
(2.5,-2) node (nand2) [nand port] {}
(notb.out) -| (nand2.in 2)
%node [circ, xshift=0.7cm](B1-dot1) at (B1) {}
%(B1-dot1) |- (nand1.in 2)
(B1) ++(0.7cm,0) node[circ] {} |- (nand1.in 2)
(A1) ++(1cm,0) node[circ] {} |- (nand2.in 1)
(4.5,-1.4) node (nand3) [nand port] {}
(nand3.out) node (C1) [anchor=west,xshift= 1cm] {out}
(nand3.out) -- (C1)
(nand1.out) -| (nand3.in 1)
(nand2.out) -| (nand3.in 2)
(nand1.out) node [xshift=15,yshift=7,font=\footnotesize] {nandout1}
(nand2.out) node [xshift=15,yshift=-7,font=\footnotesize] {nandout2}
% (nand1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
;\end{circuitikz}

199
projects/01/xor.svg Normal file
View File

@@ -0,0 +1,199 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 326.08932 153.57733"
height="153.57733"
width="326.08932"
xml:space="preserve"
id="svg2"
version="1.1"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs6" /><g
transform="matrix(1.3333333,0,0,-1.3333333,82.018665,27.654666)"
id="g10"><g
id="g12"><g
id="g14"><path
id="path16"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m -48.18948,0 h 28.3468 m -28.3468,-73.70186 h 28.3468 M 19.84268,0 h 11.73557 v -11.90556 m -11.73557,-61.7963 h 11.73557 v 9.07117 m -66.43735,-9.07117 v 45.92212 H 31.57825 M -26.18741,0 v -48.7565 h 57.76566 m 100.34773,9.07115 H 160.2728 M 75.23236,-19.84267 H 88.27187 V -31.74825 M 75.23236,-56.69362 h 13.03951 v 9.0712" /><g
id="g18"><g
id="g20"><g
id="g22"><path
id="path24"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="M 10.91354,0 -13.88982,19.84268 V -19.84268 L 10.91354,0" /><path
id="path26"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 13.88982,0 c 0,0.82187 -0.66626,1.48813 -1.48815,1.48813 -0.82188,0 -1.48813,-0.66626 -1.48813,-1.48813 0,-0.82187 0.66625,-1.48813 1.48813,-1.48813 0.82189,0 1.48815,0.66626 1.48815,1.48813 z" /></g><path
id="path28"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m -19.84268,0 h 5.95286 m 33.7325,0 h -5.95286" /></g><g
id="g30"><g
id="g32" /></g></g><g
id="g34"><g
transform="translate(-57.188,-2.511)"
id="g36"><g
id="g38"><g
transform="translate(-4.326,-91.931)"
id="g40"><text
id="text44"
style="font-variant:normal;font-weight:normal;font-size:10.47280025px;font-family:CharterBT;-inkscape-font-specification:CharterBT-Roman;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
transform="matrix(1,0,0,-1,4.326,91.931)"><tspan
id="tspan42"
y="0"
x="0">a</tspan></text>
<g
transform="translate(4.326,91.931)"
id="g46" /></g></g><g
transform="translate(57.188,2.511)"
id="g48" /></g></g><g
id="g50"><g
id="g52"><g
id="g54"><path
id="path56"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 10.91354,-73.70186 -24.80336,19.84268 v -39.68536 l 24.80336,19.84268" /><path
id="path58"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 13.88982,-73.70186 c 0,0.82189 -0.66626,1.48813 -1.48815,1.48813 -0.82188,0 -1.48813,-0.66624 -1.48813,-1.48813 0,-0.82188 0.66625,-1.48814 1.48813,-1.48814 0.82189,0 1.48815,0.66626 1.48815,1.48814 z" /></g><path
id="path60"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m -19.84268,-73.70186 h 5.95286 m 33.7325,0 h -5.95286" /></g><g
transform="translate(0,-73.701)"
id="g62"><g
id="g64" /><g
transform="translate(0,73.701)"
id="g66" /></g></g><g
id="g68"><g
transform="translate(-57.523,-77.482)"
id="g70"><g
id="g72"><g
transform="translate(-3.991,-16.96)"
id="g74"><text
id="text78"
style="font-variant:normal;font-weight:normal;font-size:10.47280025px;font-family:CharterBT;-inkscape-font-specification:CharterBT-Roman;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
transform="matrix(1,0,0,-1,3.991,16.96)"><tspan
id="tspan76"
y="0"
x="0">b</tspan></text>
<g
transform="translate(3.991,16.96)"
id="g80" /></g></g><g
transform="translate(57.523,77.482)"
id="g82" /></g></g><g
id="g84"><g
id="g86"><path
id="path88"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 31.57825,-11.90556 h 6.54818 m -6.54818,-15.87418 h 6.54818 m 37.10593,7.93707 h -6.54819" /><path
id="path90"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 38.12643,-3.96848 v -31.74838 c 15.06862,0 27.28383,7.10701 27.28383,15.87419 0,8.76718 -12.21521,15.87419 -27.28383,15.87419 z m 30.55774,-15.87419 c 0,0.90407 -0.73289,1.63695 -1.63694,1.63695 -0.90407,0 -1.63695,-0.73288 -1.63695,-1.63695 0,-0.90405 0.73288,-1.63694 1.63695,-1.63694 0.90405,0 1.63694,0.73289 1.63694,1.63694 z" /></g><g
transform="translate(53.405,-19.843)"
id="g92"><g
id="g94" /><g
transform="translate(-53.405,19.843)"
id="g96" /></g></g><g
id="g98"><g
id="g100"><path
id="path102"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 31.57825,-48.7565 h 6.54818 m -6.54818,-15.87419 h 6.54818 m 37.10593,7.93707 h -6.54819" /><path
id="path104"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 38.12643,-40.81941 v -31.7484 c 15.06862,0 27.28383,7.10703 27.28383,15.87419 0,8.76718 -12.21521,15.87421 -27.28383,15.87421 z m 30.55774,-15.87421 c 0,0.90407 -0.73289,1.63696 -1.63694,1.63696 -0.90407,0 -1.63695,-0.73289 -1.63695,-1.63696 0,-0.90405 0.73288,-1.63695 1.63695,-1.63695 0.90405,0 1.63694,0.7329 1.63694,1.63695 z" /></g><g
transform="translate(53.405,-56.693)"
id="g106"><g
id="g108" /><g
transform="translate(-53.405,56.693)"
id="g110" /></g></g><g
id="g112"><g
id="g114"><path
id="path116"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m -33.27196,-73.70186 c 0,0.87656 -0.71058,1.58714 -1.58714,1.58714 -0.87656,0 -1.58714,-0.71058 -1.58714,-1.58714 0,-0.87655 0.71058,-1.58714 1.58714,-1.58714 0.87656,0 1.58714,0.71059 1.58714,1.58714 z" /></g><g
transform="translate(-34.859,-73.701)"
id="g118"><g
id="g120" /><g
transform="translate(34.859,73.701)"
id="g122" /></g></g><g
id="g124"><g
id="g126"><path
id="path128"
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m -24.60027,0 c 0,0.87656 -0.71058,1.58714 -1.58714,1.58714 -0.87655,0 -1.58714,-0.71058 -1.58714,-1.58714 0,-0.87656 0.71059,-1.58714 1.58714,-1.58714 0.87656,0 1.58714,0.71058 1.58714,1.58714 z" /></g><g
transform="translate(-26.187)"
id="g130"><g
id="g132" /><g
transform="translate(26.187)"
id="g134" /></g></g><g
id="g136"><g
id="g138"><path
id="path140"
style="fill:none;stroke:#000000;stroke-width:0.3985;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 88.27187,-31.74825 h 6.54818 m -6.54818,-15.87417 h 6.54818 m 37.10593,7.93707 h -6.54819" /><path
id="path142"
style="fill:none;stroke:#000000;stroke-width:0.79699999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
d="m 94.82005,-23.81116 v -31.74838 c 15.06862,0 27.28383,7.10701 27.28383,15.87419 0,8.76718 -12.21521,15.87419 -27.28383,15.87419 z m 30.55774,-15.87419 c 0,0.90405 -0.73289,1.63695 -1.63695,1.63695 -0.90406,0 -1.63694,-0.7329 -1.63694,-1.63695 0,-0.90407 0.73288,-1.63695 1.63694,-1.63695 0.90406,0 1.63695,0.73288 1.63695,1.63695 z" /></g><g
transform="translate(110.098,-39.685)"
id="g144"><g
id="g146" /><g
transform="translate(-110.098,39.685)"
id="g148" /></g></g><g
id="g150"><g
transform="translate(163.961,-42.581)"
id="g152"><g
id="g154"><g
transform="translate(-225.475,-51.861)"
id="g156"><text
id="text160"
style="font-variant:normal;font-weight:normal;font-size:10.47280025px;font-family:CharterBT;-inkscape-font-specification:CharterBT-Roman;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
transform="matrix(1,0,0,-1,225.475,51.861)"><tspan
id="tspan158"
y="0"
x="0 5.6448393 11.603863">out</tspan></text>
<g
transform="translate(225.475,51.861)"
id="g162" /></g></g><g
transform="translate(-163.961,42.581)"
id="g164" /></g></g><g
id="g166"><g
transform="translate(72.073,-15.916)"
id="g168"><g
id="g170"><g
transform="translate(-133.587,-78.526)"
id="g172"><text
id="text176"
style="font-variant:normal;font-weight:normal;font-size:8.60779953px;font-family:CharterBT;-inkscape-font-specification:CharterBT-Roman;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
transform="matrix(1,0,0,-1,133.587,78.526)"><tspan
id="tspan174"
y="0"
x="0 4.8892303 9.2533846 14.142615 19.006021 23.645626 28.543465 31.41847">nandout1</tspan></text>
<g
transform="translate(133.587,78.526)"
id="g178" /></g></g><g
transform="translate(-72.073,15.916)"
id="g180" /></g></g><g
id="g182"><g
transform="translate(72.073,-66.714)"
id="g184"><g
id="g186"><g
transform="translate(-133.587,-27.728)"
id="g188"><text
id="text192"
style="font-variant:normal;font-weight:normal;font-size:8.60779953px;font-family:CharterBT;-inkscape-font-specification:CharterBT-Roman;writing-mode:lr-tb;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
transform="matrix(1,0,0,-1,133.587,27.728)"><tspan
id="tspan190"
y="0"
x="0 4.8892303 9.2533846 14.142615 19.006021 23.645626 28.543465 31.41847">nandout2</tspan></text>
<g
transform="translate(133.587,27.728)"
id="g194" /></g></g><g
transform="translate(-72.073,66.714)"
id="g196" /></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 13 KiB

68
projects/01/xor.tex Normal file
View File

@@ -0,0 +1,68 @@
%!tikz editor 1.0
\documentclass{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tkz-euclide}
\usetikzlibrary{angles, arrows.meta, quotes, calc, babel, fadings,quotes}
\usetikzlibrary{intersections,through,backgrounds}
\usepackage[graphics, active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}
%!tikz preamble begin
%!tikz preamble begin
\pgfplotsset{compat=1.18}
%!tikz preamble begin
%!tikz preamble begin
\usepackage{circuitikz}
%!tikz preamble begin
%!tikz preamble end
\begin{document}
\begin{circuitikz} \draw
(0,0) node (nota) [not port] {}
(nota.in) node (A1) [anchor=east,xshift=-1cm] {a}
(A1) -- (nota.in)
(0,-2.6) node (notb) [not port] {}
(notb.in) node (B1) [anchor=east,xshift=-1cm] {b}
(B1) -- (notb.in)
(2.5,-0.7) node (nand1) [nand port] {}
(nota.out) -| (nand1.in 1)
(2.5,-2) node (nand2) [nand port] {}
(notb.out) -| (nand2.in 2)
%node [circ, xshift=0.7cm](B1-dot1) at (B1) {}
%(B1-dot1) |- (nand1.in 2)
(B1) ++(0.7cm,0) node[circ] {} |- (nand1.in 2)
(A1) ++(1cm,0) node[circ] {} |- (nand2.in 1)
(4.5,-1.4) node (nand3) [nand port] {}
(nand3.out) node (C1) [anchor=west,xshift= 5mm] {out}
(nand3.out) -- (C1)
(nand1.out) -| (nand3.in 1)
(nand2.out) -| (nand3.in 2)
(nota.out) node [xshift=10,yshift=7,font=\footnotesize] {nota}
(notb.out) node [xshift=10,yshift=-7,font=\footnotesize] {notb}
(nand1.out) node [xshift=15,yshift=7,font=\footnotesize] {nandout1}
(nand2.out) node [xshift=15,yshift=-7,font=\footnotesize] {nandout2}
% (nand1.in 1) node (A1) [anchor=east,xshift=-1cm] {A}
;\end{circuitikz}
\end{document}