1. Nand2Tetris ¶
- 디 개 :
- 벨 논리로(드)단부 OS high level language까 두루두루 렵고 는 리를 만드는것 목 디다.
- 벨 논리로(드)단부 OS high level language까 두루두루 렵고 는 리를 만드는것 목 디다.
- 디 는 -> http://www.nand2tetris.org/
1.2.1. 공부 내 ¶
- Chapter1
- 기본 논리 게를 공부.
- Nand gate를 primitive gate로 놓고, 나머 논리 게 Not, And, Or, Xor, Mux, Demux Nand만로 구.
- Mux나 Demux같 경, 력나 력 무 많 경, 규모 Mux를 러 개 규모 Mux를 구 된다. 를 들면, 4way Mux는 2Way Mux 3개를 구 다.
- HDL Code
- Not Gate
CHIP Not2 { IN a; OUT out; PARTS: Nand(a = a, b = a, out = out); }
- And Gate
CHIP And { IN a, b; OUT out; PARTS: Nand(a = a, b = b, out = x); Nand(a = x, b = x, out = out); }
- Or Gate
CHIP Or { IN a, b; OUT out; PARTS: Nand(a = a, b = a, out = x1); Nand(a = b, b = b, out = x2); Nand(a = x1, b = x2, out = out); }
- Xor Gate
CHIP Xor { IN a, b; OUT out; PARTS: Nand(a = a, b = a, out = nota); Nand(a = b, b = b, out = notb); Nand(a = nota, b = b, out = x1); Nand(a = a, b = notb, out = x2); Nand(a = x1, b = x2, out = out); }
- Mux
CHIP Mux { IN a, b, s; OUT out; PARTS: Nand(a = s, b = s, out = nots); Nand(a = a, b = s, out = x1); Nand(a = b, b = nots, out = x2); Nand(a = x1, b = x2, out = out); }
- Mux 4way
CHIP Mux4way { IN a[4], s[2]; OUT out; PARTS: Nand(a = s[0], b = s[0], out = nots0); Nand(a = s[1], b = s[1], out = nots1); Nand(a = a[0], b = s[1], out = x0); Nand(a = a[1], b = nots1, out = x1); Nand(a = a[2], b = s[1], out = x2); Nand(a = a[3], b = nots1, out = x3); Nand(a = x0, b = x1, out = xx0); Nand(a = x2, b = x3, out = xx1); Nand(a = xx0, b = s[0], out = xxx0); Nand(a = xx1, b = nots0, out = xxx1); Nand(a = xxx0, b = xxx1, out = out); }
- Demux
Demux는 다 구고 Mux 4way를 Demux 리는 바람 날려림 ㅡㅡ;
1.2.3. 기 ¶
- 뿔 단김 빼라는 말 듯, 디 다. 기 끝날 때까 매 보려고 는데, 끝까 다 면 겠다. 뭐 나 까 되겠. 던 것 기 기데, 논리로 Nand 게로 다른 gate 구기 따는 본 당 다. 그리고 그림 그리는 것 만고, 다 까 논리로 ppt 보고 겠. 단 4way MUX 리 긴데, 떻게 .. 머리가 다. - 권기
- 만 논리로를 다루면 내가 까먹고 던 부 많다고 느낌다. 물론 라는 녀 리가 모든것 기 는 만, 그래 리를 다고 것 듯. nand로 nand로 끝나는 다. -
- 부라 무난게 만... 가면록 떤로 될 난 따라 바뀔 려나...는 각 들다. 그나나 논리로 뒷부 기 는데... 공 보고 것같다. - 김
1.3.1. 공부 내 ¶
- half-adder, full-adder, 16bit-adder, incremental adder, ALU 대 공부고 구다.
- Half-Adder
CHIP HalfAdder { IN a, b; // 1-bit inputs OUT sum, // Right bit of a + b carry; // Left bit of a + b PARTS: And(a = a, b = b, out = carry); Xor(a = a, b = b, out = sum); }
- Full-Adder
CHIP FullAdder{ IN a, b, c; // 1-bit inputs OUT sum, // Right bit of a + b + c carry; // Left bit of a + b + c PARTS: // Put you code here: Xor(a=a, b=b, out=s1); And(a=a, b=b, out=c1); Xor(a=s1, b=c, out=sum); And(a=s1, b=c, out=c2); Or(a=c1, b=c2, out=carry); }
- 16bit Adder
CHIP Add16 { IN a[16], b[16]; OUT out[16]; PARTS: FullAdder(a = a[0], b = b[0], c = false, sum = out[0], carry = c1); FullAdder(a = a[1], b = b[1], c = c1, sum = out[1], carry = c2); FullAdder(a = a[2], b = b[2], c = c2, sum = out[2], carry = c3); FullAdder(a = a[3], b = b[3], c = c3, sum = out[3], carry = c4); FullAdder(a = a[4], b = b[4], c = c4, sum = out[4], carry = c5); FullAdder(a = a[5], b = b[5], c = c5, sum = out[5], carry = c6); FullAdder(a = a[6], b = b[6], c = c6, sum = out[6], carry = c7); FullAdder(a = a[7], b = b[7], c = c7, sum = out[7], carry = c8); FullAdder(a = a[8], b = b[8], c = c8, sum = out[8], carry = c9); FullAdder(a = a[9], b = b[9], c = c9, sum = out[9], carry = c10); FullAdder(a = a[10], b = b[10], c = c10, sum = out[10], carry = c11); FullAdder(a = a[11], b = b[11], c = c11, sum = out[11], carry = c12); FullAdder(a = a[12], b = b[12], c = c12, sum = out[12], carry = c13); FullAdder(a = a[13], b = b[13], c = c13, sum = out[13], carry = c14); FullAdder(a = a[14], b = b[14], c = c14, sum = out[14], carry = c15); FullAdder(a = a[15], b = b[15], c = c15, sum = out[15], carry = c16); }
- Incremental
CHIP Inc16 { IN a[16]; OUT out[16]; PARTS: FullAdder(a = a[0], b = false, c = true, sum = out[0], carry = c1); FullAdder(a = a[1], b = false, c = c1, sum = out[1], carry = c2); FullAdder(a = a[2], b = false, c = c2, sum = out[2], carry = c3); FullAdder(a = a[3], b = false, c = c3, sum = out[3], carry = c4); FullAdder(a = a[4], b = false, c = c4, sum = out[4], carry = c5); FullAdder(a = a[5], b = false, c = c5, sum = out[5], carry = c6); FullAdder(a = a[6], b = false, c = c6, sum = out[6], carry = c7); FullAdder(a = a[7], b = false, c = c7, sum = out[7], carry = c8); FullAdder(a = a[8], b = false, c = c8, sum = out[8], carry = c9); FullAdder(a = a[9], b = false, c = c9, sum = out[9], carry = c10); FullAdder(a = a[10], b = false, c = c10, sum = out[10], carry = c11); FullAdder(a = a[11], b = false, c = c11, sum = out[11], carry = c12); FullAdder(a = a[12], b = false, c = c12, sum = out[12], carry = c13); FullAdder(a = a[13], b = false, c = c13, sum = out[13], carry = c14); FullAdder(a = a[14], b = false, c = c14, sum = out[14], carry = c15); FullAdder(a = a[15], b = false, c = c15, sum = out[15], carry = c16); }
- ALU
1.4.1. 공부 내 ¶
- Chapter 4
- Hack Machine language를 로그램 .
D - data, A - address, M - memory
e.g. A - 32경, M M32. M 때, A 값 memory address
2개 Instruction 다. 각 Instruction 2Byte다.
- A-Instruction : @value // Where value is either a non-negative decimal number or a symbol referring to such number.
Binary : 0vvv vvvv vvvv vvvv
- C-Instruction : dest=comp;jump // Either the dest or jump fields may be empty.
// If dest is empty, the "=" is omitted;
// if jump is empty, the ";" is omitted;
- A-instruction 면, value는 A 들다.
A 값 M 될 때는, 고, D 같 때는 값 그 로 .
- Chapter4 내
- PPT 내
{ comp }{dest }{jump}
Binary : 111a c1c2c3c4 c5c6d1d2 d3j1j2j3
1.4.2. 과 ¶
- 과
- 1 ~ 100까 더기 (권기)
0 @100 1 M=1 2 @150 3 M=0 4 @100 5 D=M 6 @100 7 D=D-A 8 @18 9 D;JGT 10 @100 11 D=M 12 @150 13 M=D+M 14 @100 15 M=M+1 16 @4 17 0;JMP 18 @18 19 0;JMP
- 두 (권기)
//Memory[10] = A //Memory[11] = B //Memory[12] = Dest 0 @20 1 D=A 2 @10 3 M=D 4 @20 5 D=A 6 @11 7 M=D 8 @12 9 M=0 10 @11 11 D=M 12 @22 13 D;JEQ 14 @10 15 D=M 16 @12 17 M=D+M 18 @11 19 M=M-1 20 @10 21 0;JMP 22 @22 23 0;JMP
- 두 (김)

[PNG image (303.11 KB)]
- I/O Handling, (권기)(BLACK 력면 모가 면 나고, WHITE를 력면 면 모를 )
0 @24576 1 D=M 2 @0 3 D;JEQ 4 @66 5 D=D-A 6 @1000 7 D;JEQ 8 @24576 9 D=M 10 @87 11 D=D-A 12 @2000 13 D;JEQ 14 @0 15 0;JMP 1000 @24576 1001 D=M 1002 @1000 1003 D;JEQ 1004 @76 1005 D=D-A 1006 @0 1007 D;JNE 1008 @24576 1009 D=M 1010 @1008 1011 D;JEQ 1012 @65 1013 D=D-A 1014 @0 1015 D;JNE 1016 @24576 1017 D=M 1018 @1016 1019 D;JEQ 1020 @67 1021 D=D-A 1022 @0 1023 D;JNE 1024 @24576 1025 D=M 1026 @1024 1027 D;JEQ 1028 @75 1029 D=D-A 1030 @0 1031 D;JNE 1032 @24555 1033 M=-1 1034 @0 1035 0;JMP 2000 @24576 2001 D=M 2002 @2000 2003 D;JEQ 2004 @72 2005 D=D-A 2006 @0 2007 D;JNE 2008 @24576 2009 D=M 2010 @2008 2011 D;JEQ 2012 @73 2013 D=D-A 2014 @0 2015 D;JNE 2016 @24576 2017 D=M 2018 @2016 2019 D;JEQ 2020 @84 2021 D=D-A 2022 @0 2023 D;JNE 2024 @24576 2025 D=M 2026 @2024 2027 D;JEQ 2028 @69 2029 D=D-A 2030 @0 2031 D;JNE 2032 @24555 2033 M=0 2034 @0 2035 0;JMP
- I/O Handling, (김)(BLACK 력면 모가 면 나고, WHITE를 력면 면 모를 )

[PNG image (300.59 KB)]
1.4.3. 기 ¶
- MIPS 딩는 것 각고 과를 는데, MIPS 보다 더 드. Symbol 고( Cpu emulator만 긴 문 만), 2~3개 밖 못는 려고 막막다. I/O Handling 같 경 보드 력 결려고 나 각 는데, 결과물 들 는군. 무 느낀 것 "High-Level Language가 가?" 가 되겠다. 느낌 블리 , 구 느만 말. 1/3를 고, 대로라면 12 되기 까 1/2는 것 같 기 . 무 끝 봤면 는 각다. - 권기
1.5.1. 공부 내 ¶
- Von Neumann machine (circa 1940)
Memory (data + instruction) + CPU(ALU + Registers + Control) + Input device & Output device
까 기본 논리 게를 (Nand만 ) 구고, Combinational Chip 과 Sequential Chip까 부 구다. 까 구 것 모두 면 Computer Architecture가 만들다.
- The Hack Computer
A 16-bit Von Neumann platform
The instruction memory and the data memory are physically separate
Screen: 512 rows by 256 columns, black and white
Keyboard: standard
- Instruction memory(ROM)
ROM는 미리 놓 로그램 .
ROM는 16bit 명령가 나.
instruction = ROM32Kaddress
- Memory(RAM)
Data memory
기
k = address
out = RAMk
기
- CPU
- Computer ( 모든 logic 다 가고 )
명 architecture 나다.
k = address
x = in
load = 1
RAMk = x
Screen(memory map)
Screen RAM 딘가를 당놓. 공 Screen 공. CPU는 그 공 나 Screen 력
x = in
load = 1
RAMk = x
Screen(memory map)
Screen RAM 딘가를 당놓. 공 Screen 공. CPU는 그 공 나 Screen 력
Keyboard(memory map)
Keyboard를 RAM 딘가를 당놓. 공 Keyboard를 공. CPU는 그 공 떤 key가 들는 .
Keyboard를 RAM 딘가를 당놓. 공 Keyboard를 공. CPU는 그 공 떤 key가 들는 .