eda software engineering

32
EDA Software Engineering Outline SE Methods Software Reuse Software Libraries Rapid Prototyping Tools Computer-Aided Programming Goal Understand SE ideas relevant to CAD Learn pointers to specific SE tools

Upload: eytan

Post on 17-Jan-2016

48 views

Category:

Documents


3 download

DESCRIPTION

Outline SE Methods Software Reuse Software Libraries Rapid Prototyping Tools Computer-Aided Programming Goal Understand SE ideas relevant to CAD Learn pointers to specific SE tools. EDA Software Engineering. Software Reuse Software Libraries Rapid Prototyping Tools - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EDA Software Engineering

EDA Software Engineering

Outline– SE Methods

– Software Reuse

– Software Libraries

– Rapid Prototyping Tools

– Computer-Aided Programming

Goal– Understand SE ideas relevant to CAD

– Learn pointers to specific SE tools

Page 2: EDA Software Engineering

Software Engineering Methods

• Software Reuse

• Software Libraries

• Rapid Prototyping Tools

• Computer-Aided Programming

Page 3: EDA Software Engineering

Software Reuse

The fastest way to code is don't• use existing software

- programs, modules, classes, functions, data structures- "previous work" analogy

• sources- friends, project, group, system, bboards, servers, vendors- pieces of source code, packages, libraries

Bigger != better• software value is in functionality and performance• no one cares how many lines of code are in your software• 20,000 lines of code != PhD• software size is only useful as a complexity metric for planning

Page 4: EDA Software Engineering

Benefits of Software Reuse

Reduced implementation time• Hitachi "software factory" produces 1500 lines/person/month of

debugged code• Only 500 lines/person/month are new. Rest is reused.• 20,000/1500 = 13 months to implement thesis software!

- debugged too!

Higher quality• can put more effort into a module that is reused many times• do it right once and it is right everywhere

Easier maintenance• less to maintain• easier to understand

Page 5: EDA Software Engineering

Barriers to Software Reuse

Difficult to Understand• no comments, documentation, explanatory variable/function names• example: variables foo, bar, baz, count1, count2,...

Specialized• customized to platform, data structures, application• example: sort routine only for positive integers

Not Modular• spread across many locations in existing application• example: structure initialized in file1, modified in file2,...

Result: often less time and error to start from scratch

Page 6: EDA Software Engineering

Writing Reusable Software

Understandable• useful comments - not "cnt++; /* increment counter */"• complete man page - painful, but necessary• meaningful names - "rectangle", "IncCounter",...

General• clean interface - streams, sequences, etc.• specialization via procedure argument, derived type, etc.• example: qsort uses procedure arg to compare two array elements

Modular• use good practices - structured programming, information hiding,

abstract types, object-oriented programming• everything in one bundle• example: include MakeRectangle, DeleteRectangle in module

Page 7: EDA Software Engineering

Cleanliness is Next to Godliness

Good fundamentals• algorithms

• data structures

• modularity

Simple interface• character stream, list, array

- example: stream interface of UNIX filters

• functions with few arguments

- example: functions to build up argument structure for operation

Avoid premature efficiency• do not sacrifice generality for efficiency

• identify and eliminate program bottlenecks later

Page 8: EDA Software Engineering

Cleanliness

ExampleBeginPolygon();MoveTo(0, 0);LineTo(1, 0);LineTo(1, 1);LineTo(0, 1);RectPoly = EndPolygon();...UnionPoly = Union(RectPoly, DiamondPoly);

Books• Software Tools, Kernighan, Plauger• Writing Efficient Programs, Bentley

Page 9: EDA Software Engineering

Software Libraries

Library == bundled abstract/abstract-like data types• implementation often unknown

General• C library - system interface, misc.

• C Programmer's Toolbox - allocation, lists, trees, hash tables in C

• Code Farms, Inc. - collections, trees, lists, database,... in C, C++

• NIH - collections, numbers, dictionary, geometry, vectors,... in C++

• GNU - I/O, strings, numbers, RNG, collections, vectors,... in C++

Graphics• Motif

• X library (Xlib)

• X toolkit (Xt)

• InterViews

• Tk

Page 10: EDA Software Engineering

Software Libraries

Math• Numerical Recipes in C

• matrix packages - LINPACK, LAPACK, EISPACK,...

