What is Computer? Equality test(x,y) zero eq; How to flip eq;产equality on check the test x flip eq; equality of test y flip eq;equality on only tum twice two bits? Can you extend it to check the equality of two 32-bit binary numbers? Assume,X =x31,x30,..,x,Y=y31,y30,...,yo
2022/12/14 6 What is Computer? How to check the equality of two bits? Assume, 𝑋 = 𝑥31, 𝑥30, … , 𝑥0 , 𝑌 = 𝑦31, 𝑦30, … , 𝑦0 Can you extend it to check the equality of two 32-bit binary numbers?
Another "complicated"example Operations allowed to use add(x,y) How to flip,zero,test 1.zero z0 calculate exit,goto 2.zero z1 3.equality test(x,y) the sum of X 4.test eq goto 7 5.flip z0 two 1-bit 6.exit 1, binary 7.zero t 8.flip t number 9.equality test(x,t) 10.test eq flip z1
2022/12/14 7 Another “complicated” example How to calculate the sum of two 1-bit binary number ? flip, zero, test exit, goto Operations allowed to use add(x,y) 1. zero z0 2. zero z1 3. equality test(x,y) 4. test eq goto 7 5. flip z0 6. exit 7. zero t 8. flip t 9. equality test(x,t) 10. test eq flip z1
Another "complicated"example add(x,y) X2X1 How to 1.zero z0 2.zero z1 y2 y1 calculate 3.equality test(x,y) the sum of 4.test eq goto 7 Z2 Z1 Zo 5.flip z0 two 2-bit 6.exit binary 7.zero t YES 8.flip t numbers? 9.equality test(x,t) WE 10.test eq flip z1 CAN
2022/12/14 8 Another “complicated” example How to calculate the sum of two 2-bit binary numbers? add(x,y) 1. zero z0 2. zero z1 3. equality test(x,y) 4. test eq goto 7 5. flip z0 6. exit 7. zero t 8. flip t 9. equality test(x,t) 10. test eq flip z1 𝑥1 𝑦1 𝑥2 𝑦2 𝑧2 𝑧1 𝑧0
Encapsulation Abstraction flip zero test goto exit “Atomic” operations Equality test (x.y) zero eq; add(x,y) can be flip eq;equality on 1.zero z0 test x flip eq; 2.zero z1 combined to test y flip eq;equality on only tum twice 3.equality test(x,y) 4.test eq goto 7 5.flip z0 generate 6.exit 7.zero t “Compound' 8.flip t 2-bitAdd(x,y) 9.equality test(x,t) operations! 10.test eq flip z1 9
2022/12/14 9 Encapsulation + Abstraction “Atomic” operations can be combined to generate “Compound” operations! 2-bitAdd(x,y) flip zero test goto exit …
Encapsulation Abstraction Compound Operations “Atomic” Provide higher functional abstractions operations can be Encapsulate underlying details of implemented by lower operations combined to generate Can be directly used as atomic “Compound' operations operations! Can be further combined to provide new higher compound operations/functions
2022/12/14 10 Encapsulation + Abstraction “Atomic” operations can be combined to generate “Compound” operations! • Provide higher functional abstractions • Encapsulate underlying details of implemented by lower operations • Can be directly used as atomic operations • Can be further combined to provide new higher compound operations/functions Compound Operations