Friday, March 30, 2007

LOVE ;)

yeah .. you came to right place .. but for every engineer .. it's really important to have a perfect love life .. so .. I'm gonna give you some information about girls ..and how to use them ;)

I took the writing from web and you gonna see that it's pretty amazing how easy to do thoose kind of things ..


To illustrate how important the subject of handling women
is just look at the divorce rate. A study of the divorce rate
states that 50% of marriages fail and within 20 years or so
it will probably be 75%, I will state here and now (a lot of
women will love me for this and a lot of men will hate me
but it's true) but I really feel that when a marriage or relationship fails it's the mans fault in over 90% of the
cases. He does not know how to handle his wife or
girlfriend; he does not know how to make her happy. He
takes her for granted and ignores her.
The other day a guy who bought one of my manuals on
meeting women through personals called me and asked me
the following. He wanted to know why no women would
stay interested in him. Every woman he met would lose
interest in him after the first or second date. I explained to
him a few simple rules of holding women, the same rules
you will learn, and he now has no trouble. Another guy
wanted to know why all women would refuse to dance
with him when he asked. After I questioned him I realized
that he was making a basic mistake nearly all men make
when they ask a girl to dance.
I had calls from hundreds of guys who have had problems
with women. It is so easy to have dozens of women in love
with you and interested in you that you will be surprised
why you ever had trouble. Men make so many mistakes
with women that it's sad to see them unhappy and
miserable when there is no reason for it. Women are a joy
to know and a joy to spend time with and if only guys
would apply a little know how they could have all the
women they want. You will have all the women you want
when you get through with this manual.

Why You Should Listen To Me
It's so easy for someone to tell you that they can teach you
all there is to know about women and how to handle them.
But why should you listen to me? Who the hell do I think I
am that I should consider myself an expert? Well let roe
tell you what I am not. I am not the kind of guy I am not
good looking; in fact I am very homely. Before I knew
how to handle women I was a complete failure with all
kinds of women. I was the kind of guy who couldn't make
out with a woman even if I paid them a hundred dollars.
That was true until a few years ago, but today things are
quite different.
In high school I was very shy. I rarely dated girls and could
never muster up the courage to ask a girl for a date. The
few dates that I did have were blind dates arranged by my
friends. I had a miserable life in high school as far as girls
were concerned. I met my ex wife quite by accident
through a wrong number I dialed one day on the phone. By
some miracle I got to know her on the phone and made a date. We dated nearly four years and finally got married.
That was the biggest mistake I ever made in my life. I was
22 years old and she was the only girl I ever dated. If by
chance you meet a woman and want to get married please
take my advice and don't do it unless you dated at least a
hundred women. Too many guys get married today and all
they dated were a few women. How could they know if
this girl is for them unless they see what other women are
like?
We were married for ten years and had three kids. Many
times during those ten years I used to daydream what a
great lover I could be if only I wasn't tied down to a wife
and kids. I felt that I had missed a lot by getting married so
young and never having a chance to enjoy being a
bachelor. I believed I could really have a ball if only I was
single. Finally my chance came.
After ten years of marriage, I was divorced and I suddenly
found myself a 32 year old unmarried man. Now I was
ready to live the great single life that I had heard so much
about, I was ready to meet dozens of girls and sleep with as
many as I could. I was a virgin when I got married and
wanted to make up for all that I had missed. I was raring to
go. A single friend of mine told me about what great
success he had in meeting girls in a certain singles bar. I
decided to go with him the following Friday.
After we got to the bar I had a few drinks and was ready to
try to pick up some girls. That night I struck out with every
girl I tried to pick up. I approached ten girls that night and
struck out with every one of them. That was the story of
my life for the next seven years. I wanted to give up on
girls completely. I met a guy who told me about meeting
girls through personal ads and decided to try that method. I
had tried meeting girls in bars and failed. This would be
different.
After a few weeks of answering and inserting personal ads
I came upon a formula for meeting women and it worked. I
even wrote two manuals on meeting women through
personals. You may have one or both of them. I had
arranged to meet a dozen women for coffee whom I met
through the First few ads I placed. I really felt they would
like me and keep dating me if I wanted because I had sold
myself through my letters and phone calls. But a certain
pattern emerged. Out of all the women I met and dated not
one of them wanted to dale me a second time. I was doing
something wrong and had no idea what it was. I placed
more ads and met more women but the problem of holding
their interest was still there. What could I be doing wrong?
I was more depressed than ever. Here I could meet girls
but what was the use if they would not date me more than
once.
I decided to try something different the next time I dated a
girl to see if it would change anything. Boy was I shocked.
One little detail and all the girls were interested in dating
me again. This little known detail is what I call the "D"
technique and it is dynamite. I will explain it in detail a
little later.
I decided to learn everything there was to know about
women and I started by questioning all the women I could.
I talked to nearly a hundred women about what works with
them in holding their interest with guys. They were very
helpful; especially when they found out I would publish a
manual for men on how to handle women. They felt men
could use all the help they could get, they all agreed the
"D" technique was great and gave me loads of other advice
that you will learn about in this manual.
Today when I'm at home it's by choice since I have some
of the most beautiful women in my life now. There is no
more loneliness for me. It took me several months to learn
how to handle women. But I did learn and what I learned
works. Once I found out what to do I changed from a
lonely and unhappy guy to a guy who makes out with the
kind of gorgeous women most guys can only dream about.
You will learn the secrets I discovered in handling
beautiful women. And if you follow my advice within days
you can start meeting and dating some of the best looking
girls in the world.

With Women
I've had hundreds of calls from guys in the last Few years
asking me what is the matter with women. They were
having terrible luck. They could not keep relationships
going at all. Most of them were even having trouble getting
a second date with most women. They wanted to know
why women act the way they do. Some of them had such
bad luck that they wanted to give up completely. This
would have been the biggest mistake they could ever
make. So many of them begged me to write a manual on
handling women. So here it is guys. Read it and be
prepared for a radical change in your social life.
Why
Men Lose A Woman After A Few
Dates
I can state here and now that one of the reasons women
lose interest in men after a few dates is that they are bored.
Most guys take a girl to a movie, then dinner and maybe a
few drinks. They follow the same pattern date after date
after date. No wonder women get bored. You must take a
woman on a date that is different and unique if you really
want to impress her Women like men who are special.
They remember them better and have fantasies and
daydreams about them. If you're not that good looking and
want to win over women from almost any other man then
take her out on a magical memorable date. If you get a first
date with a woman the way to keep her coming back for
more and more is to take her out on a spectacular date. And
the worst place to go on a First date is the movies. How
can you get to know a girl in a dark movie theatre? Some
of the very best places to take a woman on the first date are
the following:
Take her dancing
− One of the biggest complaints that I hear from women is
that men don't like to dance. If you can dance you are way
ahead of most guys. Most women love to dance. If you ask
a woman out and tell her you want to lake her dancing she
will be more eager to go out with you. Why? Because most
men ask a girl out to the movies and she rarely gets asked
dancing so she will consider it a real treat. Women say that
men who like to dance are more sensuous and exciting. A
sexy girl once told me that men who like to dance arc
better in bed and more fun to go places with and do things
with.
Besides when you are dancing with a girl you have a good
reason to touch her and hold her close. I cannot describe
the wonderful feeling you can have while holding a girl on
the dance floor that excites you and appeals to you. But
don't just slow dance, fast dance also. Have you ever gone
to a singles bar where they have a band? How many times
do you see two women fast dancing together? That is
because most guys do not fast dance. When women know
you can fast dance they will be extremely eager to get to
know you and date you. Let's hear what Roger has to say
about dancing.
Roger
− "I was really a lousy dancer. When I went to a singles
bar I would usually just stand there against the wall with a
drink. Whenever I wanted to meet a girl I would usually
walk over and mumble to her about buying her a drink.
90% of the time I would be turned down. One Friday night
I was at my favorite bar watching the sexy girls dancing. I
kept watching this one girl. Man was she beautiful. I could
not take my eyes off her. She had long blonde hair and a
build that wouldn't quit. I watched her for hours. Not one
guy ever asked her to dance. She sat out every slow dance
and danced most of the fast dances with her girlfriend.
When the band announced it was the last song I decided to
take a chance and ask her to dance. I walked over and said,
"Would you like to dance?" She said yes which shocked
the hell out of me. When we were on the dance floor I held
her tight (it was a slow dance) and was as nervous as hell. I
was shaking because she felt so good in my arms and I
could smell her perfume. It was like an aphrodisiac to me. I
don't know what gave me the courage but I asked her if she
would go out with me. I told her we would go dancing and
have a good time. She told me that no guy had ever asked
her out dancing before and that she would be thrilled.
I took her out the following Friday night and we had the
most fun I ever had on any date. She told me that she
would remember our first date forever because most guys
just took her to a movie and then home. We dated nearly
three months and finally she moved out of town because
she got a job transfer. But she did tell me that the main
reason she went out with me was because I asked her to go
dancing. She was so beautiful that my confidence soared in
meeting other women and I now know most women love
to dance and dancing would break the ice on the First date.
Asking a girl to go dancing increased my chance of getting
a date with her 100%.
Take
her to an amusement park − This is a real fun date. Offer
to take a girl to an amusement park and you will almost be
guaranteed a yes answer when you ask her out. I would
like to have Richard tell you about an amusement park
date. Before he does I would like to add here that many of
my manuals include a lot of case histories. That is because
when many of these guys talk to me I feel it would be so
much more personal to include their actual words in my
manual. I feel that they could get the point across better
than I. Do you like this practice? Write and let me know. If
you have any good experiences in meeting and dating
women write and let me know. I might include it in my
next manual. On to Richard.
Richard
− "I was at a singles bar one night feeling sorry for myself
as usual. I just could not meet any women. My buddy was
there with me and he made contact with a good looking
girl. I thought how lucky he was. He came over to me and
told me that the girl he met had a girlfriend and asked if I
would like to meet her. I was really interested but I didn't
know what to say to her so I asked him what she looked
like. He told me that she was a fox and wanted someone to
dance with. I reluctantly agreed to meet her but I was
positive that she wouldn't like me.
When my buddy brought her over to introduce her to me, I
was shocked speechless. She was a real beauty. Her name
was Laurie and she looked like an angel that dropped from
heaven. She had long dark hair and beautiful sparkling
eyes. My buddy left her alone with me and went off
dancing with the girl he was with.
Laurie was real sweet but I didn't know what to say to her.
I was an avid talker with guys but here with this beautiful
girl I was speechless. It's a good thing the bar was closing.
I wanted to see Laurie again so I asked her out. At first she
hesitated, but I blurted out "Maybe we can go to Disney
World."
Her face lit up just like a kid who had been told that Santa
Claus was coming. Her entire tone changed. She was so
excited. Though she had lived in Florida a couple of years
she had never been to Disney World. She said that she
would be thrilled to go.
That Saturday was one of the best days in my life. We
went on most of the rides, even the ones mostly for kids.
We were like two kids that day having the best time of our
lives. Laurie said that it was the best date she ever had.
Laurie and I have been dating about six months now.
Recently she told me that she would never have got to
know me if I didn't take her to Disney World that day. She
wasn't going to go out with me because I seemed dull and
boring. Asking her to go to Disney World broke the ice.
She told me very few guys would take a girl to an
amusement park and when they did they had a very good
chance of winning a girl's heart.
All women like the little boy in a man. Show her this little
boy and you'll be surprised at the results. Don't be like
every other guy and take her to dinner and a movie. Be
different and you'll have more women than you can handle.
Other places you can take a date to make it unforgettable
are some of the following — take her on a Sunday picnic, a
picnic is very romantic and she'll remember it for a long
time. How about a helicopter ride? − That’s different and
unique.
Bring her a present on the first date. She'll view your
generosity as a sign of love, of caring, of giving. Try it.
Next time you arrive to pick her up see how excited she is
because you've brought her a box of candy, a card you
thought was funny or some flowers.
Do the above and I guarantee you won't be sorry. You will
be amply rewarded.
Biggest
Mistake Men Make On Their First
Date
You may be shocked at the material in this section but I've
talked to hundreds of women and they are in agreement
that men are too aggressive, too pushy, especially on the
first date. According to most women, men act like
sex−crazed idiots, like a dog in heat. This goes hand in
hand with the "D" technique, which I will describe in the
next section. A lot of good−looking women expressed the
same attitude as Tina did.
Tina
— "I just don't understand men. They all think that they
have to act like some kind of macho he−man to win over a
woman. I met this real nice guy at a singles dance one
night. His name was Jim and he came across as a sincere
nice person. He asked me for a dale and I agreed. He
wasn't that good looking but he seemed to have a real nice
personality.
He picked me up for our date and right away I noticed a
difference. Women know. In the car he seemed to be
leering at me, as if he was undressing me with his eyes. He
looked as if his tongue was hanging out and he kept
panting like a dog in heat. I couldn't believe that this was
the same guy who I had met a few days earlier.
He took me to a movie and put his arm around me. That
was nice and romantic but he started kissing me on my ear,
which was a real turnoff for two reasons. It was too soon
after I met him and it was in a crowded movie theater. He
was also breathing hard like he was extremely worked up
and raring to go.
We went to a singles bar afterwards and that was even
worse. I love to dance but not with him. We danced a few
slow dances and that was enough. On the dance floor he
was humping me as we danced. It was crude and vulgar. I
was embarrassed and humiliated. I felt as if I was being
raped on the dance floor.
I finally told him that I didn't feel well and had to go home.
At the door he asked if he could come in for a drink or a
cup of coffee. What nerve! I told him to go to hell and
slammed the door in his face, He called me many times
after that but I would never go out with him again. Where
are all the nice, courteous, romantic men? Practically every
guy I meet expects sex on the first date. I want to be
courted in the old fashioned romantic way. Maybe it's just
a dream. There are no nice guys around."
It's a shame that Tina feels I hat way. There are a lot of
nice guys around but most of them are misguided as to
how to treat a woman on the first date. A woman is not a
piece of meat. She's a wonderful person with feelings.
A lot of books I read on meeting women say to move fast,
that women like it when a guy moves fast. This is total
B.S. Do not feel that every lime you take a woman out it
must end up in a heavy love making session, especially on
the first date. Ignore some of the advice you may have
heard about speeding up when you're with a woman. A
woman today wants a man who is different and unique.
Show her some consideration and respect especially on the
First date. You will rarely seduce a girl by being too horny.
The more desperate you seem for sex, the less a woman
will want to have sex with you.
For a woman nothing is more important than having a man
take his time. Usually this is not what a woman runs into.
Most men bombard women with sexual demands. If they
don't come right out and ask the woman to go to bed with
them, they usually act sullen and withdrawn until the girl
agrees to give them what they want. This is a real turnoff
because most women read this as sexual anxiety and
insecurity. It's a real turnoff.
A slow pace is what the skilled lover takes. When he
finally decides to have sex the woman is a very willing
target. The advantages of taking your time are numerous.
You are different from the hundreds of men stampeding
after sex. Taking your time implies to a woman that you're
a skilled lover, whether you are or not. It allows you to get
to know a woman in a relaxed way so when you do make
love to her it will be very exciting and wonderful. In the
world of winning with women, it is one of the best
techniques there is.
This is very important. Don't push and push a girl to have
sex. This goes hand in hand with the "D" technique, which
I consider dynamite in winning women. Use the "D"
technique and be prepared for hoards of women to fall in
love with you.

this will contionue .. dont worry ;)

