Sei sulla pagina 1di 50

Maths is not everything

Embedded Systems
5 - Development of microprocessor-based systems

Architectures and components Debugging Manufacturing Testing


RMR2012

Example

Maths is not everything

Development of Microprocessor-based Systems Architectures and Components

RMR2012

Software architecture

Functional description must be broken into pieces: division among people; conceptual organization; performance;
2008 Wayne Wolf

testability; maintenance.

Maths is not everything

RMR2012

Hardware and software architectures

Hardware and software are intimately related: software doesnt run without hardware; how much hardware you need is determined by the software requirements:
Maths is not everything

2008 Wayne Wolf

speed; memory.

RMR2012

Software components

Need to break the design up into pieces to be able to write the code. Some component designs come up often. A design pattern is a generic description of a component that can be customized and used in different circumstances.

Maths is not everything

RMR2012

2008 Wayne Wolf

Software state machine

State machine keeps internal state as a variable, changes state based on inputs. Uses:
control-dominated code; reactive systems.
Maths is not everything

RMR2012

2008 Wayne Wolf

State machine specication

in1=1/x=a

B
r=1/out1=0

r=0/out2=1

in1=0/x=b

s=0/out1=0
2008 Wayne Wolf
Maths is not everything

C
s=1/out1=1

RMR2012

C code structure

Current state is kept in a variable. State table is implemented as a switch.


Cases define states. States can test inputs.
2008 Wayne Wolf

Maths is not everything

Switch is repeatedly evaluated in a while loop.

RMR2012

Software design techniques

Want to develop as much code as possible on a standard platform:


friendlier programming environment; easier debugging.

Maths is not everything

RMR2012

2008 Wayne Wolf

May need to devise software stubs to allow testing of software elements without the full hardware/software platform.

Host/target design

Use a host system to prepare software for target system:

target system
serial line

Maths is not everything

RMR2012

2008 Wayne Wolf

host system

Host-based tools

Cross compiler:
compiles code on host for target system.

Cross debugger:
displays target state, allows target system to be controlled.
Maths is not everything

RMR2012

2008 Wayne Wolf

Evaluation boards

Designed by CPU manufacturer or others. Includes CPU, memory, some I/O devices. May include prototyping section. CPU manufacturer often gives out evaluation board netlist---can be used as starting point for your custom board design.

Maths is not everything

RMR2012

2008 Wayne Wolf

Adding logic to a board

Programmable logic devices (PLDs) provide low/medium density logic. Field-programmable gate arrays (FPGAs) provide more logic and multi-level logic.
2008 Wayne Wolf

Maths is not everything

Application-specific integrated circuits (ASICs) are manufactured for a single purpose.

RMR2012

The PC as a platform

Advantages:
cheap and easy to get; rich and familiar software environment.

Disadvantages:
requires a lot of hardware resources;
Maths is not everything

RMR2012

2008 Wayne Wolf

not well-adapted to real-time.

Maths is not everything

Development of Microprocessor-based Systems Debugging Embedded Systems

RMR2012

Debugging embedded systems

Challenges:
target system may be hard to observe; target may be hard to control; may be hard to generate realistic inputs; setup sequence may be complex.
Maths is not everything

RMR2012

2008 Wayne Wolf

Software debuggers

A monitor program residing on the target provides basic debugger functions. Debugger should have a minimal footprint in memory. User program must be careful not to destroy debugger program, but , should be able to recover from some damage caused by user code.

Maths is not everything

RMR2012

2008 Wayne Wolf

Breakpoints

A breakpoint allows the user to stop execution, examine system state, and change state. Replace the breakpointed instruction with a subroutine call to the monitor program.
Maths is not everything

RMR2012

2008 Wayne Wolf

ARM breakpoints

0x400 MUL r4,r6,r6

0x400 0x404 ADD r2,r2,r4 0x404 0x408 ADD r0,r0,#1 0x408 0x40c 0x40c B loop uninstrumented code
Maths is not everything