Geometry• 2-D polygon package - C

• Spatial Technologies ACIS solid modeler - C++ classes

Specialized• XF interface builder for Tk/Tcl

• BOS object set for Tcl

Somewhere out there is a library for almost everything

Page 11: EDA Software Engineering

What is Rapid Prototyping?

1: Quick assembly of a partial or complete system for experimentation prior to full requirements, specification, and implementation.

2: Quick assembly of a tool or system for temporary or permanent use, using special-purpose languages and existing tools.

Goals• rapid! - <10% of time to do traditional C/C++ implementation

• functionality - implement functions to permit experimentation or use

• okay performance - system only needs to be fast enough to try it out or be acceptable

• easily modified - for iteration during experimentation, or for maintainability

Page 12: EDA Software Engineering

Rapid Prototyping Tools

General-Purpose Languages• Bourne shell (sh), C shell (csh), Korn shell (ksh),

born-again shell (bash), tcsh• LISP?

Pattern Languages• awk, gawk• sed, grep• perl

Extension Languages• Tk/Tcl• Emacs LISP

Parser Generators• lex, yacc

UNIX utilities• comm, diff, ed, find, sort, uniq,...

Existing Tools

Page 13: EDA Software Engineering

Prototyping Tool Characteristics

They exist!• lot of needed functionality already built in

Quick edit-compile-debug loop• interpreted, compile-on-fly, pre-compiled

Simple I/O• mostly just ASCII text, not binary• frequently stream I/O - easier interfacing

Easily controlled from other programs• command line interface, extension language, streams, files,...

Often used in combination• e.g. awk scripts in a shell script

Page 14: EDA Software Engineering

Shell Languages

Command Interpreters• programming language access to UNIX commands• sh, csh are "standard" and portable• shell to use matter of personal taste

Applications• need general control constructs• file testing, directory access• need functionality of many UNIX tools• "central control" of application

Performance• UNIX commands normally dominates runtime

Page 15: EDA Software Engineering

Pattern Languages

Domain• scan text input, do computation, pass result to the output

Key Ideas• regular expression matching• state machine transformations

Performance• Stream/file I/O dominates application• CPU efficiency is less important

Page 16: EDA Software Engineering

Awk

Language• set of <pattern, action> pairs• for each input line, execute actions of matching patterns• patterns are regular expressions, conditionals, etc.• actions are expressions, statements• gawk is extended version of awk

Examples• {print $2} - print the second field of every line• length > 72 {i++} - count # lines >72 characters long END {print i}

Applications• good for simple computations on input stream• e.g. take average of a column of numbers

Page 17: EDA Software Engineering

Sed

Language• stream editor• commands are [address [,address]] function [args]• apply commands with matching addresses to each input line• can read and write files, test, branch, use buffer space, etc.

Examples• sed -e 's/^ //' file - delete first three spaces of each line• sed -e 'r foo' file - place contents of foo between each line

Applications• good for local transformations on text streams• e.g. capitalize the first word at the beginning of each sentence• most common use is regular expression query-replace

Page 18: EDA Software Engineering

Grep

Language• regular expression pattern search• print all lines that do/do not match pattern• grep - limited RE, egrep - full RE, fgrep - fixed strings

Example• grep '^[abc]h' file - print all lines beginning with "ah", "bh", or "ch"• grep -v 'Defect' file - print all lines except those with "Defect"• grep -n foo * - print all lines (w/filename and line number) of all

files with "foo"

Applications• general tool for simple text file searches• egrep usually fastest and most general

Page 19: EDA Software Engineering

Perl

Language• practical extraction and report language• combination of awk, sed, sh, csh, etc., functionality• C-like syntax, operators, and semantics• faster, more powerful

Features• fast text, binary scan• command line switch parsing• math, system, file testing, I/O control, IPC functions• subroutines• awk (a2p), sed (s2p), find (find2perl) to perl translators

Applications• facilities management - more secure than C programs• networking applications• general-purpose• for simple things, use sed, awk,...

Page 20: EDA Software Engineering

Perl Example

Archie• program to access databases of useful stuff available on Internet

C version• 7889 lines of C code and scripts

• 1822 lines for VMS support

• 230 lines for MS DOS support

Perl version• 1146 lines of Perl code and scripts