Sunday, March 25, 2007

The problems we confront while designing an elevator circuit

Don't worry, I'm gonna post the design of ours with pspice later .. today I just had time to post that .. It will continue ..


In our design we have two inputs. IN1 is to choose the way you wanted to go and IN2 is to stop the elevator on which floor you want. After the design procedure we came the real part : setting our circuit up. In this part we spend a lot of time to see the result we wanted to. Because there was really lots of reasons to keep us out of the way.

In our early times at laboratory we set a circuit that we both examined while setting the circuit elements for keeping our circuit out of trouble from connection errors. After we finished the circuit, before plugging the VCC on we make sure that the JK flip flop’s K parameter is converted with NOT gate as we follow on datasheet. And PR and CLR legs of JK flip flop are both 1 to see the behavior of synchronous circuit. After we plug 5V dc voltage we saw that something was wrong. The circuit was not answering our inputs according to clock signals. We were taking the signal from TTL(transistor transistor logic) output of the generator. This output is supposed to give us 5V and it must be independent from amplitude bar of the Function generator. We examined the output of the function generator on the oscilloscope and see that the TTL output was not working properly.

After changing the output of the generator we plugged the Voltage connections again and with a bit of excitement we rushed to see the result of our circuit. It was failure again. Plus we smelled something was burning. After a second we realized that it was coming from our circuit, JK flip flop. We unplugged the sustention safely with our right dry hands and sniffing the brief and weird smell in our lungs. The voltage was supposed to be 5V as we examined before we plugged the circuit. We listened the lab attendance suggestion and examined the voltage again and we saw 20V on the oscilloscope screen.

