260 likes | 278 Views
ECE 3430 – Introduction to Microcomputer Systems University of Colorado at Colorado Springs. Lecture #1 Agenda Today: 1) Microcomputers, Microprocessors, Microcontrollers 2) Number Systems. Microcomputers and Terminology.
E N D
ECE 3430 – Introduction to Microcomputer SystemsUniversity of Colorado at Colorado Springs Lecture #1 Agenda Today: 1) Microcomputers, Microprocessors, Microcontrollers 2) Number Systems ECE 3430 – Intro to Microcomputer Systems Fall 2009
Microcomputers and Terminology There are lots of confusing terms floating around which don’t always have consistent definitions. Get used to it! What is a microcomputer? • Term which evolved into personal computer (PC)—desktop and laptop. Sometimes just referred to as a computer. • A microcomputer is a computer—but a computer is not a microcomputer. • Other types of computers (not digital in nature): • Analog (slide ruler, abacus, mechanical computers) • Pulse (neural networks) ECE 3430 – Intro to Microcomputer Systems Fall 2009
Microcomputers and Terminology • Other types of digital computers: • Minicomputers (larger than microcomputers) • Mainframe computers (larger than minicomputers) • Supercomputers (biggest and fastest) • Microcomputers have five classic components: • Input (keyboards, mice, touch-screens, etc.) • Output (LCD panels, monitors, printers) • Memory (ROM, RAM, hard drives) • Datapath (performs arithmetic and logical operations [ALU]) • Control (state machine in nature, controls the datapath) • The last two (datapath and control) are usually collectively called theprocessor or central processor unit(CPU). • Microcomputers are typically computers that are developed around a microprocessor. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Microprocessors and Microcontrollers Microprocessor: • A CPU packaged in a single integrated circuit. • Typically employs multiple execution pipelines, data and instruction caches, and other complex logic to get very high execution throughput (lots of “work” done in a given unit of time). Microcontroller: • A computer system implemented on a single, very large-scale integrated circuit. Generally speaking, a microcontroller contains everything in a microprocessor plus on-chip peripheral devices (bells and whistles). • A microcontroller may contain memories, timer circuits, A/D converters, USB interface engines, the kitchen sink, et cetera. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Use Models for Microprocessors/Microcontrollers Microprocessors: • Used in systems that need to do complex calculations (serious number crunching). • Used in systems that need to do calculations very quickly. Microcontrollers: • Typically don’t have overly-complex datapaths and control logic. • Microcontrollers typically live in a system to do one dedicated operation. • Circuits that do complex control operations (not complex calculations) use microcontrollers. The datapath complexity of a microprocessor is often scaled back in microcontrollers—in favor of on-chip peripheral devices. This course will focus on the use of the MC68HC11 microcontroller to solve engineering problems (see chip timeline on web). ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems Number Base Notation Used in this Course: Decimal, Base 10 <nothing> Ex) 11 Binary, Base 2 % Ex) %1011 Octal, Base 8 @ Ex) @13 Hexadecimal, Base 16 $ Ex) $BD ASCII ‘ Ex) ‘z This notation is also used by the HC11 assembler we will be using. We’ll discuss assembly and the assembler later. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems Base Conversion – Binary to Decimal • Each digit has a “weight” of 2n that depends on the position of the digit. • Multiply each digit by its “weight”. • Sum the resultant products. Ex) Convert %1011 to decimal 23 22 21 20 (weight) % 1 0 1 1 = 1•(23) + 0• (22) + 1• (21) + 1• (20)= 1•(8) + 0• (4) + 1• (2) + 1• (1)= 8 + 0+ 2 + 1= 11 Decimal ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems Base Conversion – Binary to Decimal with Fractions • The weight of the binary digits have negative positions. ex) Convert %1011.101 to decimal 23 22 21 20 2-1 2-2 2-3 % 1 0 1 1 . 1 0 1 = 1•(23) + 0• (22) + 1• (21) + 1• (20) + 1• (2-1) + 0• (2-2)+ 1• (2-3)= 1•(8) + 0• (4) + 1• (2) + 1• (1) + 1• (0.5)+ 0• (0.25)+ 1• (0.125)= 8 + 0+ 2 + 1 + 0.5 + 0 + 0.125= 11.625 Decimal ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Decimal to Binary - the decimal number is divided by 2, the remainder is recorded - the quotient is then divided by 2, the remainder is recorded - the process is repeated until the quotient is zero ex) Convert 11 decimal to binaryQuotient Remainder 2 11 5 1 LSB 2 5 2 1 2 2 1 0 2 1 0 1 MSB = %1011 ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Decimal to Binary with Fractions - the fraction is converted to binary separately - the fraction is multiplied by 2, the 0th digit is recorded - the remaining fraction is multiplied by 2, the 0th digit is recorded - the process is repeated until the fractional part is zero ex) Convert 0.375 decimal to binaryProduct 0th Digit 0.375•2 0.75 0 MSB 0.75•2 1.50 1 0.5•2 1.00 1 LSB 0.375 decimal = % .011 finished ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Hex to Decimal - the same process as “binary to decimal” except the weights are now BASE 16- NOTE ($A=10, $B=11, $C=12, $D=13, $E=14, $F=15) ex) Convert $2BC to decimal 162 161 160 (weight) $2 B C = 2• (162) + B• (161) + C• (160) = 2•(256) + 11• (16) + 12• (1) = 512 + 176 + 12= 700 Decimal ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Hex to Decimal with Fractions - the fractional digits have negative weights (BASE 16)- NOTE ($A=10, $B=11, $C=12, $D=13, $E=14, $F=15) ex) Convert $2BC.F to decimal 162 161 160 16-1 (weight) $2 B C . F = 2• (162) + B• (161) + C• (160) + F• (16-1) = 2•(256) + 11• (16) + 12• (1) + 15• (0.0625) = 512 + 176 + 12 + 0.938= 700.938 Decimal ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Decimal to Hex - the same procedure is used as before but with BASE 16 as the divisor/multiplier ex) Convert 420.625 decimal to hex 1st, convert the integer part…Quotient Remainder 16 420 26 4 LSB 16 26 1 10 16 1 0 1 MSB= $1A4 2nd, convert the fractional part…Product 0th Digit 0.625•16 10.00 10 MSB= $ .A 420.625 decimal = $1A4.A ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Base Conversion – Octal to Decimal / Decimal to OctalThe same procedure is used as before but with BASE 8 as the divisor/multiplier ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems (Shortcuts) • Base Conversion – Hex to Binary Each HEX digit is made up of four binary bits which represent 8, 4, 2, and 1 Ex) Convert $ABC to binary $A B C = % 1010 1011 1100 = %1010 1011 1100 Octal to Binary works the same except using groups of three binary Bits which represent 4, 2, and 1. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems (Shortcuts) • Base Conversion – Binary to Hex - every 4 binary bits for one HEX digit - begin the groups of four at the LSB - if necessary, fill the leading bits with 0’s ex) Convert $ABC to binary= % 11 0010 1111 $3 2 F Binary to Octal works the same way using groups of 3 binary bits. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Binary Addition - same as BASE 10 addition - need to keep track of the carry bit ex) Add %1011 and %10011 1% 1 0 1 1 % 1 0 0 1 +________ 1 0 1 0 0 Carry Bit ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement - we need a way to represent negative numbers in a computer - this way we can use “adding” circuitry to perform subtraction - since the number of bits we have is fixed (i.e., 8), we use the MSB as a sign bit Positive #’s : MSB = 0(ex: %0000 1111, positive number) Negative #’s : MSB = 1 (ex: %1000 1111, negative number) - the range of #’s that a two’s complement code can represent is:(-2n-1) < N < (2n-1 – 1) : n = number of bits ex) What is the range of #’s that an 8-bit two’s complement code can represent? (-28-1) < N < (28-1 – 1)(-128) < N < (+127) ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Negation - to take the two’s complement of a positive number (i.e., find its negative equivalent)Nc= 2n – N Nc = Two’s Complement N = Original Positive Number ex) Find the 8-bit two’s complement representation of –52dec N = +52dec Nc= 28 – 52 = 256 – 52 = 204 = %1100 1100 Note the Sign Bit ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Negation (a second method) - to take the two’s complement of a positive number (i.e., find its negative equivalent) 1) Invert all the bits of the original positive number (binary) 2) Add 1 to the result ex) Find the 8-bit two’s complement representation of –52dec N = +52dec = %0011 0100 Invert: = %1100 1011 Add 1 = %1100 1011 + 1 -------------------- %1100 1100 (-52dec) ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Negation (a third method) • Begin with the original positive value. • Change all of bits to the left of the right-most 1 to the opposite state. Done. ex) Find the 8-bit two’s complement representation of –52dec N = +52dec = %0011 0100 right-most 1 %1100 1100 (-52dec) ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Addition- Addition of two’s complement numbers is performed just like standard binary addition - However, the carry bit is ignored ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Subtraction- now we have a tool to do subtraction using the addition algorithm ex) Subtract 8dec from 15dec 15dec = %0000 1111 8dec = %0000 1000 -> two’s complement -> invert %1111 0111 add1 %1111 0111 + 1 ----------------- %1111 1000 = -8decNow Add: 15 + (-8) = %0000 1111 %1111 1000 +_________ % 1 0000 0111 = 7dec Disregard Carry ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Two’s Complement Overflow- If a two’s complement subtraction results in a number that is outside the range of representation (i.e., -128 < N < +127), an “overflow” has occurred. ex) -100dec – 100dec- = -200dec (can’t represent) - There are three cases when overflow occurs 1) Sum of like signs results in answer with opposite sign 2) Negative – Positive = Positive 3) Positive – Negative = Negative - Boolean logic can be used to detect these situations. ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • Binary Coded Decimal- Sometimes we wish to represent an individual decimal digit as a binary representation (i.e., 7-segment display to eliminate a decoder) - We do this by using 4 binary digits.DecimalBCD 0 0000 1 0001 ex) Represent 17dec 2 0010 3 0011 Binary = %10111 4 0100 BCD = %0001 0111 5 0101 6 0110 7 0111 8 1000 9 1001 ECE 3430 – Intro to Microcomputer Systems Fall 2009
Number Systems • ASCII • American Standard Code for Information Interchange • English Alphanumeric characters are represented with a 7-bit code ex) ‘A’ = $41 ‘a’ = $61 • There is an ASCII table in the front of the HC11 Programming Reference Guide. More on Number Systems in Appendix A of Your Text Book. ECE 3430 – Intro to Microcomputer Systems Fall 2009