1 / 24

Binary number system

ECE 2560. Binary number system. Department of Electrical and Computer Engineering The Ohio State University. Today. Number systems To and from base 10 Addition Subtraction (made easy) Multiplication THIS LECTURE IS REVIEW MATERIAL. We live in a base 10 world.

alesia
Download Presentation

Binary number system

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  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

  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

  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

  6. To and from base • Base 10 to binary (base 2) • Number in Base 10 • 1910 = ? • Procedure (Integer division) • Divide by 2 19/2 = 9 r 1 • 9/2 = 4 r 1 • 4/2 = 2 r 0 • 2/2 = 1 r 0 • 1/ 2 = 0 r 1 • So the binary of 1910 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

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

  8. Base 2 to base 10 • In first example have 1 0 0 1 1 • In binary the digits have the following weight • Value10=a4*24+a3*23+a2*22+a1*21+a0*20 • Value10=a4*16+a3*8+a2*4+a1*2+a0*1 • So here • 1 0 0 1 1 = 1*16 +0*8 +0*4 +1*2 +1*1 • = 19 ECE 3561 - Lecture 1

  9. 2nd 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

  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

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

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

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

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

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

  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 1st 1 and then complement the rest of the bits. Can easily see on previous example. ECE 3561 - Lecture 1

  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

  18. Operating in 2’s complement • In general can represent • -2n-1£ n £ 2n-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

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

  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

  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

  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

  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

  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 ECE 3561 - Lecture 1

More Related