So we changed our cadet . But we were not sure about if all the gate’s were burned out. So we decided to inspect all the legs of the gates to make sure that everything was alright with our circuit elements. We keep following that procedure and we found something interesting. In some integrated circuit some of the leg’s were working but some of them weren’t. So we changed that half-burned integrated circuit’s with brand new ones. But before changing them we tried all the integrated-circuits we bought before using.

After changing circuit elements we still couldn’t got the result we want. And yes we felt a little tired of that. Because we set that circuit like ten times and we were able to remember those functions we found on the design procedure and the proper legs of the integrated circuits. But still couldn’t get it to go. Everything was right and every connection was correct. We suspected from our design and set it on the workbench. We were getting the results we want. So our design was also true. What was the problem ?

This time we used a different method while inspecting the circuit. We started to touch with the probe to the leg of the integrated circuit not the potential line to see if there might be any difference between the gate voltage and the potential line. Then we inspected the board which we inserted the circuit-elements. There were same voltage potential on different voltage lines. That means there was a short circuit under the circuit board. Then we found several of the on the other sides of the board. The reason of that short circuits might be the cables that we used on our circuits. We were using those boards for 2 years and including our freshman year. In our freshman year we might pull that cables not kindly and cause the cables to trap under the circuit board. Those conductor peace’s we left inside the board might cause a problem after while we tried another cable for another circuit later. After a quick chat with lab attendance he showed us inside the boards that we used in our experiment. We looked at the design and It’s a miracle to keep that board out of any trouble. So we decided to keep our cable’s conducting parts on optimum length.