MUL r4,r6,r6 ADD r2,r2,r4 ADD r0,r0,#1 BL bkpoint

code with breakpoint

RMR2012

2008 Wayne Wolf

Breakpoint handler actions

Save registers. Allow user to examine machine. Before returning, restore system state.
Safest way to execute the instruction is to replace it and execute in place. Put another breakpoint after the replaced breakpoint to allow restoring the original breakpoint.

Maths is not everything

RMR2012

2008 Wayne Wolf

In-circuit emulators

A microprocessor in-circuit emulator is a specially-instrumented microprocessor. Allows you to stop execution, examine CPU state, modify registers.
2008 Wayne Wolf

Maths is not everything

RMR2012

Logic analyzers

A logic analyzer is an array of low-grade oscilloscopes:

Maths is not everything

RMR2012

2008 Wayne Wolf

Logic analyzer architecture

UUT
system clock

sample memory vector address controller

microprocessor

clock gen
Maths is not everything

state or timing mode keypad display

2008 Wayne Wolf

RMR2012

- Checking memory (e.g. cache misses) or I/O access - Checking execution time (marks needed)

How to exercise code

Run on host system. Run on target system. Hardware/Software verification


Run in instruction-level simulator. Run on cycle-accurate simulator (e.g. SoC).
2008 Wayne Wolf
Maths is not everything

Run in hardware/software co-simulation environment.

RMR2012

Maths is not everything

Development of Microprocessor-based Systems Manufacturing

RMR2012

Manufacturing testing

Goal: ensure that manufacturing produces defect-free copies of the design. Can test by comparing unit being tested to the expected behavior.
But running tests is expensive.

Maximize confidence while minimizing testing cost.


Maths is not everything

2008 Wayne Wolf

Design for testability


take manufacturing test into account during design

RMR2012

Testing concepts

Yield: proportion of manufactured systems that work.


Proper manufacturing maximizes yield. Proper testing accurately estimates yield.

Maths is not everything

RMR2012

2008 Wayne Wolf

Field return: defective unit that leaves the factory.

Faults

Manufacturing problems can be caused by many things. Fault model: model that predicts effects of a particular type of fault. Fault coverage: proportion of possible faults found by a set of test.
Maths is not everything

RMR2012

2008 Wayne Wolf

Having a fault model allows us to determine fault coverage.

Software vs. hardware testing

When testing code, we have no fault model.


We verify the implementation, not the manufacturing. Simple tests (e.g., Error Correcting Codes) work well to verify software manufacturing.

Maths is not everything

RMR2012

2008 Wayne Wolf

Hardware requires manufacturing tests in addition to implementation verification.

Hardware fault models

Stuck-at 0/1 fault model:


output of gate is always 0/1.

01
2008 Wayne Wolf

Maths is not everything

RMR2012

Combinational testing

Every gate can be stuck-at-0, stuck-at-1. Usually test for single stuck-at-x faults
One fault at a time. Multiple faults can mask each other.

We can generate a test for a gate by:


controlling the gates input; observing the gates output through other gates.
Maths is not everything

RMR2012

2008 Wayne Wolf

Sequential testing

A state machine is combinational logic + registers. Sequential testing is considerably harder.


A single stuck-at fault affects the machine on every cycle.
Maths is not everything

RMR2012

2008 Wayne Wolf

Fault behavior on one cycle can be masked by same fault on other cycles.

Scan chains

A scannable register operates in two modes:


normal; scan---forms an element in a shift register.

Using scan chains reduces sequential testing to combinational testing.


Maths is not everything

2008 Wayne Wolf

Unloading/unloading scan chain is slow. May use partial scan.

RMR2012

Test generation

Automatic test pattern generation (ATPG) programs: produce a set of tests given the logic structure. Some faults may not be testable--redundant.
Maths is not everything

2008 Wayne Wolf

redundancy may have been added for avoiding glitches Timeout on a fault may mean hard-to-test or untestable.

