SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 1
www.nand2tetris.org
Building a Modern Computer From First Principles
Boolean Logic
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 2
Boolean algebra
Some elementary Boolean functions:
Not(x)
And(x,y)
Or(x,y)
Nand(x,y)
x y z
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 0
zyxzyxf )(),,( +=
Boolean functions:
A Boolean function can be expressed using a
functional expression or a truth table expression
Important observation:
Every Boolean function can be expressed using
And, Or, Not.
x y Nand(x,y)
0 0 1
0 1 1
1 0 1
1 1 0
x y Nand(x,y)
0 0 1
0 1 1
1 0 1
1 1 0
x y And(x,y)
0 0 0
0 1 0
1 0 0
1 1 1
x y And(x,y)
0 0 0
0 1 0
1 0 0
1 1 1
x y Or(x,y)
0 0 0
0 1 1
1 0 1
1 1 1
x y Or(x,y)
0 0 0
0 1 1
1 0 1
1 1 1
x Not(x)
0 1
1 0
x Not(x)
0 1
1 0
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 3
All Boolean functions of 2 variables
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 4
Boolean algebra
Given: Nand(a,b), false
We can build:
Not(a) = Nand(a,a)
true = Not(false)
And(a,b) = Not(Nand(a,b))
Or(a,b) = Not(And(Not(a),Not(b)))
Xor(a,b) = Or(And(a,Not(b)),And(Not(a),b)))
Etc.
George Boole, 1815-1864
(“A Calculus of Logic”)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 5
Gate logic
Gate logic – a gate architecture designed to implement a Boolean function
Elementary gates:
Composite gates:
Important distinction: Interface (what) VS implementation (how).
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 6
Gate logic
And
And
Not
Or out
a
b
Not
Xor(a,b) = Or(And(a,Not(b)),And(Not(a),b)))
Implementation
Xor
a
b
out
0 0 0
0 1 1
1 0 1
1 1 0
a b out
Interface
Claude Shannon, 1916-2001
(“Symbolic Analysis of Relay and
Switching Circuits” )
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 7
0 0 0
0 1 0
1 0 0
1 1 1
a b out
a b
out
power supply
AND gate
power supply
a
b
out
0 0 0
0 1 1
1 0 1
1 1 1
a b out
OR gate
a
out
b c
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1
a b c out
AND (a,b,c)
a
AND
b
AND
c
out
Circuit implementations
From a computer science perspective,
physical realizations of logic gates are irrelevant.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 8
Project 1: elementary logic gates
Given: Nand(a,b), false
Build:
Not(a) = ...
true = ...
And(a,b) = ...
Or(a,b) = ...
Mux(a,b,sel) = ...
Etc. - 12 gates altogether.
a b Nand(a,b)
0 0 1
0 1 1
1 0 1
1 1 0
a b Nand(a,b)
0 0 1
0 1 1
1 0 1
1 1 0
Q: Why these particular 12 gates?
A: Since …
They are commonly used gates
They provide all the basic
building blocks needed to build
our computer.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 9
Multiplexer
Proposed Implementation: based on Not, And, Or gates.
a
b
sel
outMux
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
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
sel out
0 a
1 b
sel out
0 a
1 b
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 10
out
a
b
And
a b out
0 0 0
0 1 0
1 0 0
1 1 1
a b out
0 0 0
0 1 0
1 0 0
1 1 1
And.cmp
load And.hdl,
output-file And.out,
compare-to And.cmp,
output-list a b out;
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;
load And.hdl,
output-file And.out,
compare-to And.cmp,
output-list a b out;
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;
And.tstAnd.hdl
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
Example: Building an And gate
Contract:
When running your
.hdl on our .tst,
your .out should
be the same as
our .cmp.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 11
Building an And gate
out
a
b
And
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
And.hdl
Interface: And(a,b) = 1 exactly when a=b=1
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 12
Implementation: And(a,b) = Not(Nand(a,b))
out
a
b
Building an And gate
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
And.hdl
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 13
outNot
a
b
out
Nand
a in out
x
b
Implementation: And(a,b) = Not(Nand(a,b))
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
CHIP And
{ IN a, b;
OUT out;
// implementation missing
}
And.hdl
Building an And gate
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 14
CHIP And
{ IN a, b;
OUT out;
Nand(a = a,
b = b,
out = x);
Not(in = x, out = out)
}
CHIP And
{ IN a, b;
OUT out;
Nand(a = a,
b = b,
out = x);
Not(in = x, out = out)
}
Implementation: And(a,b) = Not(Nand(a,b))
outNOT
a
b
out
NAND
a in out
x
b
Building an And gate
And.hdl
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 15
Hardware simulator (demonstrating Xor gate construction)
test
script
HDL
program
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 16
Hardware simulator
HDL
program
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 17
HDL
program
Hardware simulator
output
file
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 18
Project materials: www.nand2tetris.org
Project 1 web site
And.hdl ,
And.tst ,
And.cmp files
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 19
Project 1 tips
Read the Introduction + Chapter 1 of the book
Download the book’s software suite
Go through the hardware simulator tutorial
Do Project 0 (optional)
You’re in business.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 20
a
b
c
and
and
or
f(a,b,c)...
Perspective
Each Boolean function has a canonical representation
The canonical representation is expressed in terms of And, Not, Or
And, Not, Or can be expressed in terms of Nand alone
Ergo, every Boolean function can be realized by a standard PLD
consisting of Nand gates only
Mass production
Universal building blocks,
unique topology
Gates, neurons, atoms, …
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 21
End notes: Canonical representation
Whodunit story: Each suspect may or may not have an alibi (a), a motivation to
commit the crime (m), and a relationship to the weapon found in the scene
of the crime (w). The police decides to focus attention only on suspects
for whom the proposition Not(a) And (m Or w) is true.
)(),,( wmawmas +⋅=Truth table of the "suspect" function
Canonical form: wmawmawmawmas ++=),,(
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 22
End notes: Canonical representation (cont.)
and
s
a
m
w
or
)(),,( wmawmas +⋅=
a
m
w
s
and
and
and
or
wmawmawmawmas ++=),,(
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 23
a
b
c
and
and
or
f(a,b,c)8 and terms
connected to the
same 3 inputs
...
(the on/off states of the fuses determine which gates participate in the computation)
single or term
connected to the
outputs of 8 and terms
active fuse
blown fuse
legend:
PLD implementation of f(a,b,c)= a b c + a b c
_ _ _
End notes: Programmable Logic Device for 3-way functions
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 24
a
b
c
and
and
or
f(a,b,c)...
End notes: universal building blocks, unique topology

Contenu connexe

Tendances

Lecture 09 high level language
Lecture 09 high level languageLecture 09 high level language
Lecture 09 high level language鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第五章 計算機結構
nand2tetris 舊版投影片 -- 第五章 計算機結構nand2tetris 舊版投影片 -- 第五章 計算機結構
nand2tetris 舊版投影片 -- 第五章 計算機結構鍾誠 陳鍾誠
 
Lecture 08 virtual machine ii
Lecture 08 virtual machine iiLecture 08 virtual machine ii
Lecture 08 virtual machine ii鍾誠 陳鍾誠
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言鍾誠 陳鍾誠
 
Bakers and Philosophers
Bakers and PhilosophersBakers and Philosophers
Bakers and PhilosophersDavid Evans
 
Sequential and combinational alu
Sequential and combinational alu Sequential and combinational alu
Sequential and combinational alu Piyush Rochwani
 
System design using HDL - Module 3
System design using HDL - Module 3System design using HDL - Module 3
System design using HDL - Module 3Aravinda Koithyar
 
Cryptographic algorithms
Cryptographic algorithmsCryptographic algorithms
Cryptographic algorithmsAnamika Singh
 
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)Sylvain Hallé
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...Linaro
 
Scheduling in Linux and Web Servers
Scheduling in Linux and Web ServersScheduling in Linux and Web Servers
Scheduling in Linux and Web ServersDavid Evans
 

Tendances (20)

Lecture 09 high level language
Lecture 09 high level languageLecture 09 high level language
Lecture 09 high level language
 
nand2tetris 舊版投影片 -- 第五章 計算機結構
nand2tetris 舊版投影片 -- 第五章 計算機結構nand2tetris 舊版投影片 -- 第五章 計算機結構
nand2tetris 舊版投影片 -- 第五章 計算機結構
 
Lecture 08 virtual machine ii
Lecture 08 virtual machine iiLecture 08 virtual machine ii
Lecture 08 virtual machine ii
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
 
Lecture 10 compiler i
Lecture 10 compiler iLecture 10 compiler i
Lecture 10 compiler i
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
 
Bakers and Philosophers
Bakers and PhilosophersBakers and Philosophers
Bakers and Philosophers
 
Machine language
Machine languageMachine language
Machine language
 
Matlab workshop
Matlab workshopMatlab workshop
Matlab workshop
 
Managing Memory
Managing MemoryManaging Memory
Managing Memory
 
Unit 2 module-2
Unit 2 module-2Unit 2 module-2
Unit 2 module-2
 