And after 40 minutes we had a circuit with result !!

We played a little with our circuit parameters to see what are the really effective on the result. After all we become really familiar with some of them:

We must use same kind of cable. At the lab in the cable box there are some cables like we used in our circuits but a little bit chubby ones. After we finished our circuit and see it working properly we changed one of the cable inside of our circuit with that chubby ones and observe that with time the operations which our circuit do becomes a weird with time. The bit that which has the chubby cable inside the connections has becomes a little faster with time. We came to the conclusion as a group that if we would change the clock frequency with higher frequencies there might be huge problems on the outputs.

We must use the same firm’s integrated circuits. If we use different kind of integrated circuit there might be some problem with our output lines because of the propagation delay of our gates. With higher frequencies that problem can grow bigger and bigger.

We got out of the laboratory and looked at the sky. There was a rainbow on the sky. But we were able to see only two legs of the rainbow. The middle part was disappearing with the clouds. And here its our dialog:

A-Look at the rainbow!

B-Look there is another one there …!

A-I think they are same. Follow it to the clouds . They are disappearing in to same cloud.

B-Are you sure ?

A- …

B-…..

A- Alright!! Get me the scope and a probe! :):):)

Friday, March 23, 2007

Coding Principles

Almost every wise saying
has an opposite one,
no less wise,
to balance it.

