200 likes | 520 Views
EE1A2 Microprocessor Systems & Digital Logic. Part I Digital Electronic System Design Dr. T. Collins. Content. Binary Arithmetic Addition and subtraction. Arithmetic circuits. Arithmetic Logic Units Micro-Controllers Micro-controller architecture.
E N D
EE1A2Microprocessor Systems & Digital Logic Part I Digital Electronic System Design Dr. T. Collins
Content • Binary Arithmetic • Addition and subtraction. • Arithmetic circuits. • Arithmetic Logic Units • Micro-Controllers • Micro-controller architecture. • Essential building blocks of a computer. • Programming…
Binary Arithmetic • Number Systems • Decimal • Binary • Hexadecimal • Addition • Long addition • Full adder circuits • Parallel adders • Carry-look-ahead circuitry • Subtraction • Two’s complement • Subtraction using a parallel adder
Arithmetic 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
The Anatomy of a Micro-Controller • 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
123 1´102 + 2´101 + 3´100 or 1 hundred, 2 tens and 3 units Number Systems – Decimal • Base 10 • Ten digits, 0-9 • Columns represent (from right to left) units, tens, hundreds etc.
Bases • 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 n-s digit. • Consider hours-minutes-seconds as an example of a base-60 number system: Eg. 12:58:43 + 00:03:20 = 13:02:03 NB. The base of a number is often indicated by a subscript. E.g. (123)10 indicates the base-10 number 123.
1111011 1´26 + 1´25 + 1´24 + 1´23 + 0´22 + 1´21 + 1´20 = 1´64 + 1´32 + 1´16 + 1´8 + 0´4 + 1´2 + 1´1 = 123 Binary • Base 2 • Two digits, 0 & 1 • Columns represent (from right to left) units, twos, fours, eights etc.
Binary 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.
Decimal to Binary Conversion Least significant bit (rightmost) Most significant bit (leftmost) Answer : (123)10 = (1111011)2 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
Two’s 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
Frequently Asked Question • So how can you tell the difference between: (-123)10 = (10000101)2 and (133)10 = (10000101)2 • You can’t unless you know whether you’re using signed or unsigned arithmetic:
Hexadecimal • Base 16 • Sixteen digits, 0-9 and A-F (ten to fifteen) • Columns represent (from right to left) units, 16s, 256s, 4096s etc. 7B 7´161 + 11´160 = 123
Decimal 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
0111 1011 7 B 1011 1001 0110 1111 1010 E.g. B 9 6 F A Binary 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.
0 1 1 1 0 1 0 1 0 1 Binary 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
B A C IN Full Adder C SUM OUT Full 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.
Parallel Adder • To add two n-bit numbers together, n full-adders should be cascaded. • Each full-adder represents a column in the long addition.
Summary • 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 (two’s complement). • Binary addition works in a similar way to decimal long addition. • Almost all of this should be just revision… • … if not, make full use of the tutorial.