Microprocessor and Microcontroller Architecture



Similar documents
Instruction Set Architecture (ISA)

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

CHAPTER 4 MARIE: An Introduction to a Simple Computer

CPU Organization and Assembly Language

Central Processing Unit (CPU)

İSTANBUL AYDIN UNIVERSITY

CHAPTER 7: The CPU and Memory

MICROPROCESSOR AND MICROCOMPUTER BASICS

Instruction Set Design

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University

Chapter 2 Logic Gates and Introduction to Computer Architecture

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

LSN 2 Computer Processors

Computer Organization and Architecture

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

Microprocessor or Microcontroller?

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Processor Architectures

CHAPTER 6: Computer System Organisation 1. The Computer System's Primary Functions

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

The Central Processing Unit:

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

The AVR Microcontroller and C Compiler Co-Design Dr. Gaute Myklebust ATMEL Corporation ATMEL Development Center, Trondheim, Norway

Microcontroller Basics A microcontroller is a small, low-cost computer-on-a-chip which usually includes:

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Question Bank Subject Name: EC Microprocessor & Microcontroller Year/Sem : II/IV

Chapter 2 Basic Structure of Computers. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Management Challenge. Managing Hardware Assets. Central Processing Unit. What is a Computer System?

Design Cycle for Microprocessors

MICROPROCESSOR BCA IV Sem MULTIPLE CHOICE QUESTIONS

Computer Architectures

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

8051 MICROCONTROLLER COURSE

MACHINE ARCHITECTURE & LANGUAGE

Module 2. Embedded Processors and Memory. Version 2 EE IIT, Kharagpur 1

Chapter 1 Computer System Overview

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

8051 hardware summary

Administrative Issues

Week 1 out-of-class notes, discussions and sample problems

Microtronics technologies Mobile:

PROBLEMS. which was discussed in Section

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

2.0 Command and Data Handling Subsystem

CPU Organisation and Operation

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

ARM Microprocessor and ARM-Based Microcontrollers

Chapter 13. PIC Family Microcontroller

Microcontrollers Figure 26-1 Objectives Key Words and Terms 26.1 OVERVIEW OF THE MICROCONTROLLER microcontroller

COMPUTER ORGANIZATION AND ARCHITECTURE. Slides Courtesy of Carl Hamacher, Computer Organization, Fifth edition,mcgrawhill

Computer Architecture Basics

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

Learning Outcomes. Simple CPU Operation and Buses. Composition of a CPU. A simple CPU design

An Overview of Stack Architecture and the PSC 1000 Microprocessor

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

EMBEDDED SYSTEM BASICS AND APPLICATION

Chapter 5, The Instruction Set Architecture Level

CISC, RISC, and DSP Microprocessors

Intel 8086 architecture

1 Classical Universal Computer 3

OVERVIEW OF MICROPROCESSORS

PART B QUESTIONS AND ANSWERS UNIT I

picojava TM : A Hardware Implementation of the Java Virtual Machine

Chapter 6. Inside the System Unit. What You Will Learn... Computers Are Your Future. What You Will Learn... Describing Hardware Performance

Building A RISC Microcontroller in an FPGA

Open Architecture Design for GPS Applications Yves Théroux, BAE Systems Canada

Basic Computer Organization

RAM & ROM Based Digital Design. ECE 152A Winter 2012

Computer organization

Microprocessor & Assembly Language

CHAPTER 2: HARDWARE BASICS: INSIDE THE BOX

Handout 17. by Dr Sheikh Sharif Iqbal. Memory Unit and Read Only Memories

Let s put together a Manual Processor

Von der Hardware zur Software in FPGAs mit Embedded Prozessoren. Alexander Hahn Senior Field Application Engineer Lattice Semiconductor

Digitale Signalverarbeitung mit FPGA (DSF) Soft Core Prozessor NIOS II Stand Mai Jens Onno Krah

Computer and Set of Robots

UNIVERSITY OF CALIFORNIA, DAVIS Department of Electrical and Computer Engineering. EEC180B Lab 7: MISP Processor Design Spring 1995

Chapter 1 Lesson 3 Hardware Elements in the Embedded Systems Chapter-1L03: "Embedded Systems - ", Raj Kamal, Publs.: McGraw-Hill Education

Software based Finite State Machine (FSM) with general purpose processors

================================================================

ASSEMBLY PROGRAMMING ON A VIRTUAL COMPUTER

7a. System-on-chip design and prototyping platforms

