Tuesday 24 March 2009

peanut butter and jam

I know this may seem a strange title for a blog, but I did something different in class today, the lesson was about processors, and they work. Fetch, decode, execute.

This lesson is based upon exercises found at the Intel website.

High-Tech Sandwiches
This handout teaches students the need for clear, concise instructions when programming a task for a microprocessor or "robot." Working individually, students write a set of step-by-step instructions for making peanut butter and jelly sandwiches. Students then try to make sandwiches following each other's instructions. Or, a student or the teacher tries following one set of instructions in front of the entire class.

This was a fun experience, I had two loaves of bread, white and wholemeal. Strawberry and raspberry jam, crunchy and smooth peanut butter. The students started off by being a bit strange, what is this, why is he tempting us with food? But as the lesson went on I started seeing something strange, some students we so hungry that they could not think about what the needed to do, they would test out there process and fail, which forced one students to break the seal on the peanut butter, force a knife into the jar and spread it on his bread and eat it. Other students soon found the requirements too much and had to have a go as well. I though, man this must be rather difficult, considering missing simple steps of opening a jar, and closing and cleaning up they had to think about as well.

I go through the exercise tomorrow with them through the fetch, decode, execute and what this means to a computer, I will be able to use the class today to link all that together. Yes, everyone did manage to make a sandwich, but it was interesting that it took 20 minutes before the first one was correctly made.

Explain the CPU of a computer is where instructions are handled by the computer. It is helpful to point out that instructions are the basic building blocks of programs, like Windows and word processors. Ask for 4 volunteers and have them stand in a row.

As you explain the Fetch/Decode/Execute/Memory Handling instruction cycle, give each person the appropriate nametag. Now, say that you are going to have them simulate processing an instruction. With proper prompting, have the Fetcher fetch an instruction, the blank card. Declare one computer cycle. Since the Fetcher is done, the Fetcher passes it on to the Decoder. The Decoder decodes the blank card... and the process continues.

Now, ask the students to talk about what happened. Lead them with asking how active everyone was? Specifically ask the Fetcher what he/she was doing the entire time. Then ask if there's any reason why the Fetcher couldn't fetch another instruction after fetching the other one. Do it, but after the Decoder is done with the first, ask what to do with the instruction that the Fetcher is holding. The students are likely to suggest the Decoder takes the new instruction in the next cycle. Eventually, you get the pipeline full like you want.

At this point, congratulate the students on discovering the concept of pipelining, one of the major design principles in computer architecture. Explain that what they did is used in most if not all modern processors.

No comments: