You are on page 1of 27

Lecture #1

ECE 3430 Intro to Microcomputer Systems


Fall 2014
1
ECE 3430 Introduction to Microcomputer Systems
University of Colorado at Colorado Springs
Lecture #1

Agenda Today:

1) Microcomputers, Microprocessors, Microcontrollers
2) Number Systems
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
2
Microcomputers and Terminology
There are lots of confusing terms floating around which dont 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 computerbut a computer
is not a microcomputer.
Other types of computers (not digital in nature):
Analog (slide ruler, abacus, mechanical computers)
Pulse (neural networks)
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
3
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 the processor or central processor unit (CPU).
Microcomputers are typically computers that are developed
around a microprocessor.

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
4
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.
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
5
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 dont 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
microcontrollersin favor of on-chip peripheral devices.

This course will focus on the use of the MSP430 microcontroller
to solve engineering problems (see chip timeline on web).
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
6
Number Systems
Number Base Notation Used in this Course:
Decimal, Base 10 <num> or d<num>
Ex) 11 or d11
Binary, Base 2 0b<num> or b<num> or <num>b
Ex) 0b1011 or b1011 or 1011b
Octal, Base 8 q<num> or <num>q
Ex) q13 or 13q
Hexadecimal, Base 16 0x<num> or h<num> or <num>h
Ex) 0xBD or hBD or BDh
ASCII <chars> or <chars>
Ex) Fred (non-terminated) or Barney (terminated)

The MSP430 assembler and C/C++ compiler will make use of one of the above. Well
discuss assembly, the assembler, and higher-level programming languages (C/C++)
later.
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
7
Number Systems
Base Conversion Binary to Decimal
Each digit has a weight of 2
n
that depends on the position of the
digit.
Multiply each digit by its weight.
Sum the resultant products.

Ex) Convert b1011 to decimal
2
3
2
2
2
1
2
0
(weight)
% 1 0 1 1
= 1(2
3
) + 0 (2
2
) + 1 (2
1
) + 1 (2
0
)
= 1(8) + 0 (4) + 1 (2) + 1 (1)
= 8 + 0 + 2 + 1
= d11
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
8
Number Systems
Base Conversion Binary to Decimal with Fractions
The weight of the binary digits have negative positions.

ex) Convert b1011.101 to decimal

2
3
2
2
2
1
2
0
2
-1
2
-2
2
-3

1 0 1 1 . 1 0 1

= 1(2
3
) + 0 (2
2
) + 1 (2
1
) + 1 (2
0
) + 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
= d11.625
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
9
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 binary

Quotient Remainder
2 11 5 1 LSB
2 5 2 1
2 2 1 0
2 1 0 1 MSB

= b1011

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
10
Number Systems
Base Conversion Decimal to Binary with Fractions
- the fraction is converted to binary separately
- the fraction is multiplied by 2, the 0
th
digit is recorded
- the remaining fraction is multiplied by 2, the 0
th
digit is recorded
- the process is repeated until the fractional part is zero

ex) Convert 0.375 decimal to binary

Product 0
th
Digit
0.3752 0.75 0 MSB
0.752 1.50 1
0.52 1.00 1 LSB

d0.375 = b.011
finished
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
11
Number Systems
Base Conversion Hex to Decimal
- the same process as binary to decimal except the weights are now BASE 16
- NOTE (hA=d10, hB=d11, hC=d12, hD=d13, hE=d14, hF=d15)

ex) Convert h2BC to decimal

16
2
16
1
16
0
(weight)
2 B C

= 2 (16
2
) + B (16
1
) + C (16
0
)
= 2(256) + 11 (16) + 12 (1)
= 512 + 176 + 12
= d700
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
12
Number Systems
Base Conversion Hex to Decimal with Fractions
- the fractional digits have negative weights (BASE 16)
- NOTE (hA=d10, hB=d11, hC=d12, hD=d13, hE=d14, hF=d15)

ex) Convert h2BC.F to decimal

16
2
16
1
16
0
16
-1
(weight)
2 B C . F

= 2 (16
2
) + B (16
1
) + C (16
0
) + F (16
-1
)
= 2(256) + 11 (16) + 12 (1) + 15 (0.0625)
= 512 + 176 + 12 + 0.938
= d700.938
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
13
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

1
st
, convert the integer part

