Title: EE1A2 Microprocessor Systems
1EE1A2Microprocessor Systems Digital Logic
- Part A
- Digital Electronic System Design
- Written by Dr. Tim Collins
- Edited and presented by Dr Sandra I. Woolley
2Content
- Binary Arithmetic
- Addition and subtraction.
- Arithmetic circuits.
- Arithmetic Logic Units
- Microcontrollers
- Microcontroller architecture.
- Essential building blocks of a computer.
- Programming
3Binary Arithmetic
- Number Systems
- Decimal
- Binary
- Hexadecimal
- Addition
- Long addition
- Full adder circuits
- Parallel adders
- Carry-look-ahead circuitry
- Subtraction
- Twos complement
- Subtraction using a parallel adder
4Arithmetic Logic Units
- Adder-Subtraction Circuit
- Combining addition and subtraction in a single
controllable circuit - Arithmetic Logic Units
- General-purpose arithmetic and logic
calculation units - Registers
- How memory circuits can simplify the connections
to an ALU
5The Anatomy of a Microcontroller
- Tri-State Ports and Busses
- How a bus can interconnect many different
registers without huge wiring difficulties. - Connecting an ALU to a Bus
- The Building Blocks of a Computer
- ALU
- Registers
- I/O Ports
- Program Memory
- Programs
6Number Systems Decimal
- Base 10
- Ten digits, 0-9
- Columns represent (from right to left) units,
tens, hundreds etc.
7Bases
- When counting upwards in base-10, we increase the
units digit until we get to 10 when we reset the
units to zero and increase the tens digit. - So, in base-n, we increase the units until we get
to n when we reset the units to zero and increase
the ns digit. - Consider hours-minutes-seconds as an example of a
base-60 number system
Eg. 125843 000320 130203
- NB. The base of a number is often indicated by a
subscript. E.g. (123)10 indicates the base-10
number 123.
8Binary
- Base 2
- Two digits, 0 1
- Columns represent (from right to left) units,
twos, fours, eights etc.
9Binary Numbers Terminology
- Each digit in a binary number is known as a
bit. - A group of eight bits makes a binary number known
as a byte. - A group of more than eight bits is known as a
word. - Typical word lengths 12, 16, 32, 64.
http//www.thinkgeek.com/tshirts/frustrations/5aa9
/
10Decimal to Binary Conversion
Example Converting (123)10 into binary
123 2 61 remainder 1 61 2 30 remainder
1 30 2 15 remainder 0 15 2 7 remainder
1 7 2 3 remainder 1 3 2 1 remainder
1 1 2 0 remainder 1
11Twos Complement
- One byte (eight bits) can be used to represent
the decimal number range - 0 to 255 (unsigned)
- -128 to 127 (signed)
- Negative binary numbers are formed by subtracting
from a number one greater than the maximum
possible (i.e. 2n or 256 for a byte) - For example,
(123)10 (01111011)2 (-123)10 (10000101)2
(133)10 (256-123)10
12Frequently Asked Question
- So how can you tell the difference between
(-123)10 (10000101)2 and (133)10
(10000101)2
- You cant unless you know whether youre using
signed or unsigned arithmetic
13Hexadecimal
- Base 16
- Sixteen digits, 0-9 and A-F (ten to fifteen)
- Columns represent (from right to left) units,
16s, 256s, 4096s etc.
7B
7161 11160 123
14Decimal to Hex Conversion
Converting (123)10 into hex
123 16 7 remainder 11 (or B) 7
16 0 remainder 7
Answer (123)10 (7B)16
15Binary to Hex / Hex to Binary
Each group of four binary bits maps on to a
single hex digit.
- Even very long numbers can be converted easily,
treating each hex digit independently.
16Binary Arithmetic - Addition
- Binary long addition works just like decimal long
addition.
1
0
0
1
1
1
0
0
1
1
1
0
0
Carried digits
1
Result
17Full Adder
- Each column of the sum has three inputs
- Digits from the two numbers to add (A and B)
- Carry bit from previous column
- It also has two outputs
- Result bit
- Carry bit to next column
- These are the logical operations performed by a
full adder circuit.
18Parallel Adder
- To add two n-bit numbers together, n full-adders
should be cascaded. - Each full-adder represents a column in the long
addition.
19Summary
- In digital electronics, numbers are represented
using base-2 (binary). - Base-16 (hex) is often used by human programmers
as binary to hex conversion is very easy. - Binary numbers may be unsigned or signed (twos
complement). - Binary addition works in a similar way to decimal
long addition.