Sequential and combinational alu
Sequential and combinational alu Sequential and combinational alu
Sequential and combinational alu
 
System design using HDL - Module 3
System design using HDL - Module 3System design using HDL - Module 3
System design using HDL - Module 3
 
Chapter#4
Chapter#4Chapter#4
Chapter#4
 
Cryptographic algorithms
Cryptographic algorithmsCryptographic algorithms
Cryptographic algorithms
 
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
 
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
BKK16-503 Undefined Behavior and Compiler Optimizations – Why Your Program St...
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Scheduling in Linux and Web Servers
Scheduling in Linux and Web ServersScheduling in Linux and Web Servers
Scheduling in Linux and Web Servers
 

Similaire à nand2tetris 舊版投影片 -- 第一章 布林邏輯

lecture 02 Boolean arithmetic.ppt
lecture 02 Boolean arithmetic.pptlecture 02 Boolean arithmetic.ppt
lecture 02 Boolean arithmetic.pptzorogoh2
 
Binary logic
Binary logicBinary logic
Binary logicwardjo
 
Logic Gate.pptx
Logic Gate.pptxLogic Gate.pptx
Logic Gate.pptxMrAdhit1
 
Computer organiztion3
Computer organiztion3Computer organiztion3
Computer organiztion3Umang Gupta
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the MassesDavid Evans
 
Dr. kiani artificial neural network lecture 1
Dr. kiani artificial neural network lecture 1Dr. kiani artificial neural network lecture 1
Dr. kiani artificial neural network lecture 1Parinaz Faraji
 
5.5 Logic circuits
5.5 Logic circuits5.5 Logic circuits
5.5 Logic circuitslpapadop
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum ComputingGDSC PJATK
 
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdf
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdfLec4-Algghhhhgghgjhf5dvbgyuygit87678.pdf
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdfabdnazar2003
 
Ieee cluster talk
Ieee cluster talkIeee cluster talk
Ieee cluster talkPeng Du
 
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Machine learning pt.1: Artificial Neural Networks ® All Rights ReservedMachine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Machine learning pt.1: Artificial Neural Networks ® All Rights ReservedJonathan Mitchell
 
Deep learning simplified
Deep learning simplifiedDeep learning simplified
Deep learning simplifiedLovelyn Rose
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matterDawid Weiss
 
Computer Architecture 3rd Edition by Moris Mano CH 01-CH 02.ppt
Computer Architecture 3rd Edition by Moris Mano CH  01-CH 02.pptComputer Architecture 3rd Edition by Moris Mano CH  01-CH 02.ppt
Computer Architecture 3rd Edition by Moris Mano CH 01-CH 02.pptHowida Youssry
 