Quotient Remainder
16 420 26 4 LSB
16 26 1 10
16 1 0 1 MSB
= h1A4
2
nd
, convert the fractional part
Product 0
th
Digit
0.62516 10.00 10 MSB
= h.A
d420.625 = h1A4.A
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
14
Number Systems
Base Conversion Octal to Decimal / Decimal to Octal

The same procedure is used as before but with BASE 8 as the divisor/multiplier
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
15
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 hABC to binary

A B C


= 1010 1011 1100

= b1010 1011 1100

Octal to Binary works the same except using groups of three binary
bits which represent 4, 2, and 1.

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
16
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 0s

ex) Convert b1100101111 to hex

= 0011 0010 1111



3 2 F
= h32F

Binary to Octal works the same way using groups of 3 binary bits.

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
17
Number Systems
Binary Addition
- same as BASE 10 addition
- need to keep track of the carry bit

ex) Add b1011 and b1001

1 1
1 0 1 1
1 0 0 1
+________
1 0 1 0 0


Carry Bit
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
18
Number Systems
Ways to represent integer signed values:
Sign-Magnitude (historical): b1111 1111 = d-127
0 and -0 can be represented.
8-bit range: -127 to 127
Number line: 0,1,,127,-0,-1,,-127 <repeat>
Ones Complement (historical): b1111 1111 = d-0
0 and -0 can be represented.
8-bit range: -127 to 127
Number line: 0,1,,127,-127,-126,,-0 <repeat>
Twos Complement (used today): b1111 1111 = d-1
Only one 0 representation.
Always one more negative value than positive.
8-bit range: -128 to 127
Number line: 0,1,,127,-128,-127,-1 <repeat>
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
19
Number Systems
Twos Complement
- this encoding was chosen to represent negative numbers in modern computers
- this way we can use adding circuitry to perform subtraction (easily)
- 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: b0000 1111 is positive number)
Negative #s : MSB = 1 (ex: b1000 1111 is negative number)

- the range of #s that a twos complement code can represent is:

(-2
n-1
) < N < (2
n-1
1) : n = number of bits

ex) What is the range of #s that an 8-bit twos complement code can represent?

(-2
8-1
) < N < (2
8-1
1)
(-128) < N < (+127)
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
20
Number Systems
Twos Complement Negation
- to take the twos complement of a positive number (i.e., find its negative equivalent)

Nc = 2
n
N Nc = Twos Complement
N = Original Positive Number

ex) Find the 8-bit twos complement representation of 52dec

N = +52dec

Nc = 2
8
52 = 256 52 = 204 = b1100 1100


Note the Sign Bit
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
21
Number Systems
Twos Complement Negation (a second method)
- to take the twos 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 twos complement representation of 52dec

N = +52dec = b0011 0100

Invert: = 1100 1011
Add 1 = 1100 1011
+ 1
--------------------
b1100 1100 (-52dec)
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
22
Number Systems
Twos Complement Negation (a third method)

1. Begin with the original positive value.
2. Change all of bits to the left of the right-most 1 to the opposite state. Done.

ex) Find the 8-bit twos complement representation of 52dec

N = +52dec = b0011 0100

right-most 1
b1100 1100 (-52dec)

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
23
Number Systems
Twos Complement Addition

- Addition of twos complement numbers is performed just like
standard binary addition.

- However, the carry bit is ignored.
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
24
Number Systems
Twos Complement Subtraction
- now we have a tool to do subtraction using the addition algorithm

ex) Subtract d8 from d15

d15 = b0000 1111

d8 = b0000 1000 -> twos complement -> invert 1111 0111
add1 1111 0111
+ 1
-----------------
1111 1000 = d-8
Now Add: 15 + (-8) = 0000 1111
1111 1000
+_________
1 0000 0111 = d7
Disregard Carry
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
25
Number Systems
Twos Complement Overflow
- If a twos 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 (cant 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.
Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
26
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.

Decimal BCD
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

Lecture #1
ECE 3430 Intro to Microcomputer Systems
Fall 2014
27
Number Systems
ASCII
American Standard Code for Information Interchange.
English alphanumeric characters are represented with a 7-bit code.


ex) A = h41
a = h61

There are ASCII tables everywhere. Google it.

Unicode
Supports text expressed in most of the worlds writing systems.
Each character represented by one or more bytes.
UTF-8, UTF-16 are most popular today.
UTF-8 is ubiquitous on the World-Wide Web (avoids complications arising from
byte-ordering).

You might also like