Top Banner
7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7
21

7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Dec 31, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

7-1Embedded Systems

Algorithms andSoftware Design

Lecture Notes 7                                  

Page 2: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-2

Software Design

How do you think companies create software?

Just dive in and start writing code, or

Plan the architecture and structure of the software?

Software is like any engineering project - you need to identify WHAT you want to do and HOW you want to get there.

WHAT = requirements

HOW = development process

How do you know you developed the software successfully?

Compare the finished product to the requirements (compliance)

Page 3: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-3

Why Bother?

“He who fails to plan, plans to fail”

Most companies have an established process for developing hardware and software.

Software development processes can differ between companies, or even between projects in the same company.

Software development can occur at the same time that hardware is designed (co-development), especially with embedded products. A delay in either affects the timing of the other.

Page 4: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-4

Major Phases of a Software Project

The major phases of a software project are: Requirements gathering (of the entire product) Specification (of the operation) High-level design (architecture of the system) Low-level design (algorithms of the modules) Coding (implementation) Unit test (of the individual software modules) Functional test (pull together the software) Integration test (put the software in the hardware) Verification and Beta test (make sure it is compliant) Ship it! (and make millions of dollars)

Page 5: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-5

What is an Algorithm?

A formula? A solution? A sequence of steps? A recipe?

A former Vice-President? (Al-Gore-ithm?)

An algorithm is created in the design phase

How is an algorithm represented?

Typically represented as pseudo code

Historically represented as flowcharts

Do yourself a favor – write algorithms before code – always!

Page 6: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-6

Pseudo Code

Pseudo code is written in English to describe the functionality of a particular software module (subroutine)

Include name of module/subroutine, author, date, description of functionality of module, and actual steps

Often you can take the pseudo code and use them lines in your program as comments!

Avoid a very fine level of detail (although this may sometimes be difficult to do)

Avoid writing code – use English, not assembly language (or higher-level language) instructions

Page 7: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-7

An example

The problem: On the LC-2 processor, perform R1 = R1-R2

Algorithm:

; Subtract: Jim Conrad, 2000-10-15

; Purpose: Perform R1=R1-R2

;make R2 negative

Not R2

Add 1 to R2

;subtract

R1=R1 + (-R2)

Return

Page 8: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-8

Flowchart Symbols

Decision? Do a Task

Input/ Output

START

END

Yes

No

Page 9: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-9

Flowchart the Subtraction Problem

START

END

Not R2

Add 1 to result

Add result to R1

Page 10: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-10

Another Example

Problem: Compare two numbers in R2 and R3, put the larger number in R1. If Equal, put 0 in R1.

Sample input/output:

R2 R3 R1=R2-R3

5 4

5 -4

-5 4

-5 -4

5 5

Page 11: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-11

Algorithm - Larger

Algorithm:; Larger: Jim Conrad, 2000-10-15; Purpose: Compare two numbers in R2 and; R3, put the larger number in R1. If; equal, put 0 in R1.Perform R2-R3If result is positive ; R2 is bigger Put R2 in R1, exitIf result is negative ; R3 is bigger Put R3 in R1, exitIf zero, Put 0 in R1, exit

Page 12: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-12

Flowchart - Larger

START

END

Compare R2 and R3 – Perform R2-R3

to set bits

Z=1?Yes

No

N=1?Yes

No

R1=R3

R1=R2

R1=0

Page 13: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-13

Example Code for Larger; Larger: Jim Conrad, 2000-10-15; Purpose: Compare two numbers in R2 and; R3, put the larger number in R1. If; equal, put 0 in R1.MAIN NOT R1, R3 ;Subtract R2-R3

ADD R1,R1,#1ADD R1,R2,R1BRz DONE ;Make

comparisonsBRn R3BIGGER ;based on flagsADD R1,R2,#0BRnzp DONE

R3BIGGER ADD R1,R3,#0DONE TRAP x25 ;HALT

Page 14: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-14

Coding Guidelines

Every main program and subroutine must have a header which includes:

• Code file/subroutine name -- Inputs/Outputs• Your name -- Interfaces (i,.e.

registers)• Date -- Assumption• Description of problem/solution

The code should have WORTHWHILE comments.

The code for each main/subroutine shall be less than 60 lines, including comments.

Use indentation and spaces liberally.

Page 15: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-15

Summary - Programming

Study the problem FIRST (THINK!!).

Write the important parts of your problem down.

Break the problem into manageable pieces. Solve each of the pieces individually.

Write an algorithm of the solution of your problem, or for each piece you identified.

Create test cases for yourprogram.

Write the code. Include comments as you code.

Test your program

Page 16: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

7-16

Statistics on Software Projects

Standish Group International, reported in 1995:

Only 16% of software projects were expected to finish on time and within budget

Projects completed by the largest American Organizations had only 42% of their originally proposed functions

31% of software projects were cancelled before completion costing the US economy $81 billion

NASA software research data indicates that 40% of the cost on large projects is spent on rework

Page 17: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

7-17

Advantages of SPI Efforts

Organizations that have invested in software process improvement for 3+ years report average yearly gains of:– 37% productivity– 18% more defects found in pretest– 19% reduction in time to market– 45% reduction in field error reports– The average return on investment is 4:1

Page 18: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

7-18

So what is the CMM??

CMM, the Capability Maturity Model, is an engineering practice model for an evolutionary process improvement cycle. There are five levels:

Initial – unpredictable and poorly controlled (chaos)

Repeatable – can repeat previously mastered tasks

Defined – Process characterized and fairly well understood

Managed – process measured and controlled

Optimizing – focus on process improvement (Space Shuttle!)

Page 19: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

7-19

Boeing’s Success

Late Deliverable

Dates

Goal: Goal: Low VarianceLow VarianceCMM

Level 3

CMM

Levels

1 & 2

Target Date

Page 20: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-20

How do we mature through CMM?

We initiate the need for improvement

We diagnose our current environment

We establish our plans and action teams

We develop the solutions using our teams in concert with our plans

We leverage what we have created in the next improvement initiation

Each stage has additional tasks that need to be done, i.e. peer review, software configuration management.

Page 21: 7-1 Embedded Systems Algorithms and Software Design Lecture Notes 7.

Embedded Systems 7-21

Software Development Environment

Companies that develop code need to ensure they employ “Software Configuration Management” (SCM).

Basically all work products that will be delivered as part of a project are controlled by SCM through baselines that are established at the beginning of the project.

A company has a “library system” (repository) where developers check out code they will change. They check it back in when done.

Everyone has a copy of the entire code base so they can locally compile the code, adding the few changes of the code they have checked out.