It's an intresting saying by George Santayana. If we think about it for a while We can easily see that it is true in every single one of sayings .. interesting indeed ..

In this post of mine I'm going to try to explain you some the coding principles for you to maintain your level of coding time after time .. Here we go now ..

Facing problems (and solving them) is a way of life for programmers. When
a problem arises, you want to solve it quickly. If a similar problem
occurs again, you want to remember what you did the first time and
fix it more quickly the next time. Unfortunately, sometimes you’ll see a
problem that looks the same as something you’ve seen before but can’t
remember the fix. This happens to us all the time.

Can’t you just search the Web for an answer? After all, the Internet
has grown to be this incredible resource, and you might as well put
that to good use. Certainly searching the Web for an answer is better
than wasting time in isolated efforts. However, it can be very timeconsuming.
Sometimes you find the answers you’re looking for; other
times, you end up reading a lot of opinions and ideas instead of real
solutions. It might be comforting to see how many other developers
have had the same problem, but what you need is a solution.

To be more productive than that, maintain
a log of problems faced and solutions found.
When a problem appears, instead of saying,
“Man, I’ve seen this before, but I have no clue how I fixed it,” you can
quickly look up the solution you’ve used in the past. Engineers have
done this for years: they call them daylogs.
You can choose any format that suits your needs. Here are some items
that you might want to include in your entries:
• Date of the problem
• Short description of the problem or issue
• Detailed description of the solution
• References to articles, and URLs, that have more details or related
information
• Any code segments, settings, and snapshots of dialogs that may
be part of the solution or help you further understand the details

