Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture and Hardware Introduction and revision Slides heavily based on Adrian Shaw’s material.

Similar presentations


Presentation on theme: "Computer Architecture and Hardware Introduction and revision Slides heavily based on Adrian Shaw’s material."— Presentation transcript:

1 Computer Architecture and Hardware Introduction and revision Slides heavily based on Adrian Shaw’s material

2 CS25410 Semester 1 75% Examination + 25% Assignment Assignment - Assembly Language Program LC-3 Virtual Computer – 16 bit 2

3 What do we cover? Arithmetic review Logic and Logic Circuit Review CPU/Memory/Bus Multiplexers, Address decoders Machine code Assembly Language/Assembler/Simulator I/O Basic Electricity and Power Storage 3

4 4 Recommended Texts Tocci & Ambrosio: Microprocessors & Microcomputers –Physical Sciences Library: QA76.5.T6 –Note 6 th edition is out, but is a lot more expensive. 5 th edition is fine Patt & Patel: Introduction to Computing Systems – McGraw Hill

5 Let’s talk about numbers 5

6 6 The Digital Computer Computers (as we know them) work on 1’s and 0’s –Nothing else All commands to the CPU are just strings of these All output from the CPU is in strings of these

7 7 So we need to understand binary? Yes. To understand how a computer works, you have to understand how it uses numbers. You should be able to: –Convert from binary to decimal, and vice-versa –Do simple sums in binary Can you do this already? You should be able to! Quick revision….

8 8 Binary Otherwise known as base 2 Each 1 or 0 is called a bit We can string bits together to form a byte A byte is (normally) 8 bits e.g. 10011101 We are not good at reading binary - we like to read numbers as decimal But to understand the computer, we need to understand binary

9 9 Binary to Decimal Taking our example: 10011101 ←Most significant bit …….. Least significant bit→ 10011101 128s64s32s16s8s4s2s1s 1×128 0×640×321×161×81×40×21x1 128+16+8+4+1 = 157

10 10 Decimal to Binary e.g. 201 201-128Yes1 73-64Yes1 9-32No0 9-16No0 9-8Yes1 1-4No0 1-2No0 1Yes1

11 11 Why these numbers? BinaryDecimalPower of 2 100000001282727 1000000642626 100000322525 10000162424 100082323 10042 1022121 112020

12 12 It’s the same method as in Decimal! DecimalPower of 10 100010 3 10010 2 1010 1 110 0

13 13 But Decimal is clumsy 8 bits (1 byte) we can represent 2 8 - 256 - different numbers So we often use hexadecimal (hex for short) Hexadecimal is base 16

14 14 Hexadecimal But there are only ten symbols to represent numbers, how can we manage to represent numbers from 10 to 15 with a single digit? We use the letters A to F So our counting goes… 0 1 2 3 4 5 6 7 8 9 A B C D E F

15 15 Hexadecimal HexDecimalPower of 16 100006553616 4 1000409616 3 10025616 2 101616 1 1116 0

16 16 Why is Hex better? One byte = 8 bits 256 = 2 8 = 16 2 = 10 2.40824 16 = 2 4 This means each four bits can be represented by one hex digit e.g. 10110010 2 = B2 16 Binary10110010 HexB2 Note use of subscript to denote base

17 17 Arithmetic in other bases It’s just like in Decimal, except you have to remember to ‘carry’ at the right point 10 +11 101 101 –11 10 3F +84 C3 43 –2E 15 Binary Hexadecimal

18 18 Arithmetic in other bases (2) If you find that too confusing, you can always: –Convert the numbers to decimal –Do the sums –Convert the answer back to the original base But you might not notice if a carry or a borrow happened; this becomes important later (though there are other ways you can tell)

19 19 Bases - Summary Make sure you can… –Convert between binary, decimal and hex (without a calculator!) –Do simple sums in binary and hex (just addition and subtraction) Tip: Learn to recognise the powers of 2 (2,4,8,16,32,64,128,256) and 16 (16,256) rather than having to work them out each time you need them

