Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECE 3561 - Lecture 1 1 Binary number system Department of Electrical and Computer Engineering The Ohio State University ECE 2560.

Similar presentations


Presentation on theme: "ECE 3561 - Lecture 1 1 Binary number system Department of Electrical and Computer Engineering The Ohio State University ECE 2560."— Presentation transcript:

1 ECE 3561 - Lecture 1 1 Binary number system Department of Electrical and Computer Engineering The Ohio State University ECE 2560

2 ECE 3561 - Lecture 1 2 Today Number systems To and from base 10 Addition Subtraction (made easy) Multiplication THIS LECTURE IS REVIEW MATERIAL

3 We live in a base 10 world Why base 10? Could have been base 5 or base 20. We can thank Ug! the caveman. In base 10 we have 10 symbols 0 1 2 3 4 5 6 7 8 9 In any number base system you have n symbols Base 2 – 0 1 Base 8 - 0 1 2 3 4 5 6 7 Base 16 – 0 1 2 3 4 5 6 7 8 9 A B C D E F ECE 3561 - Lecture 1 3

4 Other number bases Number system base Base 10 § § § § § § § § § § § § § 0 1 2 3 4 5 6 7 8 9 10 11 12 13 Base 2 § § § § § § § § § § 0 1 10 11 100 101 110 111 1000 1001 1010 ECE 3561 - Lecture 1 4

5 Base 5 and Base 8 Base 5 (would have digits 0 to 4) § § § § § § § § § § § § § 0 1 2 3 4 10 11 12 13 14 20 21 22 23 Base 8 (octal) § § § § § § § § § § § § § 0 1 2 3 4 5 6 7 10 11 12 13 14 15 ECE 3561 - Lecture 1 5

6 To and from base Base 10 to binary (base 2) Number in Base 10 19 10 = ? Procedure (Integer division) Divide by 2 19/2 = 9 r1 9/2 = 4 r 1 4/2 = 2 r 0 2/2 = 1 r 0 1/ 2 = 0 r 1 So the binary of 19 10 is 1 0 0 1 1 (In general for any number base you divide by the number system base and use the remainders) More examples? ECE 3561 - Lecture 1 6

7 Another How about 139 10 = ? Again divine by 2 each time So have 1 0 0 0 1 0 1 1 More Examples? ECE 3561 - Lecture 1 7

8 Base 2 to base 10 In first example have 1 0 0 1 1 In binary the digits have the following weight Value 10 =a 4 *2 4 +a 3 *2 3 +a 2 *2 2 +a 1 *2 1 +a 0 *2 0 Value 10 =a 4 *16+a 3 *8+a 2 *4+a 1 *2+a 0 *1 So here 1 0 0 1 1 = 1*16 +0*8 +0*4 +1*2 +1*1 = 19 ECE 3561 - Lecture 1 8

9 2 nd example Had 1 0 0 0 1 0 1 1 (written msb to lsb) Value of positions is (lsb to msb) 1,2,4,8,16,32,64,128,256,512,… The powers of 2 Value of the number above = 128 + 8 + 2 + 1 = 139 ECE 3561 - Lecture 1 9

10 Binary addition Follow the same rules as base 10 carries -> 1 1 1 1 1 1 0 0 1 0 0 1 1 1 (7) 0 0 0 1 0 0 1 0 1 1 (11) 1 1 0 1 1 1 0 0 1 0 (18) More examples? ECE 3561 - Lecture 1 10

11 Binary subtraction Set the problem And we need to borrow – step 1 ECE 3561 - Lecture 1 11

12 Binary subraction The next steps work through to To allow answer to be done ECE 3561 - Lecture 1 12

13 Binary multiplication Just like multiplication in base 10 More examples? ECE 3561 - Lecture 1 13

14 2’s complement For 4 bits can represent values -8 to 7 In general can represent -2 n-1  n  2 n-1 - 1 ECE 3561 - Lecture 1 14

15 Arithmetic with 2’s complement Add 5 and -3 ECE 3561 - Lecture 1 15

16 Finding the 2’s complement To generate the 2’s complement of n Say n is 3 3 in binary (4 bits) is 0011 Procedure 1) Take the 1’s complement, then add 1 1’s complement – complement all bits 0011  1100 +1 = 1101 2) Starting at the lsb (rightmost) bit Keep the 1 st 1 and then complement the rest of the bits. Can easily see on previous example. ECE 3561 - Lecture 1 16

17 Subtraction via 2’s complement 14 – 6 (need 5 bits to represent in 2’s complement form) 01110 – 00110 or 01110 + 11010 (i.e. 14 + (-6)) 01110 +11010 01000 and a carry out of 1 value is 8 ECE 3561 - Lecture 1 17

18 Operating in 2’s complement In general can represent -2 n-1  n  2 n-1 - 1 So with 4 bits can represent values of -8  n  +7 So with 8 bits can represent values of -128  n  +127 So with 16 bits can represent values of -32768  n  +32767 ECE 3561 - Lecture 1 18

19 A look at the MSP430 The chip – The MSP430F2003 ECE 3561 - Lecture 1 19

20 The pins Vcc and Vss – Power and Ground being supplied to the chip. The data sheet specifies the tolerance on the voltage supply. P1.0-P1.7,P2.6,P2.7 are for digital input, grouped into 2 digital ports, P1 and P2 TACLK, TA0, TA1 are associated with the Timer_A. More details to come. ECE 3561 - Lecture 1 20

21 The Pins (2) A0-, A0+ up to A4- and A4+ are inputs to the analog-to-digital converter. There are 4 channels and each has it own + and – input. Another pin, VREF is the reference voltage for the converter. ACLK and SMCLK are outputs of clock signals and can be used to supply external devices with a clock. XIN and XOUT are the connections for a crystal. RST’ – is the active low reset signal (could also be designated _RST or /RST) ECE 3561 - Lecture 1 21

22 The Pins (3) NMI – the nonmaskable interrupt. Interrupts allow an external device to assert a value on this pin (a low) that causes the processor to halt operation after completion of the current instruction and ‘service’ the interrupt. When service is complete a software instruction allows resumption of normal operation. There are no maskable interrupts ECE 3561 - Lecture 1 22

23 The Pins (4) TCK, TMS, TCLK, TD1, TD0 and TEST form the full JTAG interface used to program and debug the device. SBWTDIO and SBWTCK provide the Spy- By-Wire interface which is an alternative to JTAG and uses only the 2 pins. NOTE: each of the pins serves multiple purposes. The actual mode for each pin will vary across application and within a given application the use can be multiplexed. ECE 3561 - Lecture 1 23

24 ECE 3561 - Lecture 1 24 Assignment Read Chapter 1 and 2 READ FOR UNDERSTANDING Bring your questions to class Assignments will be due 2 classes after assigned to the drop box on Carmen. No paper submissions – all are electronic. Next time – the internal structure of the MSP 430 and start assembler coding Go to ti.com – order launchpad – get Code Composer Studio Quiz next Monday at start of class. Go to wikipedia.com and read on von Neuman architecture. Write a 1 page summary and submit to drop box, HW1


Download ppt "ECE 3561 - Lecture 1 1 Binary number system Department of Electrical and Computer Engineering The Ohio State University ECE 2560."

Similar presentations


Ads by Google