Sunday, March 18, 2007

simulating a rabbit colony_with java

I'm posting the document that I find on net to you. It's very practical and explains the event step by step .I think you can came out with more creative and illustrative stuff later after you acomplish that simulation example .. smile :)

We would like to write a program which models how a rabbit colony grows over time. We start with
a single male-female pair of baby rabbits. It takes two months for a baby to become an adult. At the
beginning of the month in which the pair reaches adulthood, they produce a pair of male-female baby
rabbits. They continue producing a single male-female pair of babies every month after that.
Data members of RabbitColony
Putting on the class provider hat, we start by deciding what data members are needed to describe a rabbit
colony. We will need three variables: one variable for storing the number of pairs of baby rabbits, one for
storing the number of pairs of rabbits that are 1 month old, and a third variable for storing the number
of pairs of adult rabbits. The beginning of our class would therefore look something like this:
class RabbitColony
{
int babies = 1; /* number of pairs of baby rabbits
(starting with 1) */
int young = 0; /* number of pairs of 1-month old rabbits */
int adults = 0; /* number of pairs of adult rabbits */
}
Methods of RabbitColony
We next decide what methods we need in our class, i.e. what would the class user want to do with a
rabbit colony? We decided on the following methods:

• a method which grows the colony for 1 month,
• a method which grows the colony for any number of months, and
• a method which returns the total number of rabbits in the colony.
This is the outline of the class with empty methods:
class RabbitColony
{
int babies = 1; /* number of pairs of baby rabbits
(starting with 1) */
int young = 0; /* number of pairs of 1-month old rabbits */
int adults = 0; /* number of pairs of adult rabbits */
// grow the rabbit colony by one month:
void grow()
{}
// grow the rabbit colony by n months:
void grow(int n)
{}
// calculate the total number of rabbits and return the value
int getNumRabbits()
{}
}
The first grow method takes no arguments and returns nothing. It will simply change the state of the
object (i.e. increase the variables in the class). The second grow method takes an integer as an argument
(the number of months to grow the colony). It also returns nothing, since it just updates the variables.
The getNumRabbits takes no arguments, but returns an integer.

• a method which grows the colony for 1 month,
• a method which grows the colony for any number of months, and
• a method which returns the total number of rabbits in the colony.
This is the outline of the class with empty methods:
class RabbitColony
{
int babies = 1; /* number of pairs of baby rabbits
(starting with 1) */
int young = 0; /* number of pairs of 1-month old rabbits */
int adults = 0; /* number of pairs of adult rabbits */
// grow the rabbit colony by one month:
void grow()
{}
// grow the rabbit colony by n months:
void grow(int n)
{}
// calculate the total number of rabbits and return the value
int getNumRabbits()
{}
}
The first grow method takes no arguments and returns nothing. It will simply change the state of the
object (i.e. increase the variables in the class). The second grow method takes an integer as an argument
(the number of months to grow the colony). It also returns nothing, since it just updates the variables.
The getNumRabbits takes no arguments, but returns an integer.
Using the RabbitColony class
Before we write the code inside the methods, we will take off the class provider hat and put on the class
user hat to see how this class could be used. This is an approach often used by programmers: to imagine
how your class will be used before you have finished writing it. It helps to ensure that the methods you
have chosen make sense. Here is a sample program that uses the RabbitColony class:
public class UseRabbitColony
{
public static void main(String[] args)
{
RabbitColony rc = new RabbitColony();
rc.grow(6); // grow rabbit colony for 6 months
int num = rc.getNumRabbits();
System.out.println("Number of rabbits after 6 months = " + num);
}
}
We will run this later, when we have finished writing the class. Note that we have used the default
constructor for creating the RabbitColony object. Although we have to provide code for all methods
in the class, the default constructor is an exception, since it is automatically defined if we do not write
our own constructor. In Section 3.10, we will write our own constructor.
Now that we have a better idea of how the class can be used, we can go ahead and write the methods.