• runs on any platform supporting Perl

The Perl version is more reliable and about as fast

Page 21: EDA Software Engineering

Extension Languages

Tcl• general-purpose

• small and efficient

• easily linked into applications

Emacs LISP• write programs to process text

• programs to interact with other processes - shell windows

• "live inside Emacs" - mail, bboards, compiling

• advantages: can watch things happen, record keystrokes, can run in batch, familiar

• disadvantages: startup time (0.2s on DS5000/25), size (912K)

Page 22: EDA Software Engineering

Parser Generators

Lex, Yacc (Flex, Bison)• generate lexical analyzer and parser with C callbacks

Applications• parse interchange language of some complexity• e.g. CIF, Stream, MIF• very simple format, easier to use pattern or programming language• if speed not critical, use for final application

Books• Principles of Compiler Design, Aho, Ullman, Seth (the "Dragon"

book)• even though parsing concepts are complicated, learning and using

is still faster than using C

Page 23: EDA Software Engineering

UNIX Utilities

Think of them as special-purpose tools for program construction• use combination of not-quite-ideal tools rather than write new one

Examples• How many unique words are in a word list?

#!/bin/csh -fsort $1 | uniq | wc | awk '{print $1}'

• Change files 'foo.dat' to 'foo.d'#!/bin/csh -fforeach i (`ls *.dat`) mv $i {$i:r}.dend

Page 24: EDA Software Engineering

Existing Tools

Use your suite of programs as a toolbox• follow "tool building" and software reuse practices• see Software Tools book for examples

Identify common needs in a multi-person project• parser for common language• display routines• special-purpose Tk widgets

Build on your past, recycle, don't dispose

Page 25: EDA Software Engineering

Computer-Aided Programming

When all else fails, you are forced to do some coding

Computer aids for coding• improved blocking and tackling, i.e. basics• speed up edit-compile-debug loop• code management• code analysis

Note: coding != programming• you already have algorithms, program structure

Page 26: EDA Software Engineering

Edit-Compile-Debug Loop

Edit• make source code know to system• write with editor, copy, etc.

Compile• transform source to runnable form• incorporate debugging instrumentation• not necessarily with compiler

Debug• run code on test inputs• use instruments to isolate and identify errors in source

Good programmers loop several times developing code by iterative refinement

Page 27: EDA Software Engineering

Code Management

Program Build• keep track of what is necessary to build program• source modules• libraries• module dependencies• e.g. make

Version Control• maintain multiple versions of code• diffs, patches to code• current and old versions• log files of changes• access control for multiple users• e.g. rcs, sccs

Page 28: EDA Software Engineering

Code Analysis

Navigation• cross-reference - who calls who• class hierarchy

Static Checking• portability rules

- e.g. architecture/OS dependencies• code checking

- syntax, semantics, style- e.g. lint

Performance Analysis• post-processing of profiling information

Page 29: EDA Software Engineering

CA Programming Environments

UNIX Tools• cc, make, dbx,...

Emacs• LISP commands

• interface to UNIX tools

Commercial Products• Centerline ViewCenter

• HP Softbench

• Parc Place Systems ObjectWorks/C++

• Centerline CodeCenter and ObjectCenter

• etc., etc.

Page 30: EDA Software Engineering

UNIX Tools

Compilers• cc, gcc - C compilers• CC, g++ - C++ compiler (currently a C translator)

Source Debuggers• dbx, gdb - language independent

Code Management• make - compilation control• ar, ranlib - archive and library generation• rcs, sccs - source code control• makedepend - X11 dependencies

Code Analysis• lint - C source checker• cxref - C cross-reference• prof, gprof - run-time profiling

Page 31: EDA Software Engineering

Emacs

Link to UNIX tools• fork make

• step through compile errors in source code

• e.g. GNU Emacs Compile package

Language Sensitive Editor• formatting

- indentation, pretty-printing,...

• syntax-directed editing

- paren balancing, delete expression,...

• e.g. C Mode in GNU Emacs

Implemented with LISP extension language• user can customize behavior

Page 32: EDA Software Engineering

Conclusions

• Your first reaction to any new programming task should not be to start writing C or C++

• Look around for existing modules or libraries

• Use rapid prototyping tools if possible

• As last resort, write code, but use computer-aided programming tools to do it quickly