20 20 Do it now! I really can’t stress this enough… Don’t wait until revision time; stuff later in the course relies heavily on you knowing this. You may get lost if you don’t do it now.

21 Digital Logic (Revision)

22 22 0’s and 1’s As we have already considered, a computer operates on 0’s and 1’s –Why? Because the power on a line can be either off (0) or on (1). We do not consider in- between values! How does a computer carry out calculations on these 0’s and 1’s? –It uses logic

23 23 Logic By logic, we mean the process of testing the input on one or more input lines, to produce output on one or more output lines We use the terms AND, OR, NOT, NAND, NOR, and XOR

24 24 AND: Truth Table If A AND B are both TRUE –then result is also TRUE ABAB 000 010 100 111 Truth table for AND Note signifies AND

25 25 OR: Truth Table If either A OR B (or both) are TRUE –Then result is TRUE ABA+B 000 011 101 111 Note + signifies OR

26 26 Exclusive OR! Except, beware: If A OR B are TRUE – but NOT both of them –Then result is TRUE This is called the Exclusive OR (XOR) AB ABAB 000 011 101 110

27 27 NOT The simplest of all. It just inverts the input AA 01 10 We signify NOT by a line over the corresponding letter(s)

28 28 NAND This is simply the opposite of AND ABAB 000 010 100 111 AB 001 011 101 110

29 29 NOR Similarly, this is the opposite of OR ABA+B 000 011 101 111 AB 001 010 100 110

30 30 Logic Gates A logic gate is a device (e.g. on a chip) which takes one or more inputs, performs a logical operation on them (such as AND, OR, etc) and produces an output On a circuit diagram, we have special symbols for these

31 31 Logic Gates ANDNANDNOT ORNORXOR

32 32 Multiple Input Logic Gates All the logic gates on the previous slide, except the NOT gate, may have multiple inputs. What do you think the truth table would be for a three-input AND gate?

33 33 Revision Make sure you know what each gate symbol stands for Know the truth tables for each logic gate Learn the digital logic expressions for each gate Again, do it NOW! Don’t wait.

34 Memory How a computer stores information (still revision)

35 35 Basic Computer Architecture processor (CPU) memory I/O devices bus

36 36 What is memory? A collection of individual storage cells These cells are known as locations Each location can store a fixed number of bits Each has a unique address

37 37 Memory example Address (binary) Address (hex) Contents 000000000001100101 000000010110010110 000000100201100010 000000110301110111 000001000411010110 000001010500101110 Example data only

38 38 Hex address We tend to use Hex, it’s easier than binary to remember, and closer related to the binary than decimal is As an assembly language programmer, you will often have to refer to addresses. You will find this out for yourselves later in the course – so get used to it!

39 39 Jargon A byte is (usually) 8 bits of data, e.g. 00101101 For the purposes of this course, we will assume we always mean 8 bits when we talk about a byte Don’t get confused between bytes and bits – it’s easily done. e.g. we talk of a 256 megabyte memory chip, but a 56 kilobit modem or 8 megabit broadband. Remember this when estimating transfer times!!!

40 40 More confusion What is a kilobyte? You’d think it would be 1000 bytes, right? Wrong. Well, usually. A kilobyte is usually 1024 byte (2 10 ) In 2000, the International Electrotechnical Commission defined the terms kibi-, mibi-, gibi- and tebi- byte for 1024 1, 1024 2, 1024 3 and 1024 4 bytes (symbols KiB, MiB, GiB, TiB), but they certainly aren’t universally used

41 41 More jargon A word of memory is the contents of a single memory location So an n-bit word is a word comprising n bits of data, e.g. a 16-bit word, or a 32-bit word An n-bit machine is a processor designed to work mainly with n-bit words Operating systems – 16 bit, 32 bit, 64 bit…

42 42 Basic Memory Unit 1-bit memory enable read/write control data in data out or a single data I/O line

43 43 Basic Memory Unit (2) But we deal with words of memory, and we read or write the whole word at a time So we only need one enable line and one read/write line for the whole word But we still need separate data I/O lines (why?)