Defining the grow() method
In the grow method, we have to simulate how the number of babies, young and adults increase in one
month. We have to convert the following facts into Java code:
• all the current young rabbits become adults;
• all the current babies become young;
• all the adult pairs (including the new ones) each produce a single baby pair.
Here is the Java code corresponding to the statements above:
// grow the rabbit colony by one month:
void grow()
{
adults += young; // all the young become adults
young = babies; // all the current babies become young
babies = adults; // all adult pairs produce a baby pair
}
Note that the order of these statements is significant. Can you see why? Do Exercise 3.10.
Defining the grow(int n) method
The parameterized grow method must grow the colony for any number of months. The first thing to
notice is the variable n. In the argument list of the method definition we have to indicate the type of the
argument (in this case an int). We also have to specify a name for the argument, so that we can refer
to it inside the method. We have chosen to call it n, but could have chosen any other suitable name.
In the main method, where we used the RabbitColony class, we grew the colony for 6 months
(rc.grow(6)), but we could have used any number as an argument. We call the number 6 an actual
parameter. In the method definition, we call the variable n a formal parameter.
Inside the method, all we do is call the grow() method n times. Here is the code:
// grow the rabbit colony for n months
void grow(int n)
{
for(int i=1; i<=n; i++)
grow();
}
Notice that we don’t need to precede the method call with the object name in this case, because we are
inside the class.
Defining the getNumRabbits() method
The getNumRabbits method must calculate the total number of rabbits and return the answer. Here
is the code:
// calculate the total number of rabbits and return the value
int getNumRabbits()
{
int num = 2*(babies + young + adults);
return num;
}

The first statement calculates the total number of rabbits, by adding the pairs and then multiplying by
two. This is stored in a variable called num. The Java keyword for producing an answer from a method
is return. In this way the method returns the value stored inside num.
Tracing UseRabbitColony
We will now explain how UseRabbitColony works, by tracing through the program. The first statement
is:
RabbitColony rc = new RabbitColony();
It creates the object in memory with the default values, as illustrated in Figure 3.7.
The second statement is:
rc.grow(6);
It results in a jump to the second grow method. Note: Java knows to use the second grow method
and not the first one, because we have given it an argument. In the method, n will take on the value
of 6 (only for the duration of this method call). The body of the loop will therefore execute 6 times.
Each time, the program jumps to the other grow method to execute the three statements there. Table 3.3
shows how the variables change on each loop iteration. See if you can work them out for yourself.
The third statement of the program is:
int numR = rc.getNumRabbits();
Java will first evaluate the right hand side. To do so, it has to jump to the getNumRabbits method.
At this stage, babies contains 5, young contains 3 and adults contains 5. These values are totalled
and multiplied by 2 to produce an answer of 26, which is returned to the calling statement and stored in
numR. Finally, this value is printed out.

Friday, March 9, 2007

let's make a start to digital systems !

Processor Design

Combinational Logic and K-Maps

Now that we've looked through Boolean Algebra, we are going to take a leap into the world of schematics and more advanced logic. To begin with, you need to know the schematic symbols for our combinational logic circuits. Here are the key ones you should know:

*

*

= AND

+

+

= OR

!

!

= NOT

(+)

(+)

= XOR

You see here a new symbol as well--XOR. When two numbers are XOR'd they answer is only 1 if 1 or the other is 1, not both, pretty easy. From these we will build more complex parts like adders and multiplexors. Instead of re-writing the entire circuit as we go along, we will place these in a square box with their name. You will see this as we go along.

Okay then, time to build our first circuit, a half adder. This is a circuit that will add 2 binary numbers together, ignoring the possibility of a carry in. The lack of ability to handle a carry gives it its name. The theory behind a half adders logic is pretty basic. There are two inputs, binary number A, and binary number B. Also, there are two outputs, Sum and Carry. Now let's use what is called a truth table to look at what the values of each number should be. We begin by making a truth table that has every possible input combination, like this:

  A  |  B  | Sum | Carry
-------------------------
  0  |  0  |     |
  0  |  1  |     |
  1  |  0  |     |
  1  |  1  |     |

Next, we fill out what the "answers" to our problem would need to be, like this:

  A  |  B  | Sum | Carry
-------------------------
  0  |  0  |  0  |   0
  0  |  1  |  1  |   0
  1  |  0  |  1  |   0
  1  |  1  |  0  |   1

There, we have now completed our first truth table. The next stage, is to develop a formula to figure out which combinations give us our desired values. First let us look at Sum. Sum is equal to one only when A or B is equal to 1, but not both. This sounds just like a XOR gate, so lets put it together in an equation-- Sum=A (*) B. Now, let's look at the Carry. The Carry is only equal to one when both A and B are equal to 1, so let's use an And gate, leaving us: Carry=A * B. Now we have the two needed equasions to make the circuit. Lets look at it like this-
Half Adder Schematic

