Hardware Software Co-Design
Hardware Software Co-Design
system design.
Data Flow Graph/Diagram (DFG) Model
• The Data Flow Graph ( DFG) model translates the data
processing requirements into a data flow graph.
• The Data Flow Graph (DFG) model is a data driven model in
which the program execution is determined by data.
• This model emphasizes on the data and operations on the
data which transforms the input data to output data.
• If flag = 1, x = a + b; else y = a – b;
Control Data Flow Graph/Diagram (CDFG)
If flag = 1, x = a + b; else y = a – b;
State Machine Model
• The State Machine model is used for modeling reactive or
event-driven embedded systems whose processing behavior
are dependent on state transitions.
• The State Machine model describes the system behavior with
‘States’, ‘Events’, ‘Actions’ and ‘Transitions’.
• State is a representation of a current situation.
• An event is an input to the state. The event acts as stimuli for
state transition.
• Transition is the movement from one state to another.
• Action is an activity to be performed by the state machine.
Finite State Machine ( FSM) model
• A Finite State Machine ( FSM) model is one in which the
number of states are finite.
• In other words the system is described using a finite number
of possible states.
• As an example let us consider the design of an embedded
system for driver/passenger ‘Seat Belt Warning’ in an
automotive using the FSM model.
• The system requirements are captured as.
1. When the vehicle ignition is turned on and the seat
belt is not fastened within 10 seconds of ignition ON,
the system generates an alarm signal for 5 seconds.
2. The Alarm is turned off when the alarm time (5
seconds) expires or if the driver/passenger fastens the
belt or if the ignition switch is turned off, whichever
happens first.
• Here the states are ‘Alarm Off’, ‘Waiting’ and ‘Alarm On’
and the events are ‘Ignition Key ON’, ‘Ignition Key OFF’,
‘Timer Expire’, ‘Alarm Time Expire’ and ‘Seat Belt ON’.
• Using the FSM, the system requirements can be
modeled as given in Fig.
• When the wait timer expires in the waiting
state, the event ‘Timer Expire’ is generated
and it transitions the state to ‘Alarm On’ from
the ‘Waiting’ state.
• The ‘Alarm On’ state continues until a ‘Seat
Belt ON’ or ‘Ignition Key OFF’ event or ‘Alarm
Time Expire’ event, whichever occurs first.
• The occurrence of any of these events
transitions the state to ‘Alarm Off’.
• The wait state is implemented using a timer.
• The timer also has certain set of states and
events for state transitions.
EMBEDDED FIRMWARE DESIGN APPROACHES
• The task listed at the top of the program code is executed first
and the tasks just below the top are executed after completing
the first task.
•From the above ‘C’ code you can see that the tasks 1 to n are performed
one after another and when the last task (nth task) is executed, the
firmware execution is again re-directed to Task 1 and it is repeated forever
in the loop.
•This repetition is achieved by using an infinite loop. Here the while (1) { }
loop. This approach is also referred as ‘Super loop based Approach’.
• Since the tasks are running inside an infinite loop, the only way to come
out of the loop is either a hardware reset or an interrupt assertion.
• A hardware reset brings the program execution back to the main loop.
• Whereas an interrupt request suspends the task execution temporarily
and performs the corresponding interrupt routine and on completion of
the interrupt routine it restarts the task execution from the point where it
got interrupted.
• The ‘Super loop based design’ doesn’t require an operating system, since
there is no need for scheduling which task is to be executed and assigning
priority to each task.
• In a super loop based design, the priorities are fixed and the order in
which the tasks to be executed are also fixed. Hence the code for
performing these tasks will be residing in the code memory without an
operating system image.
• This type of design is deployed in low-cost embedded products and
products where response time is not time critical.
• A typical example of a ‘Super loop based’ product is an electronic
video game toy containing keypad and display unit.
• The program running inside the product may be designed in such a
way that it reads the keys to detect whether the user has given any
input and if any key press is detected the graphic display is updated.
• The keyboard scanning and display updating happens at a reasonably
high rate.
• The ‘Super loop based design’ is simple and straight forward without
any OS related overheads. The major drawback of this approach is
that any failure in any part of a single task may affect the total system.
• If the program hangs up at some point while executing a task, it may
remain there forever and ultimately the product stops functioning.
• There are remedial measures for overcoming this. Use of Hardware
and software
• Watch Dog Timers (WDTs) helps in coming out from the loop when an
unexpected failure occurs or when the processor hangs up. This, in
turn, may cause additional hardware cost and firmware overheads.
• Another major drawback of the ‘Super loop’ design
approach is the lack of real timeliness. If the number of
tasks to be executed within an application increases, the
time at which each task is repeated also increases.
• This brings the probability of missing out some events.
For example in a system with Keypads, according to the
‘Super loop design’, there will be a task for monitoring
the keypad connected I/O lines and this need not be the
task running while you press the keys (That is key
pressing event may not be in sync with the keypad press
monitoring task within the firmware).
• In order to identify the key press, you may have to press
the keys for a sufficiently long time till the keypad status
monitoring task is executed internally by the firmware.
This will really lead to the lack of real timeliness.
The Embedded Operating System (OS) Based
Approach
• The Operating System (OS) based approach contains operating
systems, which can be either a General Purpose Operating System
(GPOS) or a Real Time Operating System (RTOS) to host the user
written application firmware.
• The General Purpose OS (GPOS) based design is very similar to a
conventional PC based application development where the device
contains an operating system (Windows/Unix/ Linux, etc. for Desktop
PCs) and you will be creating and running user applications on top of it.
• Real Time Operating System (RTOS) based design approach is
employed in embedded products demanding Real-time response.
• RTOS respond in a timely and predictable manner to events. Real Time
operating system contains a Real Time kernel responsible for
performing pre-emptive multitasking, scheduler for scheduling tasks,
multiple threads, etc.
• A Real Time Operating System (RTOS) allows flexible scheduling of
system resources like the CPU and memory and offers some way to
communicate between tasks.
EMBEDDED FIRMWARE DEVELOPMENT LANGUAGES
• We can use either a target processor/controller specific
language (Generally known as Assembly language or low level
language) or
• a target processor/controller independent language (Like C,
C++, JAVA, etc. commonly known as High Level Language) or
• a combination of Assembly and High level Language.