Scenario #1: ALU & Memory

Scenario #1: ALU & Memory#

Open the Knob & Switch Datapath 1 Simulator in a new browser window. This simple CPU contains four registers, but no control unit. You will be the control unit that directs which registers are operated on and which operations are done.

Take a look at the top box that says Register Bank. At the right are two command knobs, A Bus Address and B Bus Address. These knobs specify which registers should be read as inputs to the ALU. You can click on each knob to turn it.

Set the A bus address to R2 and the B bus address to R1.

Q1: Based on these bus settings, what values do you expect to show along the A and B bus?

The register values are the textboxes with a green background. Currently, all the register default values are zero.

Set the value of R1 to 42. Set the value of R2 to 31. Check that Animation Speed is set on Medium and Number Base is set to +-10.

Q2: What happens when you click Execute? Are the A bus and B bus values what you expected? Why or why not?

The previous set of steps sent data to the ALU. Next we will tell the ALU what to do with the data.

In the bottom right of the simulator is yet another knob entitled ALU Operation. This knob instructs the ALU what operation to perform on the data it has received.

Click the knob so that it points to the instruction A-B.

The box to the left of the ALU knob is a diagnostic. It reports information based on the input provided to the ALU. Right now, zero has a check next to it because the default result is zero. You should see this reflected in the C textbox.

Q3: What do you think will happen to the boxes when the result is less than zero?

Check that the simulator’s current settings to make sure it is set to run A-B, where A is R2 and B is R1.

Q4: With the values of R1=42 and R2=31 that you input earlier, what do you expect the result C to be?

Run the simulator to start a cycle with these settings. Halt the simulator when the result flashes in C.

Q5: Is the result what you expected? Why or why not? What happened to the diagnostic boxes?

Now we want the ALU to do something with the calculated result.

The calculated result gets sent along the C bus back into the register bank. The C Bus Address knob in the top-left of the simulator tells the CPU which register it should use to store the calculated result.

Click the knob to store the result in R3. Run a simulation of a full cycle to subtract R1 from R2 and store the result in R3.

Q6: What settings (e.g., knob positions) would cause the value stored in R3 to be doubled?
Q7: Set R3 to 12 and test your answer to Q7? Did your hypothesis hold true? Why or why not?