Okay, this is a good start. However, half adders are not really useful for anything other than a building block. For any real processing, we need to have a full adder that is capable of receiving a carry, as well as outputting one. The full adder works in the same way that we did the boolean math, and carried the numbers over for addition. This lets us chain them together to make a higher level (bit) implementation of the same circuit. The three inputs of the full adder will be represented as A, B, and CI (carry in). The outputs will be named S (sum) and CO (carry out). We will write sum as S = CI (+) A (+) B, and CO as CO = CI * (A + B) + A * B. Great, now lets just re-write that in schematic form:
Full Adder Schematic

We are now complete with learning the most basic combinational logic circuits. Although the methods of writing out the truth table and looking to discover a way of implementing the answer works, it is really not very efficient. With the more complex circuits that we will be creating, simply generating an answer without a good method does not work. That is why we use Karnough maps. Karnough maps are the basic foundation of how to develop single stage implementations of combinational logic circuits. I am going to give you a short introduction to Karnough maps, however, they take lots of practice. Because of the complexity of Karnough maps, I will show you the basic steps, and let you explore more on your own. For an excellent source to learn more, I would highly recommend purchasing Randy H. Katz's book, Contemporary Logic Design. He has excellent examples, and goes very in-depth. Well-- enough of where else to look-- Let's jump in now!!

K-Maps

A K-map is going to be our key for developing a foundation of pieces to use in our processor. Based on the theory of boolean truth table adjacencies, K-maps provide a simple approach to determining realizations of complex combinatational logic problems.

In order to use a K-map, we must first talk a short bit about Grey Code. This is the binary implementation where never more than a one bit shift occurs in our counting. All K-map's will be written using grey code, so that our adjacencies can be properly extracted. First, let's take a look at a simple K-map structure.

     Map of Z, as a funtion of ABC
                   AB
          00    01    11     10
      --|-----|-----|-----|-----|
      0 |     |     |     |     |
   C  --|-----|-----|-----|-----|
      1 |     |     |     |     |

This empty K-map shows us the basic setup that goes into a logic problem. Remember those old elementary logic puzzles where you filled in a grid pattern to determine a given problem? This is very similar. First, we need to pay special attention to the way that the grid is layed out. The top is representative of the A and B values, while the side is that of C. This will be easier to see when we map a problem to our K-Map. Let's use the following truth table to develop a function for.

A, B, and C are inputs, while Z is our output.
 
   A  |  B  |  C  ||  Z
  ----|-----|-----||----
   0  |  0  |  0  ||  1
   0  |  0  |  1  ||  0
   0  |  1  |  0  ||  1
   0  |  1  |  1  ||  0
   1  |  0  |  0  ||  0
   1  |  0  |  1  ||  1
   1  |  1  |  0  ||  0
   1  |  1  |  1  ||  1

Alright, now let's take that truth table, and map the Z's into our K-map based on their A, B and C values.

                   AB
          00    01    11     10
      --|-----|-----|-----|-----|
      0 |  1  |  1  |  0  |  0  |
   C  --|-----|-----|-----|-----|
      1 |  0  |  0  |  1  |  1  |

Perfect. You can now see that our function, Z, is equal to one in 4 locations. Now, lets use what is called Sum of Products form (or SOP) to determine a simple formula. We need to group our adjacent 1's in powers of 2 (ie 2, 4, 8 ...) first. This leaves us with two cirlces of grouped ones. On on the top left, the other on the bottom right. Now, just take the values for A, B, and C that make up those circles. The first (top left) is made up of A=0, and C=0. As you can see, it is 1 for both values of B, so we ignore B. We can then write the formula simply as (A'B'). We next need to look at the bottom right corner. This is made up of values A=1, C=1, or (AC). Our final formula is the sum of these to products, or (A'B')+(AC). This is equal to our Z. By grouping these adjacencies, we can determine any size problem of any type, quickly and easily.

That is really all there is to Karnough maps-- except understanding what is adjacent. You need to remember that our K-maps are really 3-d, so the top right number is adjacent to the top left, as if the map were really on a sphere. I know this will take a little getting used to, but as we do K-maps throughout the next several sections, you will pick it up quickly.