RISC AND CISC. Computer Architecture. Farhat Masood BE Electrical (NUST) COLLEGE OF ELECTRICAL AND MECHANICAL ENGINEERING

Pentium vs. Power PC Computer Architecture and PCI Bus Interface

Computer Systems Design and Architecture by V. Heuring and H. Jordan


(Refer Slide Time: 00:01:16 min)

Programming Logic controllers

Building a computer. Electronic Numerical Integrator and Computer (ENIAC)

Introduction to RISC Processor. ni logic Pvt. Ltd., Pune

DS1104 R&D Controller Board

Instruction Set Architecture (ISA) Design. Classification Categories

ELE 356 Computer Engineering II. Section 1 Foundations Class 6 Architecture

Hardware: Input, Processing, and Output Devices. A PC in Every Home. Assembling a Computer System

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

Instruction Set Architecture

Computer Organization

Chapter 4 System Unit Components. Discovering Computers Your Interactive Guide to the Digital World

Transcription:

Microprocessor and Microcontroller Architecture 1

Von Neumann Architecture Stored-Program Digital Computer Digital computation in ALU Programmable via set of standard instructions input memory output Internal storage of data Internal storage of program Automatic Input/Output Automatic sequencing of instruction execution by decoder/controller controller Arithmetic Logic Unit (ALU) Von Neumann Architecture Data and instructions stored in a single memory unit Harvard Architecture Data and instructions stored in a separate memory units data/instruction path control path 2

Memory Hierarchy Levels of data / memory storage Data and instructions of "all" programs "All" data and instructions of running programs Copy small section of Main Memory for faster access Fastest access to small amount of data Access by OS call Width = allocation unit Access by address Width = byte Access by address Width = byte Access by name Width = word μp: External μc: External μp: External μc: Internal μp: Internal μc: μp: Internal μc: Virtual Long Term Storage Main Memory (RAM) Cache Register All Files and Data Running Programs and Data Next Few Instructions and Data Current Data 3

μp Subsystems Microprocessor register memory I/O System long term storage processor control Arithmetic Logic Unit (ALU) network input output I/O control Bus Controller Cache Memory Unit cache memory cache control Main Memory Unit main memory memory control Processor package 4

μc Subsystems Microprocessor data memory long term storage I/O devices processor control Arithmetic Logic Unit (ALU) input output instruction memory timers Controller package 5

Instruction Set Architecture General instruction instance of data structure Operation Operand Operand... Operand Instruction set Range of data structure for Operation {legal actions} Operand {legal addressing modes} Machine instruction Binary code for processing by hardware Assembly instruction User-friendly form of machine instruction Binary code words Typical instruction Machine: 0x82E31F2B Assembly: ADD destination, source_1, source_2 Definition: destination source_1 + source_2 6

General Operations Data transfer Load (r m), store (m r), move (r/m r/m), convert data types Arithmetic/Logical (ALU) Integer arithmetic (+ compare shift) and logical (AND, OR, NOR, XOR) Decimal Integer arithmetic on decimal numbers Floating point (FPU) Floating point arithmetic (+ sqrt trig exp ) String String move, string compare, string search Control Conditional and unconditional branch, call/return, trap Operating System System calls, virtual memory management instructions Graphics Pixel operations, compression/decompression operations 7

Addressing Modes Formal specification Immediate (IMM) Constant = literal = numerical value coded into instruction Register operands register name = a μp storage location REGS[register name] = data stored in register REGS[R3] = data stored in register R3 = 11223340 R3 11223340 Memory operands address = a memory storage location MEM[address] = data stored in memory MEM[11223344] = data stored at address 11223344 = 45 11223344 Effective Address (EA) pointer arithmetic REGS[R3] &(variable) MEM[REGS[R3]+4] = *(&(variable)+4) = *(REGS[R3]+4) = *(11223340+4) = 45 45 8

General Addressing Modes Mode Syntax Memory Access Use Register R3 Regs[R3] Register data Immediate #3 3 Constant Direct (absolute) Register deferred (1001) Mem[1001] Static data (R1) Mem[Regs[R1]] Pointer Displacement 100(R1) Mem[100+Regs[R1]] Local variable Indexed (R1 + R2) Mem[Regs[R1]+Regs[R2]] Array addressing Memory indirect Auto Increment Auto Decrement @(R3) Mem[Mem[Regs[R3]]] Pointer to pointer (R2)+ -(R2) Mem[Regs[R2]] Regs[R2] Regs[R2]+d Regs[R2] Regs[R2]-d Mem[Regs[R2]] Stack access Stack access Scaled 100(R2)[R3] Mem[100+Regs[R2]+Regs[R3]*d] Indexing arrays PC-relative (PC) Mem[PC+value] PC-relative deferred 1001(PC) Mem[PC+Mem[1001]] Load instruction to data register Load instruction to data register 9

