01 Microcontrollers basics.pdf

Full Transcript

MICROCONTROLLERS BASICS DIGITAL SYSTEMS BASICS THE DIGITAL COMPUTER Why “digital” computer?: Most of the things can also be done analog (more on this in future courses) “digital” advantages: o noise robustness o...

MICROCONTROLLERS BASICS DIGITAL SYSTEMS BASICS THE DIGITAL COMPUTER Why “digital” computer?: Most of the things can also be done analog (more on this in future courses) “digital” advantages: o noise robustness o degradation robustness o reconfigurable 01 Microcontrollers basics Microcontrollers and DSP 2023/24 3 THE DIGITAL COMPUTER Memory: stores: o programs: list of commands o inputs and outputs o intermediate values Datapath: arithmetic operations and data processing Control unit: supervises information flow between units Input/Output: digital  analog interface: o input: keyboard, mouse, scanner, touch o output: screen, printer, LED, sound Datapath + control unit: Central Processing Unit o mixed: drives, ETH, WiFi 01 Microcontrollers basics Microcontrollers and DSP 2023/24 4 THE DIGITAL COMPUTER Operation flow Control unit retrieves the next instruction from memory Control unit asks memory and inputs for needed parameters Control unit asks datapath to do stuff Control unit moves results to memory and outputs 01 Microcontrollers basics Microcontrollers and DSP 2023/24 5 COMPUTER ARCHITECTURE Separate control unit and datapath Connections (different speed): Processor: Processor bus central processing unit Input/output bus floating point unit Bus interface: memory management unit communications between internal cache Other parts (keyboard, LCD, Other parts: hard drive, drive controller): external cache input/output random access memory Memory 01 Microcontrollers basics Microcontrollers and DSP 2023/24 6 THE DIGITAL COMPUTER Is the Personal Computer (desktop/notebook/netbook/ultrabook) the only digital computer? (single-chip) Embedded systems! 01 Microcontrollers basics Microcontrollers and DSP 2023/24 7 EMBEDDED SYSTEMS 01 Microcontrollers basics Microcontrollers and DSP 2023/24 8 EMBEDDED SYSTEMS Microcomputer/microcontroller: smaller, less powerful computers DSP: special-purpose computers Not reconfigurable: embedded software 01 Microcontrollers basics Microcontrollers and DSP 2023/24 9 EMBEDDED SYSTEMS Limited or no Human Interface Devices (HID) No mass storage 01 Microcontrollers basics Microcontrollers and DSP 2023/24 10 EMBEDDED SYSTEMS Analog: thermistor, sensors, knob loudspeaker, lighting, motor, dial, WiFi Digital: button, keypad, switch LED, lighting, motor, control, relays Books… Analog! Conditioning: scaling, shifting, … to fall into useful range 01 Microcontrollers basics Microcontrollers and DSP 2023/24 11 ABSTRACTION LAYERS Top-down approach: Subsequent refinements Divide et impera How to do it: o Start from the full, complex system o Decompose in subsystems o Decompose again… o …until it is simple o Connect the simple parts 01 Microcontrollers basics Microcontrollers and DSP 2023/24 12 ABSTRACTION LAYERS Different levels of abstraction / complexity, modular approach Procedures to obtain results from parameters Translates procedure into list of instructions understandable by PC Translates instructions to processor commands Set of instructions and registers available to the processor Implements instructions as data transfers Translates data transfer request into sub-components Translates sub-components to operations on bits Control voltages and flow of electrons Advantages: easy to update, easy to improve upper layers 01 Microcontrollers basics Microcontrollers and DSP 2023/24 13 MICROCONTROLLERS AND DSP WHAT IS A MICROCONTROLLER? A microcontroller is a microprocessor:: o optimized for carrying out control, timing and supervision tasks of equipment or devices (embedded control) o characterized by the “on chip” availability of memory (ROM, EEPROM, Flash,...) and numerous peripherals, which perform various functions (I/O, A/D conversion, timers, counters, PWM,...) o of reduced complexity, with simple configuration and low cost Microcontrollers allow the large-scale and cost-effective implementation of control functions in the most diverse products, both for domestic and industrial use There are units from 4 to 32 bits, available in different packages (with different numbers of pins) and with a flexible set of memories and peripherals designed to manage the most typical applications 01 Microcontrollers basics Microcontrollers and DSP 2023/24 15 MICROCONTROLLERS (µC) Most common hardware in microcontrollers: o Analog/Digital Converters (number of bits, conversion speed, linearity highly variable from model to model) o Timers, counters and PWM modulators o Communication ports (serial, I2C, field bus) o External memories (ROM, EEPROM, FLASH) o Power management unit (PMU) The use of µC is widespread in the creation of: o home appliances o mobile phones, tablet PC o PC peripherals o fax/photocopiers o industrial applications, in particular in the automotive sector (on-board instruments, control units) and electric drives o handheld measurement equipment 01 Microcontrollers basics Microcontrollers and DSP 2023/24 16 WHAT IS A DSP? A DSP is a microprocessor: o optimized for the efficient performance of real-time digital signal processing functions o it has high computing power and relatively low cost (compared to general purpose processors) o particular attention is paid to power consumption, which is reduced to a minimum (e.g. in "embedded" applications, especially if portable) 01 Microcontrollers basics Microcontrollers and DSP 2023/24 17 DIGITAL SIGNAL PROCESSORS (DSP) Most common hardware in DSPs: o availability of a multiplier circuit within the CPU (MAC instruction) o ability to perform multiple memory accesses in a single clock cycle o dedicated addressing modes for circular registers and stacks o presence of a DMA for efficient management of peripherals The use of DSP is very widespread in the creation (of algorithms) for: o encoding/decoding of audio (high fidelity) and video signals o data compression/decompression o data encryption/decryption o mixing of audio and/or video signals o sound synthesis 01 Microcontrollers basics Microcontrollers and DSP 2023/24 18 DSP VS µC The µC were used to carry out control functions: o given the wide availability of on-chip peripherals o with limited computing power (8-bit CPU or less) o without hardware multiplier DSPs were used to carry out signal processing functions, where computing power is the key parameter Currently this diversification in uses appears much more nuanced: o the most recent DSPs often incorporate peripherals traditionally typical of the µC o some µCs have hardware organizations and computing powers very close to those typical of a DSP o costs and performance are, for some applications, very close Designation for real-time control processors: Digital Signal Controller (DSC) 01 Microcontrollers basics Microcontrollers and DSP 2023/24 19 DSP VS µC The fundamental parameters in the comparison are cost and performance Cost: o Not given only by the cost of the devices used, but also by the time needed to complete product development (time to market) o The cost of electronic devices is strongly dependent on the production volume, in which the fixed costs of design and manufacturing (e.g. CPU) are diluted o The costs (time, resources) for developing the application depend on many factors: ✓ the availability of good quality integrated development environments (IDEs). ✓ effective support from the manufacturer of the device used: function libraries, drivers, technical support, support forum 01 Microcontrollers basics Microcontrollers and DSP 2023/24 20 DSP VS µC The fundamental parameters in the comparison are cost and performance Performance: o The application determines the level of performance required from the microprocessor in terms of: ✓ needed peripherals and their specifications (8, 10 or 12 bit A/D converter) ✓ operating conditions (maximum permissible power consumption, temperature) ✓ computing power required (real time control, signal processing, …) o Computer performance: time required to run a given program o µC and DSP: ✓ coincides with the time that the processor dedicates to the program: computation time ✓ there is no operating system that manages multiple concurrent processes 01 Microcontrollers basics Microcontrollers and DSP 2023/24 21 COMPUTATION TIME The computation time required by a program is a key parameter in applications involving signal- processing and/or real-time control activities Its estimate can be obtained on the basis of some fundamental data: o processor clock period o number of cycles required by the most commonly used instructions in the program o number of instructions (for each type) required by the program The clock period and number of cycles required by the instructions of interest can be obtained by reading the processor datasheet The number of instructions required by a program depends on the architecture (ISA) of the processor A given architecture can be implemented in very different ways at the hardware level Organization of the processor: circuit realization of its architecture The architecture has a direct effect on the number of instructions of a given program, the organization instead has an effect on the cycle time and the number of cycles required by the instructions 01 Microcontrollers basics Microcontrollers and DSP 2023/24 22 COMPUTATION TIME ESTIMATE In principle, the computation time can be estimated by the equation   =  ෍   1 o  : processor clock period o  : number of instructions of class  o  : average number of cycles for an instruction of class  o  : number od instruction classes Under the hypothesis: o program is not interrupted by other programs o memory-related delays are not taken into account 01 Microcontrollers basics Microcontrollers and DSP 2023/24 23 INCREASE THE SPEED   =  ෍   1 It is possible to increase the speed by: o reducing the processor clock period    o reducing the total number of instructions σ1  o reducing the number of cycles  needed by the (most commonly used) instructions Reducing the processor clock period  : o causes an increase in power dissipated by the processor (dissipates energy at each transition) o can be limited by reducing the supply voltage ( =  2 ) o demand for processors with low supply voltages (< 1 V) o the limits are technological: better manufacturing processes, better-performing innovative materials 01 Microcontrollers basics Microcontrollers and DSP 2023/24 24 INCREASE THE SPEED   =  ෍   1 Reducing the total number of instructions σ  1  : o the number of available instruction (≈  ) depends on the architecture o the reduction leads towards architectures with complex instructions (CISC), compared to architectures with simpler and fewer instructions (RISC) o the limits are economic: complex and high-cost processors Reducing the instruction number of cycles  : o more complex hardware/circuit organization: ✓ with wired control instead of micro-programmed ✓ reducing the duration of the operation: greater parallelism (obtainable in different ways) use ofi pipelines o the limits are economic: complex and high-cost processors 01 Microcontrollers basics Microcontrollers and DSP 2023/24 25 PERFORMANCE COMPARISON Performance evaluation of general-purpose processors: benchmarking (use of sample programs) It evaluates the performance of a processor globally, including memory management Technique also applied to DSPs: the programs are typical algorithms for signal-processing applications (FFT, FIR filters, IIR,...) Processor Benchmarking: complete applications This approach is inapplicable to DSPs because it tends to evaluate the compiler-processor together, rather than the processor alone It makes it difficult to make comparisons under equal conditions For DSPs we talk about kernel benchmarking 01 Microcontrollers basics Microcontrollers and DSP 2023/24 26 DSP BENCHMARKING Characteristics of a good DSP benchmark program: o relevance: it must be one of the typical applications of a DSP o ease of unambiguous definition: it must be clear which specific algorithm for implementing an operation it uses (FFT) o simplicity o optimization: it must be able to be optimized for each DSP under test There are (expensive) benchmarking catalogs on the market 01 Microcontrollers basics Microcontrollers and DSP 2023/24 27 PERFORMANCE INDICES Common performance indices: o MIPS: millions of instructions per second o DMIPS: millions of instructions per second for a specific benchmark algorithm (Dhrystone) o FLOPS: millions of floating-point operations per second Highly unreliable indicators They do not allow comparisons between devices from different families MIPS: o maximum number of instructions that a CPU is able to perform in a unit of time o the number of instructions required by a certain algorithm depends on the CPU architecture (and the quality of the compiler) o the index allows at most to compare devices with the same architecture 01 Microcontrollers basics Microcontrollers and DSP 2023/24 28 PERFORMANCE INDICES DMIPS: o number of instructions that a processor is able to execute per unit of time during the execution of a specific algorithm, called Dhrystone benchmark o conceived in 1984 to compare the performance of general-purpose processors o sometimes it is normalized to the clock frequency, expressing the speed in DMIPS/MHz o the significance of this index is however very low FLOPS: o maximum number of floating point operations per unit of time o applicable only to processors with floating-point arithmetic None of the indices mentioned considers essential aspects for the performance of a CPU: memory access speed, quality of instructions 01 Microcontrollers basics Microcontrollers and DSP 2023/24 29 EXAMPLE: MIPS VS COMPUTATION TIME We have the following processor:  Instruction class Average number of cycles  =  ෍   1 A 1 ,1 =  ∙ 500 ∙  + 00 ∙  + 00 ∙ 3 = 000 ∙  B 2 C 3 ,2 =  ∙ 000 ∙  + 00 ∙  + 00 ∙ 3 = 500 ∙  A given program will have a certain number Second code: computation time 50% longer of instructions for each class, depending on the compiler/programmer Number of instructions per class 500 + 00 + 00 Compiler / 1 = 0−6 ∙ = 0−6 ∙ 0.7 ∙  000 ∙  programmer A B C 000 + 00 + 00 500 100 100 2 = 0−6 ∙ = 0−6 ∙ 0.8 ∙  500 ∙  1000 100 100 Second code: more MIPS, seems faster! 01 Microcontrollers basics Microcontrollers and DSP 2023/24 30 DISCLAIMER Figures from Logic and Computer Design Figures and text from Introduzione alle Fundamentals applicazioni industriali di microcontrollori e DSP Fifth Edition, GE Mano | Kime | Martin Simone Buso © 2016 Pearson Education, Ltd © 2018 Società Editrice Esculapio s.r.l. … and the World (very) Wide Web and from the corresponding slides by S. Buso

Use Quizgecko on...
Browser
Browser