tema 1 introduction

Upload: sergio-gomez-lopez

Post on 04-Jun-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Tema 1 Introduction

    1/12

    Topic 1

    Introduction to Digital Electronic Systems

    Index

    1.1. Introduction1.2. Design of Digital Systems

    1.3. Embedded Systems

    1.4. The Microprocessor

    1.5 Internal Architecture of a microprocessor

    1.5.1 Evolution of the microporcessor architecture.

    1.6 Instructions.

    1.7. Input / Output

    1.8. Microprocessor Evolution

    1.9. Developing Tools2

    1.1. Introduction: What is a system?

    3

    1.1. Introduction

    Interacts with the environment

    Is divided into three stages:

    1. Input

    2. Processing

    3. Output

    The processing is based on:

    Combinational logic and sequential circuits

    Microprocessors

    Microcontrollers

    Digital Signal Processor (DSP)

    Programmable logic circuits

    Programmable Logic Controllers (PLCs)

    4

    1.1. Introduction

    Programmable Devices

    The behavior of a chip is ruled by a program

    The same chip can make different actions depending of its program.

    A program is...

    Its a sequential set of instructions that describe, define or characterize

    the execution of a task in a microprocessor

    Instructions are sequentially executed.

    5

    A microcontroller (C) is a chip that includes:

    the processor (P, CPU)

    different types and amounts of memoryand

    various input/output interfaces and peripherals

    All of them interconnected by uni/bidirectional busses

    The main difference between P and C:

    The C includes in a single chip all elements needed in a

    digital system, therefore achieving more integration and lower price.

    1.1. Introduction

  • 8/13/2019 Tema 1 Introduction

    2/12

    More differences between Pand C:

    Lower time to marked when implementing a project in a C

    In former Call operations in the ALU where developed using an accumulator

    The accumulator output is connected to one of the ALUs inputs, being always

    therefore one of the operands

    Instructions with a single operand (c lear, increment, decrement, invert) operate with

    the accumulator

    1.1. Introduction 1.2. Design of Digital Systems

    Combinational/Sequential integrated circuits

    Big space, delays, difficult redesign.

    Full-custom circuits

    Very expensive design, slow process of debugging

    Semi-custom circuits

    ASIC (Application Specific Integrated Circuit)

    Created from standard cells from the library, for a specific application.

    Easy design modification.

    8

    Standard circuits

    ASSP circuits (Application Specific Standard Part).

    Originally designed for a client and then offered to the general public

    Microcontrollers and Microprocessors

    Generic processor with embedded devices for specific applications

    DSPs

    Device for Digital Signal Processing It has been designed for carrying out a small set of operations with a large amount of data.

    9

    1.2. Design of Digital Systems

    Design with microcontroller

    First, we have to know the problem to solve.

    There are many microcontroller chips in the market. We should choose the proper

    microcontroller to solve our problem,

    Microcontroller with a particular subsystem

    Microcontroller with sufficient storage dimmensions

    Microcontroller with proper speed, dimensions,... PCB scheme is designed with the proper connections with other systems.

    Program is designed

    Taking into account the specifications required

    Simulation

    We test that our program solve the problem

    Integration of program and hardware and test of the prototype.10

    1.2. Design of Digital Systems

    Based on programmable devices

    (e.g. microcontrollers, DSPs.)

    In general, they are real-time reactive systems:

    They react to external events

    They keep continuous interaction

    They are continuously running

    Their work is subjected to external time constraints

    They do concurrently several tasks

    1.3. Embedded Systems

    11

    1.3. Embedded Systems

    SupercomputersServersWorkstationsPersonal computersCalculator

    Specific computersPersonal Computers+ I/O boardsPLCsDigital regulators

    Microprocessors-based boards+ I/O boards + VME busPC's + I/O boards + ISA busMicrocontrollers

    Scientific calculationManagement (accounting, etc.)Databases

    Industrial ControlFlight simulatorsRobotics

    Appliances

    AeronauticsMobile roboticsMobile phones

    DO CONTROL / REAL TIME

    EMBEDDED

    NOT

    EMBEDDED

    DO NOT CONTROL

    12

  • 8/13/2019 Tema 1 Introduction

    3/12

    Embedded system examples

    Consumer electronics CD players, HIFI, television, ...

    Washer machines, fridges, dishwashers, ...

    Automotive Speed control, air conditioning, etc.

    ABS, ASR, Electronic fuel injection

    Telecommunications Mobile phone

    Avionics, Space Flying computers

    Path-finder

    Defense Bombs and intelligent missiles

    Vehicles, ...

    Instrumentation

    13

    1.3. Embedded Systems 1.3. Embbeded Systems: Features

    Concurrency

    All the tasks carried out by the system under control work simultaneously

    The control system has to generate simultaneously the control actions

    If there is only on processing unit: multiprocessing techniques are required, by using

    real time operating systems

    It there are several processing units, we are speaking about a multiprocessor solution

    Reliability and safety

    A fault in a control system can drive the controlled system to behave dangerously or

    uneconomical

    It is important to guarantee that if the control system fails, the system remains in a

    safe controlled state: to anticipate potential design errors and exceptions

    14

    Low power

    Many of these systems are powered by batteries.

    Less consumption => greater autonomy

    In many cases low voltage (3V) is needed

    Low weight

    Desirable feature in portable systems

    It not only depends on t he onboard computer and its periphery but also on the sup Low prices

    Related to consumer electronics and other devices with very competitive markets

    Small size

    The dimensions of an embedded system depend not only on i tself but also on the

    space available on the system that controls and / or monitors

    1.3. Embbeded Systems: Features

    15

    From the wired machine to the programmed one

    WIRED:

    Mainly simple logic gates

    According to the inputs it is deterministic, very rigid with constant output

    The technology was introducing more complex logic functions

    Hard its implementation

    A huge amount of integrated circuits is needed (multiplication, division, n order roots)

    At the early 70 the PROGRAMMED MACHINE became only one electronic circuit:

    the MICROPROCESSOR

    1.4. The Microprocessor

    16

    General purpose circuit

    It is a very versatile chip, easy to adapt a multiple applications, limited by the

    designer:

    Logic functions (AND, OR,...)

    If a specific function is not implemented, it can be obtained by the combination of the

    existing ones

    Programmable: it works by means of a set of basic steps

    Each step is called instruction

    Each information element is called data

    Program: it is a structured set of instructions

    If the program is changed, the functionality changes accordingly

    17

    1.4. The Microprocessor

    Advantages of the microprocessor (uP)

    By changing the program a new function is obtained. In wired systems it is required

    to change the design, and some electronic circuits

    Much easier to debug and to optimize applications

    Easy to update versions

    Easy to adapt the design to a different application

    Easy to design digital electronic circuits

    It is possible to work with analog signals by using A/D and D/A converters

    18

    1.4. The Microprocessor

  • 8/13/2019 Tema 1 Introduction

    4/12

    Elements of a P based digital system

    PROGRAM

    MEMORYCPUI/O

    DATA

    MEMORY

    ADDRESS BUS

    DATA BUS

    CONTROL BUS

    1.4. The Microprocessor

    Unidirectional

    Bidirectional

    Power and clock Tri-state

    19

    The P needs memory enough to store both instructionsand data

    (variables and constants) of a program

    Instructions and constant data are stored in non-volatile memories (their contents are

    preserved without power). Called program memory, it can only be read or

    programmed (not written)

    Variable data are stored in volatile memories(their contents are lost with power

    down). Called data memory, it can be read and written

    Big endian/little endian

    1.4. The Microprocessor

    20

    Word size

    It is the size of the a single data that the CPU considers

    Byte

    16 bits

    32 bits.

    Instruction execution time

    1.4. The Microprocessor

    21

    Steps in the execution of an instruction

    Obtaining the instruction to execute (operation code).

    Calculation of the effective address

    Search operands

    Executing operation

    Store the result

    Preparing next instruction.

    MEMORY

    OPERATIONCODE

    CPU

    PC ADD.

    OpcodeI.R.

    Internal architecture

    1.5. Internal architecture of a microprocessor

    Internal architecture

    OPERATIONS THAT A CPU CAN PERFORM:

    LOAD REGISTERS

    READ OR WRITE MEMORY LOCATIONS

    PERFORM ARITHMETIC OR LOGIC OPERATIONS

    ROTATIONS AND SHIFTS

  • 8/13/2019 Tema 1 Introduction

    5/12

    Internal architecture

    OPERATING SECTION

    REGISTERS

    STORE TEMPORARY DATA

    ALU

    LOGIC AND ARITHMETICSOPERATIONS, SHIFTS ANDROTATIONS

    WITH OR WITHOUT

    ACCUMULATOR

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

    Internal architecture

    CONTROL SECTIONLOAD INSTRUCTIONS

    DECODE

    GENERATES MICROORDERS

    ENABLE THE TRANSFER BETWEENTHESE REGISTERS AND CONFIGURETHE ALU OPERATIONS

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

    Internal architectureOTHERS REGISTERS

    AUXILIARY REGISTERS

    STATUS REGISTER

    FLAGS: ZERO, SIGN CARRY,OVERFLOW

    PROGRAM COUNTER

    REGISTER

    STACK POINTER REGISTER

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

    Instruction register

    It loads the operation code from the memory.

    The decoder generates microorders depending on its content.

    Program counter

    It contains the address of the instruction to be executed.

    After execution of an instruction PC is modified to point to the next

    one.

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

    Status register

    It contains flags that provide information on the outcome of an

    operation: sign, zero, carry, overflow.

    It allows decisions conditional on the outcome of the previous

    operation.

    Stack pointer

    It stores a memory address where data can be stored

    automatically or manually.

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

    Internal bus

    Its a communication bus between the various components of the

    microprocessor.

    The number of bus lines is determined by the number of bits

    processed in parallel in the ALU and its one of the parameters to

    classify microprocessors.

    This bus is related to the external data bus through the data bus

    buffer.

    Internal architecture of a microprocessor1.5. Internal architecture of a microprocessor

  • 8/13/2019 Tema 1 Introduction

    6/12

    Microprocessors Architectures: Von-Neuman

    Two busses: Address (ADD) and Data (D).

    Instructions and Data are accessed sequentially through the same

    Data Bus.

    1.5.1. Evolution of microprocessors architecture

    PROGRAM

    AND

    DATA

    MEMORY

    CPU

    ADDRESS BUS

    DATA BUS

    Microprocessors Architectures: Harvard

    Two Address busses, a Data bus and an Instructions bus.

    Fetch the next instruction and move a data at the same time.

    DATA

    MEMORYCPU

    DATA ADD.

    DATA BUS

    PROGRAM

    MEMORY

    PROGRAM ADD.

    INSTRUCTION BUS

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    Pipelining

    Electronics design methodology for processors to overlap the

    execution of different instructions.

    At each pipe stage one par t of the instruction is developed.

    A processor with N stages can run N instructions at the same time,

    increasing N times its efficiency.

    The efficiency increase is obtained just reorganizing instructions, no

    extra effort is needed in the CPU.

    On the other hand the design of the Control Unit is more complex, in

    order to get the best of the pipelining (do the best of instructions and

    their parts reorganization).

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    Pipelining

    The most used pipeline architecture in 90shad 5 stages: fetch (IF),

    decode (ID), operand read (MEM), execution (EX) and operand write

    back (WB).

    Nowadays normal pipelines have a bigger number of stages, for

    example 20 in Pentium IV.

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    Super-scalar processors

    Electronics design methodology to overlap the execution of different

    instructions using repeated functional units in the CPU.

    Processor with scalar level L has L repeated functional units that can

    thus run L instructions at the same time.

    2.8. Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    Super-pipelining

    Pipeline architecture in which slowest stages are divided in sub-stages

    in order to increase their speed.

    Two or more instructions can be execute different parts of the same

    stage at a moment.

    In a super-pipeline architecture the pipelining technology is applied

    twice: in a global context and internally in its functional units.

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

  • 8/13/2019 Tema 1 Introduction

    7/12

    f etc h decode ex ec ute

    time

    1

    f et ch dec ode ex ecute

    f etc h decode ex ec ute

    2

    3

    in struction

    3 stages pipeline: Hazards and risks

    Fetch:The instruction is transferred from program memory and storedin the instructions pipeline

    Decode:The instruction is decoded

    Execute:ALU operations and data transferences

    1 instruction 3 cycles

    1 cycle 1 instruction

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    37

    Multi-cycle instructions hazard

    The instruction needs more cycles than the standard pipelinedinstructions

    fetch ADD decode execute

    time

    1

    fetch STR decode

    fetch ADD decode execute

    2

    3

    data xfer

    fetch SUB decode execute4

    instruction

    calc. add

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    38

    Structural hazard

    At a moment two instructions need the same hardware resources

    fetch ADD decode execute

    time

    1

    fetch STR decode

    fetch ADD decode execute

    2

    3

    data xfer

    fetch ADD decode execute4

    instruction

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    39

    Control risk

    In conditional jumps, the pipeline may need to be emptied

    decode

    ti me

    . .

    f etch ADD decode execute

    1

    2

    3

    4

    instruction

    fetch ADD decode execute1

    fetch BCC decode execute

    fetch SUB

    2

    3

    4

    5

    fetch STR

    Evolution of microprocessors architecture1.5.1. Evolution of microprocessors architecture

    40

    1.6. Instructions. General concepts

    What is a program?

    Its a sequential set of instructions that describe, define or characterize

    the execution of a task in a microprocessor

    What is an instruction?

    Its the CPU elementary command

    Its a set of digital input signals to the decoder

    The instruction decoder (sequential circuit) state evolves and it

    changes its outputs sequentially based on these signals.

    The output signals of the instruction decoder are the microorders.

    41

    Coding Instructions

    The instructions are stored in memory

    Binary format, set '1 'and '0', machine code

    Possible generation of binary codes

    Directly from a conversion table function / code

    Using an assembly starting from an assembly language

    Assembly language: set of mnemonics associated with the instructions

    Using a compiler, starting from a high level language

    Generates machine code from a program in high level language (eg C)

    Instructions. General concepts

  • 8/13/2019 Tema 1 Introduction

    8/12

    Instructions. General concepts

    Example of Instruction

    Add 2 to the contents of register 'A' (Historical solution) Using a conversion table it shows that this operation

    corresponds to the code 0x23, followed by the value 0x02.

    (Tedious solution) Using an assembler program, It would be written to a file: "add2, A", the result would be the same after you run the assembler (0x23, 0x02).

    (Current solution) Using a high-level language: "A + = 2", and after compiling, theresult would be the same again (0x23, 0x02).

    Instructions. General concepts

    Instruction format

    Opcode + [Source operand] + [Destination operand]

    Access to the operands

    Effective address: location of the operand

    Addressing Modes: Different ways to express the effective address

    Provide power to the device

    Simplify programming

    Instructions. General concepts

    Steps in the execution of an instruction

    Instruction fecth

    PC ADDRESS BUS; READING OPCODE

    Calculation of the effective address

    Search operands

    Executing operation

    Store the result

    Increased PC, new cycle

    MEMORY

    OPERATIONCODE

    CPU

    PC ADD.

    OpcodeI.R.

    Instructions. General concepts

    Transfer instructions

    To Copy information from registers, registers and memory, or between

    memory.

    Arithmetic instructions

    They perform simple arithmetic operations: addition, subtraction, etc..

    Logical Instructions

    They perform logic operations on the operands: AND, OR, XOR, etc..

    1.6. Instructions.Type of instructions

    Bit manipulation instructions

    They modify a single bit of the operand

    Shift Instructions

    They shift the contents of a register in both directions

    Program Control Instructions

    They change the flow of program execution

    Types of instructions1.6. Instructions.Type of instructions

  • 8/13/2019 Tema 1 Introduction

    9/12

    Mechanism for specifying the location of an operand.

    A microprocessor has several addressing modes.

    Objectives of addressing modes:

    Facilitate the management of the data structures.

    Allow relocation code.

    Reduce the memory space occupied by the instructions.

    1.6. Instructions. Addressing modes

    Possible addressing modes:

    Implicit Register direct

    Immediate

    Memory direct

    Indirect

    Indirect with offset

    Indirect with Index

    Indirect with pre-indexed

    Indirect with post-indexed

    Addressing modes1.6. Instructions. Addressing modes

    1.7. Inputs / Outputs

    Inputs / Outputs(I/O)

    The reference for the interchange of information is the CPU.

    I/O: the data or information that is passed into or out of a CPU

    CPU takes an external data from the external system Input operation

    CPU gives the data to the external system Output operation

    P external access are carried out through the buses

    I/O devices can be connected to the main system buses

    Or can be a special subsystem depending on the main system.

    51

    1.7. Inputs / Outputs

    Example: domestic heating system

    P external access are carried out through the buses

    I/O classification:

    Directly with the environment under control (analog or digital I/O)

    With the user (analog or digital I/O)

    With other digital systems(this improves the capabilities of the whole system)

    52

    1.7. Inputs / Outputs

    Devices classification

    Output

    Capability of holding data. Example: Latch

    Input

    They need tri-state outputs

    Bidirectional

    Both features in the same device

    53

    1.7. Inputs / Outputs. Interface structure

    Interface circuits

    They make possible transition between two different systems

    Interface structure

    In general, there are two options for the design.

    General purpose circuits (standard circuits such as logic gates, latches, )

    Special circuits designed for a specific function (e.g. USB adapter)

    The CPU sees the interface circuits as a group of registers located

    (mapped) in specific addresses.

    54

  • 8/13/2019 Tema 1 Introduction

    10/12

    1.7. Inputs / Outputs. Interface structure

    Digital Interfaces

    They only manage digital information.

    In general, there are two kinds for transferring information:

    Parallel data transfer:

    A group of n bits are transferredsimultaneously.

    Serial data transfer:

    The bits are transferred one byone. It is needed time orsynchronism information forunderstanding the data withouterrors..

    Advantages and disadvantages?

    55

    1.7. Inputs / Outputs. Interface structure

    Digital interfaces

    Asynchronous serial:

    Synchronous serial:

    8 b its

    R elo j

    In icio Fi n

    T ran sm is o r

    as n cro n o

    B 0 B 1 B 2 B 3 B 4 B 5 B 7B 6

    Asynchronous

    Transmitter

    Clock

    Start End

    8 b i t s

    R el o j maes t r o

    T r ans mi s o r / r ecep t o r

    s ncr ono

    8 b i t s

    D a t o s

    R e l o j

    S en t i do de l a t r ans f er enc i a

    T r ans mi s o r / r ecep t o r

    s ncr ono

    Clock

    Synchronous

    Transmitter/

    Receiver

    Synchronous

    Transmitter/

    ReceiverTransfer direction

    Clock

    Data

    56

    1.7. Inputs / Outputs. Interface structure

    Analog interfaces

    They are circuits that facilitate the conversion between numerical

    codes (related to the digital system) and the multiplicity of instant

    values of the analog signals

    Circuits: Digital/Analog Converter (DAC, D/A)

    and Analog/Digital Converter (ADC, A/D)

    An important parameter related to A/D and D/A is the number of bits ofresolution and the sample frequency

    57

    1.7. Inputs / Outputs. Interface structure

    I/O Interface and peripherals addressing

    For the microprocessor the interface is a group of registers

    For working with the interface, it is needed to read or write the registers

    Depending on the microprocessor, Inputs and Outputs can be:

    mapped in memory (standard accesses to the registers)

    Out of the memory map (special instructions for accessing)

    58

    1.7. Inputs / Outputs. Interface structure

    Buses accessing

    Interconnection electrical problems

    Unidirectional Buses. (fan-out, fan-in)

    Bidirectional Buses. It is needed arbitrations techniques to prevent conflicts (whois using the bus and when).

    Two or more devices connected to the same bus never can transfer simultaneously

    information through the bus. Solutions:

    Integrated circuits with high impedance controlled by the selection of the chip (CS,

    chip select signal) or output enable (OE = Output Enable Signal).

    Devices without high impedance outputs can use additional tri- state buffers with

    enable logic. .

    59

    1.8. Microprocessor Evolution

    Evolution based on ideas, and not only on the technology

    At the beginning the evolution depended only on the technology

    Goal: to increase the clock frequency

    Efficiency is affected for more parameters:

    Memory accesses (bottleneck)

    Input/Output operations

    Compilation

    Operating System Overload

    CPU

    60

  • 8/13/2019 Tema 1 Introduction

    11/12

    Von Neumann's machine had a single functional unit

    CISC processors:

    Complex Instruction Set Computer Short programs with complex instructions (each instruction does many things)

    Very sophisticated operations:

    It reduces the gap between High level and ASM programming

    A few number of instructions, but a lot of machine cycles

    More complex functional units, based on microcode

    Memory Operations (LOAD/STORE): Few internal registers

    Simple compilers

    61

    1.8. Microprocessor Evolution

    Segmentation

    Without finishing one instruction, another starts to be processed

    62

    1.8. Microprocessor Evolution

    New philosophy

    New compilers

    Machine cycles as fast as technology permits

    More operations in one machine cycle

    The simple decoding and the segmented execution are more important than the

    code size (only one instruction format)

    New words appear in the processor design:

    Super-segmentationand superscalararchitectures

    Goal: to increase the nu mber of simultaneous operation (PARALELISM)

    63

    1.8. Microprocessor Evolution

    RISC processors:

    Reduced Instruction Set Computer

    Long programs

    Simple CPU

    Small execution time of the instructions

    Easily Pipelining / Segmenting (PARALELISM)

    64

    1.8. Microprocessor Evolution

    Simulator

    It is a software that permits to simulate the behavior of a program. It imitates thebehavior of a microprocessor or a microcontroller.

    It permits to visualize and modify the registers and the memory content

    Real-time functionalities are not available

    In general, physical and time aspects are no considered

    The running speed is lower than the one with the real device

    1.9. Developing Tools

    65

    On-chip debugging

    It is needed a special software running in the device, and a communication port forconnecting with a computer.

    Specific ports for this task:

    JTAG (Joint Test Action Group) is a method of accessing memory and CPU resources

    without having an application running on the target

    BDM or background debugging mode also achieves this objective

    The debugging application slows down the program

    It is easy to visualize the real content of the memory, registers, etc.

    Other features: step-by-step execution, break points, etc.

    1.9. Developing Tools

    66

  • 8/13/2019 Tema 1 Introduction

    12/12

    This document has been made using material developed by the

    Electronics Department personal.

    1.10. Acknowledgments

    67