Read Only Memory (ROM) Non-volatile memory Permanent configuration data Device initialization code (FIRMWARE) Basic Input/Output System (BIOS) ROM technologies OTP (One-Time Programmable) Cannot be changed after writing EPROM (Erasable Programmable Read-Only Memory) Glass window allows ultraviolet light to erase device EEPROM (Electrical Erasable Programmable Read-Only Memory Can write electrically without prior erase Flash Organized as blocks Read Read any bit in any block Write 0 1 1 0 Overwrite and bit in any block Copy block delete entire block (write 0) overwrite 1 bits 10

General Register Operation Models Register-Memory Model Operands can be stored in any REGISTER or MEMORY location Z = X + Y Easier to program load R1, X add R1, R1, Y store Z, R1 Register- Register Model MEMORY operands must be loaded to a REGISTER Also called LOAD-STORE MODEL Z = X + Y load R1, X load R2, Y add R1, R1, R2 store Z, R1 Easier to implement in hardware Statistics most loaded operands used more than once 11

Running Machine Language Program Program list Instruction 1 Instruction 2 Instruction 3 Instruction 4 Instruction 5 Instruction 6 Instructions in Flat Memory Instruction 5 byte A+11 byte A+10 Instruction 4 byte A+9 byte A+8 Instruction 3 byte A+7 byte A+6 μp Instruction 2 Fetches next instruction in list Decodes fetched instruction Executes decoded instruction Instruction 1 byte byte byte byte byte A+5 A+4 A+3 A+2 A+1 byte A Address 12

Modular Programming (Main + Functions) Build program from separate source files (modules) Each source module edited in a separate file Compile / Assemble source files into separate object files Object code is machine code with symbolic external references Link object files together Create executable file Easier to design, read and understand programs Write most modules in high level language Write critical sections in assembly language Write, debug, and change modules independently main.c compile main.obj link prog.exe f1.asm assemble f1.obj f2.c compile f2.obj load f_std.lib 13

Computer Design Before 1990 Limitations Memory = expensive RAM ~ $5000/MB wholesale in 1977 Compiler = bad Bad error messaging Weak optimization Efficient code write / optimize in assembly language Implications Complex Instruction Set Computer (CISC) Easier assembly programming Closer to high level language Powerful assembly language > 300 instructions > 12 addressing modes > 10 data types Powerful instructions fewer instructions less memory 14

CISC Physical Implementation Machine Language Instruction SUB R1, R2, 100(R3) Microcode Instruction Sequence (Microprogram) ALU_IN R3 ALU 100 ADD Registers IN MAR OUT ALU Operation READ ALU Result Flag ALU_IN MDR System Bus ALU R2 SUB R1 OUT Status Word Decoder IR PC ALU Subsystem + 1 2 3 control OUT MAR MDR PC - program counter IR - instruction register MAR - memory address register MDR - memory data register Address Data Main Memory 15

Run Time and Clock Cycles μp is timed by periodic signal called a clock clock cycle Clock Cycle time is measured in seconds per cycle Instruction requires 1 or more clock cycles to process Clock Rate is cycles per second = Hz (Hertz) Run time = clock cycles to run program seconds per clock cycles clock cycles to run program = clock cycles per second Higher clock rate shorter run time More clock cycles (at constant clock rate) longer run time Clock Cycles Per Instruction (CPI) = lines of microcode 16

CISC Limitations Complex microcode Many instruction types many microcode sequences Complex operations complex decoding and sequencing Central bus organization Permits atomic microcode operations System bus bottleneck Microcode operations execute one-at-a-time Machine instructions execute one-at-a-time Microcode several clock cycles to execute machine instruction Memory access Instruction length Non-uniform Depends on operation complexity Multiple clock cycles to load instruction 17

Computer Design Since 1990 Technological developments Price of RAM $5000 / MByte (1975) $5 / MByte (1990) $0.01 / MByte (2012) Compilers Powerful + efficient + optimized Reduced Instruction Set Computer (RISC) Speed up most common operations Fewer machine instructions with uniform instruction length (in bytes) Ignore performance degradation to other operations Simpler hardware design No microcode No system bus All processors today use RISC technology Pure RISC (PowerPC, Sparc, MIPS, ARM, Arduino, PIC, ) RISC technology for CISC language (Pentium II 4, Centrino, Core) Explicitly parallel RISC (Intel Itanium, IBM mainframes) 18

Typical RISC Instructions Class Instruction Operands Example Transfer Load Store Integer / Float R1 [R2 + offset] [R2 + offset] R1 ALU Arithmetic + Logic Register/Register Register/Immediate R1 R2 + R3 R1 R2 Imm R1 R2 R3 R1 R2 Imm Test & Set Register/Register R1 (R2 > R3) Float + Test & Set Register/Register F1 F2 F3 F1 (F2 F3) Branch Immediate PC PC + Imm Branch Register Register PC R1 Control Branch & Link Conditional Branch Register/Immediate R31 PC PC PC +Imm PC PC + (Imm * (F2 = 0)) 19

Typical RISC Pipeline Stage 1 IF Stage 2 ID Stage 3 EX Stage 4 MEM Stage 5 WB Instruction Fetch Instruction Decode Execute Data Memory Access Write Back Address Instruction Address Data Instruction Memory Data Memory clock cycle 1 2 3 4 5 6 7 8 I 1 IF ID EX MEM WB I 2 IF ID EX MEM WB I 3 IF ID EX MEM WB I 4 IF ID EX MEM WB I 5 IF ID EX MEM I 6 IF ID EX I 7 IF ID I 8 IF 20

Microcontroller (μc) versus Microprocessor (μp) Microprocessor (μp) application General purpose computer Access + process data data output Computational power Programming generality Execution speed Multiple processors for parallel processing Each μp handles thread Microcontroller (μc) application Embedded system Control external hardware operations Cost efficiency Small number of program tasks stored in permanent memory Lowest possible cost Multiple controllers for concurrent control problems Each μc applied to small group of tasks 21

Embedded Processor Core Programmable Logic Devices (PLD/FPGA) Generic programmable integrated circuits Large array of digital circuit blocks User defines logic blocks Truth tables Boolean functions Karnaugh diagrams User defines connections on programmable routing matrix Design copied to ASIC for manufacture ASIC application specific integrated circuit Embedded-processor core μp or μc available on chip as programmable logic block Large embedded system designed on single chip μp or μc works with other digital system blocks System on chip (SoC) 22

Choosing a Microcontroller Generic Requirements Optimum device for given application Device family Uniform ISA Different hardware resources Internal resources Interrupts Type + number of I/O lines (analog and digital) Size of program and data memory Space optimization Smallest footprint at reasonable cost Low power consumption Battery powers applications using microcontrollers Sleep state while microcontroller idle Copy protection Stored program protected against user reading 23

Microcontroller Components Microprocessor core Typically RISC-type μp Memory ROM holds program (FIRMWARE) RAM / registers for data + configuration Usually RAM < ROM Timers Time internal / external events Watchdog timeout resets system if code loop fails Controller I/O Interrupt controller external event grabs processor attention Analog digital converters (A/D and D/A) Digital signal processor (DSP) Serial parallel converters (UART) Oscillator Generates clock signal to synchronize all internal operations 24

Special Purpose Registers Instruction register Holds executing instruction Program counter Points to next instruction Accumulator Associated with ALU operations One operand must be in ACC Result stored in ACC Status register (flags) Set configuration Results of ALU operations Data address register (DAR) Stores data memory addresses Stack pointer Points to last element pushed to stack 25

Reset Initializes microcontroller Sets PC to preset value (init address) Microcontroller starts executing commands from init address Causes of reset Power up Controller resets at startup Manual reset Press reset button Power-glitch reset Detect spike on power supply Brown-out reset Input voltage drops below threshold Watchdog timer (WDT) 26

Power Consumption Low power consumption Most microcontroller applications on battery power Low power chip technology Complementary metal-oxide semiconductor (CMOS) Clock frequency Power consumed only on logic transition 1 0 Higher clock frequency more transitions /second more power Supply voltage Higher supply voltage faster + higher power Sleep state Stop clock 0 transitions /second no power Leave low-power mode by external interrupt or reset Key press Interrupt 27

Common Microcontrollers Applied Micro (was IBM) PowerPC AVR family Atmel AT89 family (Intel 8051 architecture) AT91 family (ARM architecture) 68HC00 family Freescale DSP56800 MPC family MCS 48 (8048 family) Intel MCS 51 (8051 family) MCS 96 (8096 family) Microchip Technology PIC families National Semiconductor COP families Sony SPC families STMicroelectronics ST families Texas Instruments TMS families Toshiba TLCS families Zilog ez8/80/16 families 28