Chapter 4
Chapter 4
Models of Computation
Introduction
Describing embedded system’s processing
behavior
− Can be extremely difficult
⚫ Complexity increasing with increasing IC capacity
− Past: washing machines, small games, etc.
⚫ Hundreds of lines of code
!(req<floor)
u,d,o,t = 0,1,0,0
GoingDn
− V is a set of variables {v0, v1, …, vn} req > floor timer < 10
!(timer < 10)
− F is a next-state function (S x I x V → S) u,d,o,t = 0,0,1,0
Idle DoorOpen
− H is an action function (S → O + V) req == floor
req < floor
u,d,o,t = 0,0,1,1
⚫ I,O,V may represent complex data types (i.e., integers, floating point, etc.)
u is up, d is down, o is open
⚫ F,H may include arithmetic operations req < floor t is timer_start
learning
State machine vs. sequential program model
⚫ Different thought process used with each model
⚫ State machine:
− Encourages designer to think of all possible states and transitions
among states based on all possible input conditions
⚫ Sequential program model:
− Designed to transform data through series of instructions that may be
iterated and conditionally executed
⚫ State machine description excels in many cases
− More natural means of computing in those cases
− Not due to graphical representation (state diagram)
⚫ Would still have same benefits if textual language used (i.e., state table)
⚫ Besides, sequential program model could use graphical representation (i.e.,
flowchart)
Capturing state machines in
sequential programming language
⚫ Despite benefits of state machine model, most popular development tools use
sequential programming language
− C, C++, Java, Ada, VHDL, Verilog, etc.
− Development tools are complex and expensive, therefore not easy to adapt or
replace
⚫ Must protect investment
⚫ Two approaches to capturing state machine model with sequential
programming language
− Front-end tool approach
⚫ Additional tool installed to support state machine language
− Graphical and/or textual state machine languages
− May support graphical simulation
− Automatically generate code in sequential programming language that is input to main development
tool
⚫ Drawback: must support additional tool (licensing costs, upgrades, training, etc.)
− Language subset approach
⚫ Most common approach...
Language subset approach
⚫ Follow rules (template) for #define IDLE0
#define GOINGUP1
capturing state machine #define GOINGDN2
#define DOOROPEN3
constructs in equivalent sequential void UnitControl() {
int state = IDLE;
language constructs while (1) {
⚫ Used with software (e.g.,C) and switch (state) {
IDLE: up=0; down=0; open=1; timer_start=0;
hardware languages (e.g.,VHDL) if
if
(req==floor) {state = IDLE;}
(req > floor) {state = GOINGUP;}
⚫ Capturing UnitControl state if (req < floor) {state = GOINGDN;}
break;
machine in C GOINGUP: up=1; down=0; open=0; timer_start=0;
if (req > floor) {state = GOINGUP;}
− Enumerate all states (#define) if (!(req>floor)) {state = DOOROPEN;}
− Declare state variable initialized to break;
GOINGDN: up=1; down=0; open=0; timer_start=0;
initial state (IDLE) if (req < floor) {state = GOINGDN;}
− Single switch statement branches if (!(req<floor)) {state = DOOROPEN;}
break;
to current state’s case DOOROPEN: up=0; down=0; open=1; timer_start=1;
− Each case has actions if (timer < 10) {state = DOOROPEN;}
if (!(timer<10)){state = IDLE;}
⚫ up, down, open, timer_start break;
}
− Each case checks transition }
}
transform
Z
Nodes with more complex
transformations
Synchronous data flow
⚫ With digital signal-processors (DSPs), data flows at fixed
rate
⚫ Multiple tokens consumed and produced per firing
⚫ Synchronous dataflow model takes advantage of this
− Each edge labeled with number of tokens A B C D
consumed/produced each firing
− Can statically schedule nodes, so can easily use sequential mA mB mC mD
program model
⚫ Don’t need real-time operating system and its overhead modulate convolve
⚫
⚫
⚫
If pulse < Lo then
Activate Siren
⚫
⚫
Lo = Lo +/– 1
If B3/B4 pressed then
⚫ Repeat
sharing data
⚫ Difficult to write system
using sequential program
Set-top Box
model
⚫
Task 1: Task 2:
Concurrent process model
⚫ ⚫
Separate sequential
⚫
In Task 2
− ⚫
pu ⚫ Send Video to
⚫
Task 3: Au
programs (processes) for
⚫ ⚫
t Task 3
⚫ Wait on Task 1 dio
Si ⚫ Repeat
Decode/output
each task
⚫
gn Video
al Repeat
Programs communicate
⚫
−
with each other
Implementation
The choice of
⚫ Mapping of system’s functionality ⚫
computational
onto hardware processors: ⚫ State ⚫ Sequ ⚫ Data- ⚫ Concur
rent
model(s) is
based on
mach ent. flow
captured using computational
⚫ ⚫
⚫ ⚫ designer to
− written in some language(s) describe the
system.
⚫ Implementation choice
independent from language(s) ⚫ The choice of
language(s) is
choice ⚫ Pasc ⚫ C/C+ ⚫ Java ⚫ VHD based on
al + L whether it
Implementation choice based on
⚫
⚫ ⚫ ⚫ ⚫
captures the
power, size, performance, timing computational
model(s) used
and cost requirements by the
designer.
⚫ Final implementation tested for
The choice of
feasibility ⚫
implementation
− Also serves as is based on
whether it
blueprint/prototype for mass ⚫ Implementati
on A
⚫ Implementati
on
⚫ Implementati
on
meets power,
size,
manufacturing of final product ⚫ ⚫ B ⚫ C
performance
⚫ ⚫
and cost
requirements.
Concurrent process model:
implementation
⚫ Process
Communication
⚫ Can use single and/or general-purpose ⚫ Proc
or A
Process
processors
⚫
ess1
⚫ Proc or B
ess2
⚫ (a) Multiple processors, each executing one ⚫ ( Proc ⚫ Process
Bus
⚫
a ess3 or C
process ) ⚫ Proc
ess4
⚫ Process
or D
True multitasking (parallel processing)
⚫
−
− General-purpose processors
⚫ Use programming language like C and compile to ⚫ Proc
instructions of processor ⚫
ess1
Proc ⚫
−
⚫
b ess3
Proc
More common
⚫
⚫ ) ess4
⚫ (b) One general-purpose processor running all
processes
− Most processes don’t use 100% of processor ⚫ Process
Communication
or A
time ⚫ Proc
ess1
Can share processor time and still achieve
⚫
− ⚫ Proc ⚫ General
( ess2
necessary execution rates ⚫
Proc Purpose
Bus
⚫
c ess3 Process
⚫ (c) Combination of (a) and (b) ) ⚫ Proc or
ess4
Multiple processes run on one general-purpose
⚫
−
⚫
◼ Real-time constraints
Techniques :
-Testing Concurrent Systems
-Non-intrusive testing
Embedded Software Testing...
⚫ Concurrency increases the difficulty of s/w testing.
⚫ Unmanageably large set of legal execution sequences
that a concurrent program may take.
⚫ Subsequent execution could lead to different-yet correct
results.
⚫ Dealing with abstraction
⚫ Static and Dynamic testing
⚫ Non-intrusive testing
⚫ For host based- intrusion is acceptable.
⚫ Embedded applications have strict timing requirements.
Absolutely imperative that there is no intrusions on a test
execution.