RMR2012

Boundary scan

Simplifies testing of multiple chips on a board.


Registers on pins can be configured as a scan chain (JTAG standard interface)
Test Access Port

Maths is not everything

RMR2012

2008 Wayne Wolf

JTAG

Also used as an OCDM interface


e.g. MSP430 responds to various commands sent over JTAG:
Set watchpoint and breakpoint triggers Poll CPU status (e.g., if halted at a breakpoint)
Maths is not everything

Poll the state-storage buffer (for information stored at watchpoint trigger) Poll the program counter (PC)

RMR2012

Maths is not everything

Development of Microprocessor-based Systems Example


Designing an Alarm Clock

RMR2012

Alarm clock interface

Alarm on PM

Alarm off buzzer

light
set time
Maths is not everything

Alarm ready
set alarm hour minute

RMR2012

2008 Wayne Wolf

button

Operations

Set time: hold set time, depress hour, minute. Set alarm time: hold set alarm, depress hour, minute. Turn alarm on/off: depress alarm on/off.
Maths is not everything

RMR2012

2008 Wayne Wolf

Alarm clock requirements

Maths is not everything

RMR2012

2008 Wayne Wolf

Alarm clock class diagram

Lights*

Display

1 1

Mechanism
1

Buttons*

Maths is not everything

RMR2012

2008 Wayne Wolf

Speaker*

Alarm clock physical classes

Lights*

Buttons*

Speaker*

digit-val() digit-scan() alarm-on-light() PM-light()


2008 Wayne Wolf

set-time(): boolean set-alarm(): boolean alarm-on(): boolean alarm-off(): boolean minute(): boolean hour(): boolean

buzz()

Maths is not everything

RMR2012

Display class

Display time[4]: integer alarm-indicator: boolean PM-indicator: boolean set-time() alarm-light-on() alarm-light-off() PM-light-on() PM-light-off()

Maths is not everything

RMR2012

2008 Wayne Wolf

Mechanism class

Mechanism Seconds: integer PM: boolean tens-hours, ones-hours: integer tens-minutes, ones-minutes: integer alarm-ready: boolean alarm-tens-hours, alarm-ones-hours: integer alarm-tens-minutes, alarm-ones-minutes: integer
2008 Wayne Wolf
Maths is not everything

scan-keyboard() update-time()

RMR2012

Update-time behavior

update seconds with rollover Rollover? T update hh:mm with rollover F

display.set-time(current time)

Time >= alarm and alarm-on? T alarm.buzzer(true)

2008 Wayne Wolf

AM->PM PM=true

Maths is not everything

PM->AM PM=false

RMR2012

Scan-keyboard behavior

compute button activations


alarm-ready= true
Alarm-on Set-time and not set-alarm and hours Set-time and not setalarm and minutes

only one activation

Alarm-off

Increment time tens w. rollover and AM/PM

Maths is not everything

RMR2012

2008 Wayne Wolf

alarm-ready= false alarm.buzzer(false)

save button states

Increment time ones w. rollover and AM/PM

System architecture

Includes:
periodic behavior (clock); aperiodic behavior (buttons, buzzer activation).

Two major software components:


interrupt-driven routine updates time;
Maths is not everything

RMR2012

2008 Wayne Wolf

foreground program deals with buttons, commands.

Interrupt-driven routine

Timer probably cant handle one-minute interrupt interval. Use software variable to convert interrupt frequency to seconds.
2008 Wayne Wolf

Maths is not everything

RMR2012

Foreground program

Operates as while loop: while (TRUE) { read_buttons(button_values); process_command(button_values);


2008 Wayne Wolf

check_alarm(); }

Maths is not everything

RMR2012

Testing

Component testing:
test interrupt code on the platform; can test foreground program using a mock-up.

System testing:
relatively few components to integrate;
2008 Wayne Wolf

check clock accuracy; check recognition of buttons, buzzer, etc.

Maths is not everything

RMR2012