Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Which of the transistors below are on? 9kΩ A 5V 1kΩ 9kΩ B 5V 1kΩ -5V C 6V 4V D 2V Submit your answer on menti.com with code 24 34 75 ENGR 40M, Lecture 10: From logic gates to computers Steven Bell 17 July 2016 Two levels of thinking about transistors Voltage/circuit level Transistor only "knows" voltages across its pins. An NMOS turns on when VGS > Vth A PMOS turns on when VGS < -Vth Logic-level Assume: NMOS source → Vdd, PMOS source → Gnd Assume: Inputs are HIGH (1, Vdd) or LOW (0, Gnd) Then: An NMOS turns on when input is high A PMOS turns on when input is low Time taken on homework: <= 1 hour <= 2 hours <= 3 > 3 hours By the end of today, you should be able to: Represent numbers using binary, with 2's complement for negative values Explain the various datatypes in Arduino, and predict overflow/underflow Take a keyboard apart (and figure out how it works). Binary numbers Convert the following decimal numbers to binary: 4, 19, 63, 256 Convert the following binary numbers to decimal: 10001, 10101, 00111, 11111111 overflow! 0000 1111 1110 1101 14 15 13 1011 1 0010 2 3 binary integer 12 1100 0 0001 4 5 11 1010 10 9 1001 8 1000 0011 7 6 0100 0101 0110 0111 To write a negative number in 2's complement: Write the positive number in binary Flip all the bits (1→0, 0→1) Add 1 (with all the appropriate carries) To convert negative 2's complement to decimal, Flip all the bits (1→0, 0→1) Add 1 (with all the appropriate carries) Write the number in decimal unsigned overflow 1111 0000 0001 0010 15 0 1 2 14 -1 0 1 0011 1101 2 -2 3 13 -3 3 binary unsigned 1100 12 -4 4 4 0100 signed 5 -5 5 0101 11 6 1011 -6 6 10 -7 -8 7 0110 7 9 1010 8 1110 1001 1000 0111 signed overflow Convert the following decimal numbers to binary, using 8-bit 2's complement: -1, -12, -128, 4 Convert the following 8-bit 2's complement binary numbers to decimal: 1000 0011, 0000 1011, 1111 1100 _ _ _ If you have 8 bits: What is the largest signed number you can represent? Smallest (most negative) signed number? Casting from one data type to another doesn't change the bits. unsigned char x = 253; char y = x; print(y); When you add more bits, the number shouldn't change... char x = -1; int y = x; print(y); Building an adder xkcd.com/571 Breaking break: Keyboards!