240 likes | 403 Vues
ELEC1700 Computer Engineering 1 Week 12 Monday lecture Microprocessor systems Semester 1, 2013. Introduction to microprocessor systems Intel 8051. Microprocessor systems. Basic computer organisation. CPU = Central Processing Unit
E N D
ELEC1700Computer Engineering 1Week 12 Monday lectureMicroprocessor systems Semester 1, 2013
Introduction to microprocessor systems Intel 8051 Microprocessor systems
Basic computer organisation • CPU = Central Processing Unit • fetches instructions from memory, decodes and executes instructions • Memory & storage • Non-volatile ROM stores BIOS = lowest level of operating system • RAM stores data used by programs • Buses • Address bus carries memory or I/O locations • Data bus carries memory or I/O contents • Control bus transfers control signals to/from CPU
ELEC2700 — microprocessor system design & interfacing ELEC3720 — design & implement your own microprocessor
Elements of a microprocessor • ALU = arithmetic & logic unit • +, –, ×, /, sin, cos, exp, … • AND, OR, NOT • Register array • Registers store groups of bits in groups of flip-flops • Store temporary results during program execution • Control unit + instruction decoder • State machine • Provides timing and control signals for ALU, instruction decoder, registers and memory
Multi-core processors • Multi-core processors • 2 or more microprocessors (“cores”) on one chip • Cores operate in parallel • Dual-core and quad-core processors are now common
Pipelining • Instructions divided into pipeline stages • Microprocessor executes multiple stages concurrently • Analogy: making pizzas • 3 stages, each 1-minute long • once pipeline is full: 3 people can make pizzas at rate of 1 per minute
Multitasking • Multitasking operating systems (e.g. Windows) switch quickly between many tasks • Programs appear to run simultaneously • Multi-core processors allow fewer tasks per core, with less switching time → faster
High-level language /* Hello World program */ #include<stdio.h> main() { printf ("Hello, world\n"); } Assembly language MOV R7,#0AH MOV P0,#00H LOOP: CPL P0.7 DJNZ R7,LOOP Machine language 00110001 00000000 10010000 Computer programming
assembler High-level language (HLL) Assembly language Machine language compiler “front-end” “back-end” Compilers and assemblers • Role of the assembler is possible to perform manually • compilation of HLL source into efficient assembly language is difficult—the design of optimising compilers is a course in itself
Introduction to microprocessor systems Intel 8051 Microprocessor systems
Fetch, decode, execute • Microprocessor program execution: • Fetch instruction from memory • Decode instruction • If other “operand” information is required by the instruction, fetch it from memory • Execute the instruction • Perform the operation, and return results to registers and memory
Instructions and data Opcode = “operation code” Unique 1-byte code identifying each instruction to the microprocessor
Single- and multi-byte instructions • Single-byte instructions • opcode only • Multi-byte instructions • opcode followed by one or two operand bytes
Programmer’s model of the 8051 • General purpose registers R0,…,R7 • Accumulator A • Program counter PC
General purpose registers • 8-bit general-purpose registers • R0,R1,…,R7 • Registers are used for holding: • temporary results of computations • addresses of data in memory Examples MOV R1,#0F3H Load register R1 with value F3 hexadecimal MOV P3,@R1 Send the contents of RAM, whose address is in register 1, to port 3
Accumulator (A) Processor status Word (PSW) Arithmetic and logic unit (ALU) Accumulator (A) 8-bit accumulator (A) • holds one operand before the arithmetic/logic operation and the result after the operation Example ANL A,R2 Logically AND register R2 (bit by bit) with accumulator, and store result in accumulator
Program counter (PC) PC • 16-bit program counter (PC) keeps track of addresses of instructions and data read from memory • PC is normally incremented by CPU control unit as successive instructions are fetched from memory 8000 : 7FFE16 : 7FFF16 1-byte instruction byte 1 800016 byte 1 800116 2-byte instruction byte 2 800216 : 800316
Some 8051 instructions • uses mnemonic representations for opcodes, data and addresses • abbreviations intended to assist the memory of programmers
Application: microwave oven control Jump to correct address to start program Decide if value in accumulator is zero If A ≠ 0, display accumulator value at port 1 Wait 1 second Decrease accumulator value by 1 Repeat from step 3 until value in accumulator is zero
8051 assembly language example Address contents Assembly language 000002 LJMP 0100H 000101 000200 010060 JZ 010AH 010108 0102F5 MOV P1, A 010390 010412 LCALL 1__SEC__DELAY 010528 010655 010714 DEC A 010870 JNZ 0102H 0109F8
8051-based system • Microcontroller = CPU + RAM + ROM + IO ports on one chip • “Embedded applications”— dishwashers, cameras, electric toothbrushes, vending machines, keyboards, …
8051 microcontroller • Just a few dollars each • $3.88 in single unit quantities http://bit.ly/KtFMoo • Can also buy as an IP core (intellectual property core) for Altera FPGAs and CPLDs http://bit.ly/M4yslc 8051 is the microprocessor used in ELEC2700