Programmable array-logic-and-programmable-logic-array
Programmable array-logic-and-programmable-logic-arrayProgrammable array-logic-and-programmable-logic-array
Programmable array-logic-and-programmable-logic-arrayJher Carlson Atasan
 
PST SC015 Chapter 2 Computer System (III) 2017/2018
PST SC015 Chapter 2 Computer System (III) 2017/2018PST SC015 Chapter 2 Computer System (III) 2017/2018
PST SC015 Chapter 2 Computer System (III) 2017/2018Fizaril Amzari Omar
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmTasuku Soma
 
Combinational logic circuits design and implementation
Combinational logic circuits design and implementationCombinational logic circuits design and implementation
Combinational logic circuits design and implementationssuserca5764
 

Similaire à nand2tetris 舊版投影片 -- 第一章 布林邏輯 (20)

lecture 02 Boolean arithmetic.ppt
lecture 02 Boolean arithmetic.pptlecture 02 Boolean arithmetic.ppt
lecture 02 Boolean arithmetic.ppt
 
Binary logic
Binary logicBinary logic
Binary logic
 
Logic Gate.pptx
Logic Gate.pptxLogic Gate.pptx
Logic Gate.pptx
 
9. logic gates._rr
9. logic gates._rr9. logic gates._rr
9. logic gates._rr
 
Computer organiztion3
Computer organiztion3Computer organiztion3
Computer organiztion3
 
Multi-Party Computation for the Masses
Multi-Party Computation for the MassesMulti-Party Computation for the Masses
Multi-Party Computation for the Masses
 
DLD Chapter-2.pdf
DLD Chapter-2.pdfDLD Chapter-2.pdf
DLD Chapter-2.pdf
 
Dr. kiani artificial neural network lecture 1
Dr. kiani artificial neural network lecture 1Dr. kiani artificial neural network lecture 1
Dr. kiani artificial neural network lecture 1
 
5.5 Logic circuits
5.5 Logic circuits5.5 Logic circuits
5.5 Logic circuits
 
Introduction to Quantum Computing
Introduction to Quantum ComputingIntroduction to Quantum Computing
Introduction to Quantum Computing
 
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdf
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdfLec4-Algghhhhgghgjhf5dvbgyuygit87678.pdf
Lec4-Algghhhhgghgjhf5dvbgyuygit87678.pdf
 
Ieee cluster talk
Ieee cluster talkIeee cluster talk
Ieee cluster talk
 
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Machine learning pt.1: Artificial Neural Networks ® All Rights ReservedMachine learning pt.1: Artificial Neural Networks ® All Rights Reserved
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
 
Deep learning simplified
Deep learning simplifiedDeep learning simplified
Deep learning simplified
 
sizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may mattersizeof(Object): how much memory objects take on JVMs and when this may matter
sizeof(Object): how much memory objects take on JVMs and when this may matter
 
Computer Architecture 3rd Edition by Moris Mano CH 01-CH 02.ppt
Computer Architecture 3rd Edition by Moris Mano CH  01-CH 02.pptComputer Architecture 3rd Edition by Moris Mano CH  01-CH 02.ppt
Computer Architecture 3rd Edition by Moris Mano CH 01-CH 02.ppt
 
Programmable array-logic-and-programmable-logic-array
Programmable array-logic-and-programmable-logic-arrayProgrammable array-logic-and-programmable-logic-array
Programmable array-logic-and-programmable-logic-array
 
PST SC015 Chapter 2 Computer System (III) 2017/2018
PST SC015 Chapter 2 Computer System (III) 2017/2018PST SC015 Chapter 2 Computer System (III) 2017/2018
PST SC015 Chapter 2 Computer System (III) 2017/2018
 
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient AlgorithmOptimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
Optimal Budget Allocation: Theoretical Guarantee and Efficient Algorithm
 
Combinational logic circuits design and implementation
Combinational logic circuits design and implementationCombinational logic circuits design and implementation
Combinational logic circuits design and implementation
 

