1 / 65

Microprocessor system design

Microprocessor system design. Lecture 2. Von-Neumann Architecture Instruction execution in Von Neumann Architecture Von Neumann Architecture’s limitation Harvard Architecture Data Representation in computer. Von Neumann Architecture.

trevet
Télécharger la présentation

Microprocessor system design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microprocessor system design Lecture 2 Muhammad Amir Yousaf

  2. Von-Neumann Architecture • Instruction execution in Von Neumann Architecture • Von Neumann Architecture’s limitation • Harvard Architecture • Data Representation in computer Muhammad Amir Yousaf

  3. Von Neumann Architecture • Von Neumann, a mathematician and early computer scientist described a design architecture for electronic digital computer. He was the first to spell out the requirements for a general purpose electronic computer. ‘ The architecture is still alive in the basis of modern computers Muhammad Amir Yousaf

  4. Von Neumann Architecture To Von Neumann, the key to building a general purpose device was in its ability to store the instructions (along with data and temporary results) in it. In a special purpose machine the computational procedure could be part of the hardware. In General purpose computers instructions must be changeable. Instruction are encoded into numeric form and stored in memory Muhammad Amir Yousaf

  5. Von Neumann Architecture • Major organs of Von Neumann architecture: Memory • The arithmetic logic unit • The control unit • The memory • The input-output devices Control Unit ALU Input / Output Muhammad Amir Yousaf

  6. Von Neumann Architecture • Von Neumann general purpose computer is a programmable machine that: • Store a set of coded instruction along with data in its memory. • Respond to instructions in a well defined manner(sequential or told otherwise). • Set of instruction is called program. • Memory can be loaded with new programs. Muhammad Amir Yousaf

  7. Instruction • An instruction is a binary coded command to perform a specific task: • Arithmetic and Logic Instruction. • Looping and decision making. • Transfer of data. • Transfer of control. Muhammad Amir Yousaf

  8. Execution of instruction • Instruction execution in Von Neumann computer • Get the coded instruction. • Decode the instruction. • Get the operand. • Perform the desired operation. • Communicate the results back. Muhammad Amir Yousaf

  9. Components of Von Neumann Computer • Memory: to store program and data. • Instruction Decoder: to decode the binary coded instructions. • Program Counter: to execute instructions in order. • Arithmetic Logic Unit: to perform logical and arithmetic operations. • Inputs/Outputs: to give the results back • Registers: Temporary data storage InstructionDecoder Program counter RAM Input / Outputs ALU Muhammad Amir Yousaf

  10. Instruction Format Instruction Muhammad Amir Yousaf

  11. CPU Execution unit ALU Registers Both data and instructions at the same system bus IR PC Controller Control unit System bus Von Neumann Architechture Memory BU IO units

  12. The number of bits in the execution unit usually denotes the processor’s size For example an 8-bit processor stores 8-bits in registers and performs 8-bit operations in the ALU. Processor Execution unit ALU Registers The execution unit comprise: BU IR PC Controller Controller unit Execution unit - ALU Aritmethic Logic Unit Performs arithmetic (+-*/) and logical calculations - Registers Intermediate storing of results

  13. 2N is the number of adressable memory positions Processor Execution unit ALU Registers BU IR Request PC Acknowlege Controller Unique signals for each processor bus Read/Write Control unit Etc. Bus unit Address (N-1:0) Data (M-1:0) Control System bus

  14. Processor The control unit comprise of: Execution unit ALU Registers BE IR PC Controller Control unit Control unit, Registers • IR, the instruction register • stores the instruction that • is executed • PC, the program counter • stores the adress to • the executing instruction • Controller, controls the other • parts (registers, bus unit • och execution unit

  15. Data ($73) from memory, equalizes the instruction ADD Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Execution unit ALU Registers BU Set the address bus to 10, the control bus to read 73 IO units IR: PC: 10 Read data from address 10 Controller Control unit Instruction executionADD $23,reg1 Fetch instruction

  16. Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Execution unit ALU Registers BU Decode the machine code 73 to an instruction ADD $23,reg1 is the instruction that is to be executed IO units IR: 73 PC: 10 Controller ADD $23,reg1 Control unit $73 Fetch instr. ADD $23,reg1 Instruction decoder Decode instr.

  17. Value from reg1 Data ($55) from memory Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Execution unit ALU Registers BU Set the address bus to $23, the control bus to read IO units IR PC: 10 Controller Read data from address $23 Control unit ADD $23,reg1 Fetch instr. Decode instr. ADD $23,reg1 Fetch operand

  18. The content in memory position ($23)=55 is added with the content in reg1: reg1 +$55 Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Exekveringsenhet ALU Registers BU IO units IR PC: 10 Add reg1 and value from memory Controller Control unit Fetch instr. Decode instr. Fetch operand ADD $23,reg1 Execute

  19. The result of the addition is written to register reg1 reg1 +$55 => reg1 Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Exececution unit ALU Registers BU IO units IR PC: 10 Save the result in register reg1 Controller Control unit Fetch instr. Decode instr. Fetch operand Execute ADD $23,reg1 Write result

  20. Processor Memory 10: $73 (ADD $23,reg1) … 23: $55 Execution unit ALU Registers BU IO units IR PC: 10 Controller Control unit Execution in i five stages Fetch instr. Decode instr. Fetch operand Execute Write result

  21. Von Neumann Limitation • The shared bus between the program memory and data memory leads to the Von Neumann bottleneck. •  Because program memory and data memory cannot be accessed at the same time, throughput is much smaller than the rate at which the CPU can work. • The CPU is continuously forced to wait for needed data to be transferred to or from memory. • For example if we try to read an operand at the same time as we try to read an instruction. This is not possible in the von Neumann architecture since we only have one system bus and cannot address two memory positions simultaneously. Muhammad Amir Yousaf

  22. Other Architectures Harvard Architecture • In the Harvard architecture this is solved by having two separate system buses: • One for instructions • One for data • Data and instructions can be loaded simultaneously, which improves the efficiency. • Means more I/O signals. • More expensive processor. • Uses more power. • Is used internally in modern 32-bit microprocessors and RISC processors. Program Memory Program system Bus CPU Computer Memory IOs Data system Bus Muhammad Amir Yousaf

  23. Components in a microprocessor system Processor Types: • CISC (Complex Instruction Set Computer) • Many instructions to facilitate for assembler programmers and complier constructors. • The drawback is that the compiler uses just a few instructions and the construction of a complex processor becomes slow. • It takes a lot of information to describe an instruction. • For example, MC68040 with 200 instructions and 18 modes of addressing. • Assembler: Different instructions are executed with different speed. Muhammad Amir Yousaf

  24. Components in a microprocessor system Reduced instruction set computing • RISC (Reduced Instruction Set Computer) • Simpler instructions (that is used by the compiler). • Gives a faster implementation. • Only one code word to describe an instruction. • For example, Alpha, ARM, PIC, PowerPC, AVR…. • Assembler: All instructions take 1 clock cycle. Muhammad Amir Yousaf

  25. Components in a microprocessor system Memory: • To store data or instructions the computer system uses a so-called primary memory • The executable program code and data is stored in main memory. • The primary memory is divided in two main parts • RAM • ROM The memory can be seen as a number of post boxes Muhammad Amir Yousaf

  26. Primary Memory RAM CPU ROM I/O unit The outer world/ The user Von Neumann Architecture Microcontrollers • What does a computer system comprise: • Processor (CPU, Central Processing Unit) • Memory • Peripheral units, I/O • System bus, to communicate with peripheral units • If we have a chip that comprise all this it is often called a ‘Micro Controller’ Muhammad Amir Yousaf

  27. Components in a microprocessor system • Data bus • Communication channel to move data to and from CPU and peripheral units. • Address bus • Used to point out which memory position or IO port that is to be read or written. Processor system bus • Control signals • Used to signal when a data transaction starts and stops. • For example signals if a transaction is a read or write operation. Muhammad Amir Yousaf

  28. Data representation

  29. Data Types • Text • ASCII Characters • Strings • Others • Graphics • Images • Video • Audio • Numbers • Integers • Unsigned • Signed • Real data types • Fixed-Point • Floating-Point • Binary-Coded Decimal

  30. Numbers are Different! • Computers use binary (not decimal) numbers (0's and 1's). • Requires more digits to represent the same magnitude. • Computers store and process numbers using a fixed number of digits (“fixed-precision”) after Radix point. • Computers represent signed numbers using 2's complement instead of sign-plus-magnitude (not our familiar “sign-plus-magnitude”).

  31. Positional Number Systems • Numeric values are represented by a sequence of digit symbols. • Symbols represent numeric values. • Symbols are not limited to ‘0’-’9’! • Each symbol’s contribution to the total value of the number is weighted according to its position in the sequence. Integers numbers Fractional numbers

  32. Polynomial Evaluation • Whole Numbers (Radix = 10): • 123410 = 1  103 + 2  102 + 3  101 + 4  100 • With Fractional Part (Radix = 10): • 36.7210 = 3  101 + 6  100 + 7  10-1 + 2  10-2 • General Case (Radix = R): • (S1S0.S-1S-2)R = • S1 R1 + S0 R0 + S-1 R -1 + S-2 R-2

  33. Converting Radix R to Decimal • Example R = 8 • 36.728 = 3  81 + 6  80 + 7  8-1 + 2  8-2 • =24 + 6 + 0.875 + 0.03125 • = 30.9062510 Important: Polynomial evaluation “doesn’t” work if you try to convert in the other direction – I.e., from decimal to something else! Why?

  34. Binary to Decimal Conversion • Converting to decimal, so we can use polynomial evaluation: • 101101012 = 18510 • = 127 + 026 + 125 + 124 + 023 + 122 + 021 + 120 • = 128 + 32 + 16 + 4 + 1 • = 18510

  35. Decimal to Binary Conversion • Converting to binary – can’t use polynomial evaluation! • Whole part and fractional parts must be handled separately! • Whole part: Use repeated division. • Fractional part: Use repeated multiplication. • Combine results when finished.

  36. Decimal to Binary ConversionWhole part: Repeated Division • Divide by target radix (2 in this case) • Remainders become digits in the new representation • (0 <= digit < R) • Digits produced in right to left order (LSB to MSB). • Quotient is used as next dividend. • Stop when the quotient becomes less than divisor, but use the corresponding remainder.

  37. Decimal to Binary ConversionWhole part: Repeated Division • 97  2  quotient = 48, remainder = 1 (LSB) • 48  2  quotient = 24, remainder = 0. • 24  2  quotient = 12, remainder = 0. • 12  2  quotient = 6, remainder = 0. • 6  2  quotient = 3, remainder = 0. • 3  2  quotient = 1, remainder = 1. • 1  2  quotient = 0 (Stop) remainder = 1 (MSB) •  Result = 1 1 0 0 0 0 12 Convert 9710 to a binary number

  38. Decimal to Binary ConversionFractional Part: Repeated Multiplication • Multiply by target radix (2 in this case) • Whole part of product becomes digit in the new representation (0 <= digit < R) • Digits produced in left to right order (MSB to LSB) • Fractional part of product is used as next multiplicand. • Stop when the fractional part becomes zero (sometimes it won’t)

  39. Decimal to Binary Conversion(Fractional Part: Repeated Multiplication) • .1  2  0.2 (fractional part = .2, whole part = 0) • .2  2  0.4 (fractional part = .4, whole part = 0) • .4  2  0.8 (fractional part = .8, whole part = 0) • .8  2  1.6 (fractional part = .6, whole part = 1) • .6  2  1.2 (fractional part = .2, whole part = 1) • Result = .000110011001100112….. • (How much should we keep?) Convert 0.110 to a binary number • Some fractional numbers have an exact representation in one number system, but not in another! • E.g., 1/3rd has no exact representation in decimal, but does in base 3!

  40. Copy digits to the left 3+1<10 Add 1 to next digit 9+1=10 123 + 1 124 129 + 1 130 Write down zero in first position Counting • Principle is the same regardless of radix. • Add 1 to the least significant digit. • If the result is less than R, write it down and copy all the remaining digits on the left. • Otherwise, write down zero and add 1 to the next digit position, etc.

  41. Counting in Binary • Note the pattern! • LSB (bit 0) toggles on every count. • Bit 1 toggles on every second count. • Bit 2 toggles on every fourth count. • Etc….

  42. Question: • Do you trust the used car salesman that tells you that the 1966 Mustang he wants to sell you has only the 13,000 miles that it’s odometer shows? • If not, what has happened? • Why?

  43. Representation Rollover • Rollover is a consequence of fixed precision. • Computers use fixed precision! • Digits are lost on the left-hand end. • Remaining digits are still correct. • Rollover while counting . . . Up: “999999”  “000000” (Rn-1  0) Down: “000000”  “999999” (0  Rn-1 ) The old MUSTANG has probably been running 113,000 miles

  44. Rollover in Unsigned Binary • Consider 8 bits used to represent an unsigned integer: • Range: 00000000  11111111 (0  25510) • Incrementing a value of 255 should yield 256, but this exceeds the range. • Decrementing a value of 0 should yield –1, but this exceeds the range. • Exceeding the range is known as overflow.

  45. Rollover is not synonymous with overflow! • Rollover describes a pattern sequence. • Overflow describes an arithmetic behavior. • Whether or not rollover causes overflow depends on how the patterns are interpreted as numeric values! • E.g., In signed two’s complement representation, 11111111 00000000 corresponds to counting from minus one to zero. • This is rollover, but not overflow • E.g., In signed two’s complement representation, 01111111 10000000 corresponds to counting from 127 to minus -128 • This is overflow, but not rollover

  46. Hexadecimal Numbers(Radix = 16) • The number of digit symbols is determined by the radix (e.g., 16) • The value of the digit symbols range from 0 to 15 (0 to R-1). • The symbols are 0-9 followed by A-F. • Conversion between binary and hex is trivial! • Use as a shorthand for binary (significantly fewer digits are required for same magnitude). • Hexadecimal numbers are sometimes indicated using $, e.g. $00FF, or with an index H, e.g. 00FFH • In program languages such as C, the representation 0x is used to indicate a hexadecimal numeric constants and \x may be used for character and string constants.

  47. Memorize This!

  48. Binary to Hex Conversions • Hex digits are in one-to-one correspondence with groups of four binary digits: • 0011 1010 0101 0110 . 1110 0010 1111 1000 • 3 A 5 6 . E 2 F 8 • Conversion is a simple table lookup! • Zero-fill on left and right ends to complete the groups! • Works because 16 = 24 (power relationship)

  49. Interpretations of Numbers signed unsigned 16710 101001112 -8910 • Signed vs. unsigned is a matter of interpretation; thus a single bit pattern can represent two different values. • Do we need both interpretations? • Why aren't all numbers represented as signed? • Some data (e.g., count, age) can never be negative, and having a greater range is useful.

  50. Which is Greater: 1001 or 0011? • Answer: It depends! • So how does the computer decide: • “if (x > y)..” /* Is this true or false? */ • It’s a matter of interpretation, and depends on how x and y were declared: signed? Or unsigned? • In C/C++ the compiler decides which instruction to use depending on the declaration of the integer. • In assembly language, it is the programmers responsibility to chose the correct instruction.

More Related