44 44 One (4-bit) word of memory 1 bit common enable common read/write control data I/O

45 The Bus A collection of wires which carry data between the CPU, memory and I/O devices

46 46 Components of the Bus Address Bus carries memory address values from the CPU to the memory and I/O Data Bus carries all data, including machine codes, in all directions Control Bus a small number of wires carrying the read/write and enable signals, and a few other “control” signals

47 47 Important Bus Parameters Width of the address bus Determines the size of the address space – i.e. how many locations can be addressed Width of the data bus Determines how much data can be transferred in a single data transfer cycle (thus affecting the speed). Usually the same as the machine (and memory) word size Bus Speed The number of transfers possible per second

48 48 Bus Width An address or data bus that contains n wires, or lines, is said to be n lines wide. Such a bus can carry an n-bit number in a single operation This does not apply to the control bus, as it only needs to carry simple control signals

49 49 Example 8-bit Bus 8 lines physically… but on a circuit diagram…8

50 50 Address Space An n bit address bus can carry any address that fits into an n bit binary number Therefore, it can carry 2 n possible addresses These will be 0 to 2 n -1 e.g. an address bus with 16 lines can address 2 16 (=65536) locations; a 32 line address bus can address 2 32 (=4,294,967,296) locations

51 51 Bus Cycles Bus cycle A single data transfer operation over the bus. The speed of this operation is governed by the bus speed, and affects the speed of the computer Read cycle A bus cycle in which data is read by the CPU from memory or an I/O device Write cycle A bus cycle in which data is written by the CPU to memory or an I/O device

52 52 Example: Bus Read Cycle undefined control bus lines

53 53 Bus Read Cycle t 1 CPU puts address on address bus and sets R/W line to 1 (=read) t 2 CPU asserts Valid Address line on control bus t 3 memory responds by putting data on data bus t 4 CPU reads data from data bus, and stops asserting valid address. Next cycle begins

54 54 Data Throughput The data throughput rate is the number of bytes (or bits) that can be transferred over the bus in one second. Therefore, it is the product of the bus speed (cycles per second) and the data bus width (bits per cycle)

55 55 Data Throughput Example A 16-bit data bus running at 10 million cycles per second (10 Megahertz) has a data throughput rate of 20 million bytes (or 160 million bits) per second Data throughput rate is a major limitation on the speed of a computer. That is why powerful computers have very wide data buses

56 56 Who Controls the Bus? In a simple system, always the CPU –but note DMAC later in this course For each bus cycle, the CPU must: –specify the address –select read or write –supply the data, if it’s a write

57 57 Addressing I/O Devices The Problem all data traffic from the CPU has to go down the data bus all addressing has to go down the address bus –but memory uses this address space already

58 58 Addressing I/O Devices The Solution There are two common ways to solve this problem 1.Give I/O devices a separate address space (how?) 2.Allow I/O devices to share the same address space as memory

59 59 Separate I/O address space Uses the control bus to specify whether we’re addressing memory or I/O Memory responds only if Memory Select is active; I/O only if I/O select is active This method requires the CPU to have separate machine codes for memory and I/O read and writes –Why?

60 60 Same address space When I/O devices share the same address space as memory, it is known as Memory-Mapped I/O I/O devices are given specific addresses in the memory address space. Reads and writes to these addresses access I/O devices instead of memory This does not require separate machine codes, since the value of the address is sufficient to distinguish between I/O and memory

61 61 Test Yourself! 1.What is the data throughput rate, in bytes, of a 32-bit data bus running at 20 Megahertz? 2.How many locations can an 8-bit address bus address? 3.True or false – all buses are bi-directional 4.Can you draw a timing diagram for a bus read cycle, identifying the lines, and the four key time points? 5.What is Memory-Mapped I/O?


Download ppt "Computer Architecture and Hardware Introduction and revision Slides heavily based on Adrian Shaw’s material."

Similar presentations


Ads by Google