Plus de 鍾誠 陳鍾誠

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史鍾誠 陳鍾誠
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus鍾誠 陳鍾誠
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥鍾誠 陳鍾誠
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++鍾誠 陳鍾誠
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列鍾誠 陳鍾誠
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列鍾誠 陳鍾誠
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》鍾誠 陳鍾誠
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作鍾誠 陳鍾誠
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統鍾誠 陳鍾誠
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統鍾誠 陳鍾誠
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器鍾誠 陳鍾誠
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器鍾誠 陳鍾誠
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言鍾誠 陳鍾誠
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器鍾誠 陳鍾誠
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入鍾誠 陳鍾誠
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器鍾誠 陳鍾誠
 

Plus de 鍾誠 陳鍾誠 (20)

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》
 
系統程式 -- 前言
系統程式 -- 前言系統程式 -- 前言
系統程式 -- 前言
 
系統程式 -- 附錄
系統程式 -- 附錄系統程式 -- 附錄
系統程式 -- 附錄
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器
 

Dernier

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Dernier (20)

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

nand2tetris 舊版投影片 -- 第一章 布林邏輯

  • 1. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 1 www.nand2tetris.org Building a Modern Computer From First Principles Boolean Logic
  • 2. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 2 Boolean algebra Some elementary Boolean functions: Not(x) And(x,y) Or(x,y) Nand(x,y) x y z 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 0 zyxzyxf )(),,( += Boolean functions: A Boolean function can be expressed using a functional expression or a truth table expression Important observation: Every Boolean function can be expressed using And, Or, Not. x y Nand(x,y) 0 0 1 0 1 1 1 0 1 1 1 0 x y Nand(x,y) 0 0 1 0 1 1 1 0 1 1 1 0 x y And(x,y) 0 0 0 0 1 0 1 0 0 1 1 1 x y And(x,y) 0 0 0 0 1 0 1 0 0 1 1 1 x y Or(x,y) 0 0 0 0 1 1 1 0 1 1 1 1 x y Or(x,y) 0 0 0 0 1 1 1 0 1 1 1 1 x Not(x) 0 1 1 0 x Not(x) 0 1 1 0
  • 3. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 3 All Boolean functions of 2 variables
  • 4. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 4 Boolean algebra Given: Nand(a,b), false We can build: Not(a) = Nand(a,a) true = Not(false) And(a,b) = Not(Nand(a,b)) Or(a,b) = Not(And(Not(a),Not(b))) Xor(a,b) = Or(And(a,Not(b)),And(Not(a),b))) Etc. George Boole, 1815-1864 (“A Calculus of Logic”)
  • 5. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 5 Gate logic Gate logic – a gate architecture designed to implement a Boolean function Elementary gates: Composite gates: Important distinction: Interface (what) VS implementation (how).
  • 6. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 6 Gate logic And And Not Or out a b Not Xor(a,b) = Or(And(a,Not(b)),And(Not(a),b))) Implementation Xor a b out 0 0 0 0 1 1 1 0 1 1 1 0 a b out Interface Claude Shannon, 1916-2001 (“Symbolic Analysis of Relay and Switching Circuits” )
  • 7. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 7 0 0 0 0 1 0 1 0 0 1 1 1 a b out a b out power supply AND gate power supply a b out 0 0 0 0 1 1 1 0 1 1 1 1 a b out OR gate a out b c 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 a b c out AND (a,b,c) a AND b AND c out Circuit implementations From a computer science perspective, physical realizations of logic gates are irrelevant.
  • 8. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 8 Project 1: elementary logic gates Given: Nand(a,b), false Build: Not(a) = ... true = ... And(a,b) = ... Or(a,b) = ... Mux(a,b,sel) = ... Etc. - 12 gates altogether. a b Nand(a,b) 0 0 1 0 1 1 1 0 1 1 1 0 a b Nand(a,b) 0 0 1 0 1 1 1 0 1 1 1 0 Q: Why these particular 12 gates? A: Since … They are commonly used gates They provide all the basic building blocks needed to build our computer.
  • 9. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 9 Multiplexer Proposed Implementation: based on Not, And, Or gates. a b sel outMux 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 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 sel out 0 a 1 b sel out 0 a 1 b
  • 10. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 10 out a b And a b out 0 0 0 0 1 0 1 0 0 1 1 1 a b out 0 0 0 0 1 0 1 0 0 1 1 1 And.cmp load And.hdl, output-file And.out, compare-to And.cmp, output-list a b out; 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; load And.hdl, output-file And.out, compare-to And.cmp, output-list a b out; 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; And.tstAnd.hdl CHIP And { IN a, b; OUT out; // implementation missing } CHIP And { IN a, b; OUT out; // implementation missing } Example: Building an And gate Contract: When running your .hdl on our .tst, your .out should be the same as our .cmp.
  • 11. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 11 Building an And gate out a b And CHIP And { IN a, b; OUT out; // implementation missing } CHIP And { IN a, b; OUT out; // implementation missing } And.hdl Interface: And(a,b) = 1 exactly when a=b=1
  • 12. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 12 Implementation: And(a,b) = Not(Nand(a,b)) out a b Building an And gate CHIP And { IN a, b; OUT out; // implementation missing } CHIP And { IN a, b; OUT out; // implementation missing } And.hdl
  • 13. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 13 outNot a b out Nand a in out x b Implementation: And(a,b) = Not(Nand(a,b)) CHIP And { IN a, b; OUT out; // implementation missing } CHIP And { IN a, b; OUT out; // implementation missing } And.hdl Building an And gate
  • 14. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 14 CHIP And { IN a, b; OUT out; Nand(a = a, b = b, out = x); Not(in = x, out = out) } CHIP And { IN a, b; OUT out; Nand(a = a, b = b, out = x); Not(in = x, out = out) } Implementation: And(a,b) = Not(Nand(a,b)) outNOT a b out NAND a in out x b Building an And gate And.hdl
  • 15. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 15 Hardware simulator (demonstrating Xor gate construction) test script HDL program
  • 16. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 16 Hardware simulator HDL program
  • 17. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 17 HDL program Hardware simulator output file
  • 18. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 18 Project materials: www.nand2tetris.org Project 1 web site And.hdl , And.tst , And.cmp files
  • 19. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 19 Project 1 tips Read the Introduction + Chapter 1 of the book Download the book’s software suite Go through the hardware simulator tutorial Do Project 0 (optional) You’re in business.
  • 20. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 20 a b c and and or f(a,b,c)... Perspective Each Boolean function has a canonical representation The canonical representation is expressed in terms of And, Not, Or And, Not, Or can be expressed in terms of Nand alone Ergo, every Boolean function can be realized by a standard PLD consisting of Nand gates only Mass production Universal building blocks, unique topology Gates, neurons, atoms, …
  • 21. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 21 End notes: Canonical representation Whodunit story: Each suspect may or may not have an alibi (a), a motivation to commit the crime (m), and a relationship to the weapon found in the scene of the crime (w). The police decides to focus attention only on suspects for whom the proposition Not(a) And (m Or w) is true. )(),,( wmawmas +⋅=Truth table of the "suspect" function Canonical form: wmawmawmawmas ++=),,(
  • 22. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 22 End notes: Canonical representation (cont.) and s a m w or )(),,( wmawmas +⋅= a m w s and and and or wmawmawmawmas ++=),,(
  • 23. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 23 a b c and and or f(a,b,c)8 and terms connected to the same 3 inputs ... (the on/off states of the fuses determine which gates participate in the computation) single or term connected to the outputs of 8 and terms active fuse blown fuse legend: PLD implementation of f(a,b,c)= a b c + a b c _ _ _ End notes: Programmable Logic Device for 3-way functions
  • 24. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 1: Boolean Logic slide 24 a b c and and or f(a,b,c)... End notes: universal building blocks, unique topology