Title: Computer Organization
1Computer Organization
Project 6 Prof. Jerry Breecher CSCI 140 Spring
2002
2Software Engineering
- Engineering is the art and science of building
things. Over the years, Engineering has moved
more from art to technique. People have learned
what works and have developed practices to build
things as efficiently as possible. - A little known fact is that half of all
cathedrals built in Europe in the Middle Ages
fell down (mostly during construction.) Those
cathedrals were state-of-the-art for their time
they stretched materials and craftsmanship to
their limits. - Over the years, weve learned a great deal about
building things. For instance, the last time a
major suspension bridge fell down was in the
1930s. You occasionally hear about buildings
falling down, but its usually attributed to
shoddy construction - the builders didnt follow
the rules. - In a similar fashion, Software Engineering is the
craft of building large software programs.
3Software Engineering
- You are ready to hear about this topic, because
Software Engineering is required whenever you
have a project to build that you cant keep in
your head all at one time. - When you start writing programs, they are usually
exercises, used as examples of coding techniques. - By the time you get to upper level courses, you
are no longer learning programming for the sake
of learning programming, but have a reason
associated with that program - youre trying to
build something. And that something can get
quite large. - So its time to start using some of the
techniques of Software Engineering in order to
build your projects.
4Software Engineering
- Software Engineering covers a wide range of
topics - 1. Figuring out what it is you want to build -
the requirements of the project. - 2. Going from the requirements to a functional
design. - 3. Taking that high level/functional design and
turning it into smaller chunks or algorithms. - 4. Figuring out the steps required to implement
the algorithms. - 5. Coding the algorithms in a specific language.
- 6. Testing the code to ensure that it works as
required. - 7. Maintaining the code - fixing bugs and adding
modifications as the requirements change. - For our purposes, were going to look at Steps 4
and 5. We implicitly do the other steps, but
this exercise will not stress those aspects.
5Breaking Down A Project
- Now were going to learn a few rules. Then well
apply these rules in a very simple example. And
then well go wild and try the rules on a more
complicated software example. - The Rules
- 1. Break down the project into smaller pieces.
- A. There should be no more than four or five
pieces. - B. If possible, make those pieces
approximately equal in size. - 2. If each of the pieces contains more than one
action, go to Step 1. - 3. Stop only when you have a series of pieces
and sub-pieces that each contain only one action.
6Breaking Down A Project
- An Example
- Break down into single actions, the Project of
eating lunch in the cafeteria. - Level 1 - Eating Lunch
- 1. Find a friend to eat lunch with.
- 2. Get your food.
- 3. Eat it.
- Level 2 - 2. Get your food
- 2A. Pay the cashier.
- 2B. Salad bar
- 2C. Pasta Bar
- 2D. Hot food
- 2E. Dessert
Each of the Level 1 items has a Level 2. Picking
just one of these we get
Breaking this down still further
7Breaking Down A Project
- Level 3 - 2A. Pay The Cashier
- 2A1. Find your card
- 2A2. Hand the card to the cashier
- 2A3. Get the card back from the cashier
- 2A4. Say Thank You
- 2A5. Put the card back in your pocket.
Breaking this down still further
8Breaking Down A Project
- Level 4 - 2A1. Find your card
Can you think and talk at the same time
Yes
No
Stop Talking
Think about where your card is.
Reach into your pocket.
This is a flowchart
Is the card there?
No
Yes
Extract Card From Pocket.
A decision box
A descriptive box
9Breaking Down A Project
- Level 4 - 2A1. Find your card
- 2A1a. Can you think and talk at the same time?
If yes, go to 2A1c. - 2A1b. Stop talking.
- 2A1c. Think about where your card is.
- 2A1d. Reach into your pocket.
- 2A1e. Is the card there? If no, go to 2A1a.
- 2A1f. Extract card from pocket.
This is a list.
This page and the previous one are identical.
Either a flowchart or a list works for showing
decision making.
10Breaking Down A Project
- Here it is from another perspective!!
11Breaking Down A Project
- OK, so that was good practice.
- Lets try the same thing but on a programming
problem. Youll find that problem at the end of
this handout. Now its your turn to practice. - Task N
- Your job will be (eventually) to write a program
to solve this problem. But were going to
sub-divide the job into many smaller tasks. - Task 1
- Write a series of Level 1 steps that break down
this problem. Remember, there should be no more
than 4 or 5 steps in this level. Remember also
you want to make each of the steps about equal in
weight. This is equivalent to the example we did
where we ended up with the following - Level 1 - Eating Lunch
- 1. Find a friend to eat lunch with.
- 2. Get your food.
- 3. Eat it.
- Go no further were going to talk this over as
a group.
12Breaking Down A Task
- Now that weve talked over the Results of Task 1,
we are ready to go on. - Task 2
- Take the first of these high-level steps and
subdivide IT into Level 2 Steps. (This can be
either a list or a flowchart.) - Find a friend in the lab, and talk over your
solutions to this Level 2 subdivision. Agree on
the best way of doing this subdivision. - Go no further were going to talk over this
result as a group.
13Breaking Down A Task
- Now that weve talked over the Results of Task 2,
we are ready to go on. - Task 3
- Are your Level 2 steps small enough? Can you
take each of those steps and write code? If yes,
great. But you might find that you need to do a
low-level breakdown. - Take one of your Level 2 steps and break it down
until it is of a size that can be coded these
are Level 3 steps. (This can be either a list or
a flowchart.) - Find a friend in the lab, and talk over your
solutions to this Level 3 subdivision. Agree on
the best way of doing this subdivision. - Go no further were going to talk over this
result as a group.
14Breaking Down A Task
- Now that weve talked over the Results of Task 3,
we are ready to go on. - Task 4
- You will do the rest of this on your own. Do NOT
work with a partner on the remaining pieces. - Continue to break down your remaining Level 1
Steps, each into a series of Level 2 Steps. - Those Level 2 Steps that are still too big to
code directly should be divided into Level 3
Steps. - You will end up with something like the chart
below. - Hand in this final product.
15Representation
There are a number of ways of representing the
complete breakdown of the problem
LIST 1. Step 1 Level 1 Description 2. Step
1A Level 2 Description 3. Step 1B Level 2
Description 4. Step 1C Level 2
Description 5. if input is TRUE, then
goto line 7 6. Step 1C1 Level 3
Description 7. Step 1C2 Level 3
Description 8. Step 1D Level 2
Description 9. Step 2 Level 1 Description 10.
etc.
Flow Chart Step 1 Level 1
16The Problem
- Heres a description of the problem you are to
solve. You will do this via the method described
on the previous pages. - Finding a Square Root
- Computers, of course, can be asked to solve a
square root function. In C this problem could
be solved by using the function - root pow( X, 0.5 )
- So, how does C solve this function? If C is
running on a CISC processor, theres probably an
Assembly Level instruction that can do the job.
In fact, on an Intel processor, this instruction
is - SQRTSD Rd, Rs
- Take the square root of the double precision
number found in Rs, and put the result in Rd. - On a RISC processor, there is no such
instruction, so the C Language Runtime Library
has to do the calculation, using the RISC
instructions (multiply, divide, etc.) that it has
available from the RISC language set. - Whether its done in hardware (CISC) or in
software (RISC), the calculation is based on a
mathematical entity called a Taylors Series.
17The Problem
One of the things thats interesting about this
is that it goes on forever!
The Rest Of The Story As you can see, this
series only works for square roots between 0 and
2. To make this work in a general case, you need
to do the following Step 1 Start with the
value you want to evaluate Step 2 Find Y,
the largest square thats less than Z. Step 3
18The Problem
- So The Hardware or Software Performs This
Calculation - As you can see, the solution of the Taylors
Series involves a loop in which each term of the
series is calculated. These terms each have a
lot of pieces in them, so theres a bit of
thinking to do here. - Your job is to calculate this series.
- First do the original series that will accept
values from 0 to 2. - Only when that is successful should you undertake
The Rest Of The Story.