Summary: You will explore a simple but complete instruction set architecture.
Collaboration: You will work with a randomly assigned partner during class.
Submitting: You do not need to turn in any work for this lab. If you are unable to finish all of the exercises during class time, you should complete this work on your own. So that we may transition to the MIPS datapath as a class, please notify the instructor when you complete Part D.
In this lab, you will explore a complete CPU architecture. Specifically, you will look at how an instruction is processed along the CPU datapath, how values from memory are incorporated into CPU instructions, and the fetch-execute cycle.
The Knob & Switch Computer uses metaphor and an incremental approach to demonstrate the interactions between CPU datapath, CPU control, and main memory. We use it in this lab to introduce the main concepts of computer organization before getting into the details of MIPS instructions and digital logic.
Open the K&S Datapath Simulator. If the link doesn’t open, then visit the Knob & Switch Computer and click the appropriate link.
This simple CPU contains four registers, but no control unit (or memory). That is because you will be the control unit! You direct which registers are operated on, and which operations are performed.
R1 to 42 by clicking on the zero and typing in a new value. Then set the value of R2 to be 17.R1 and the B bus address to R2 by clicking each appropriately. Note: A bus is essentially a collection of wires used to transport data from one component to another. A better animation would show the four bits flowing along four wires.R1=42 and R2=17 again then “program” the simulator to compute R3=R1-R2 and execute your simulation.In this section, we add memory to the datapath and switches to direct traffic to and from it.
Open K&S Datapath Simulator with Main Memory. There are two new components: main memory and bus switches.
The main memory values on the left of the simulator represent RAM. The button next to each memory location indicates which location will be read (R) from or written to (W) in one cycle of the machine. (If you don’t see the main memory, try making the browser window larger.)
Mem[1]=42. That is, put the value 42 into memory location 1.Mem[1] as the RW location.Mem[1]=43 and click Execute again.How can we write data to memory? By closing the connection from the C bus to the main memory bus, as follows:
R0=8 and R1=9.R0+R1.Thought question: Suppose we wish to subtract Mem[6] from Mem[7] and store the result in Mem[8]. That is,
Mem[8] = Mem[7] - Mem[6]
How many cycles would this take?
In this section, we add a virtual control unit to set the knobs and switches according to a stored program.
Open the K&S Simulator with Microprogramming. This simulation adds a Microprogram Memory, which contains binary numbers representing the positions of the knobs and switches.
xs disappear and binary numbers appear. Verify that they correspond to the default settings of the knobs and switches, as well as the memory RW address.Mem[7]=42, then configure the datapath and memory to load this value into R0: R0=Mem[7]. Click the first green arrow and notice how the binary values change.Mem[8]. Click the second green arrow to add this as the second instruction.Mem[6] from Mem[7] and store the result in Mem[8]. You can type directly in the microprogram memory, if you prefer.In this section, we add the ability to store machine language instructions in memory.
Mem[0], type this assembly instruction: add r1 r2 r3. (That is, you literally type those ASCII assembly characters, not binary machine code or micro-instruction fields.)HALT instruction in Mem[1].Mem[6] from Mem[7] and store the result in Mem[8]. Be sure to end your program with a HALT instruction.Thought question: What do you think the following program will do?
0: SUB R0 R0 R0 ; Mem[0]
1: LOAD R1 5 ; Mem[1]
2: ADD R0 R0 R1 ; Mem[2]
3: BRANCH 2 ; Mem[3]
4: HALT ; Mem[4]
5: 1 ; Mem[5]Mem[5] should contain the value 1.Write a sequence of assembly instructions to multiply the value at memory address 11 by 4.
For example, if the contents of memory address 11 was the number 7, your instructions should store the number 28 there. While the ALU has no multiplication setting on its knob, multiplication can be accomplished via repeated addition: .
Type your program into the simulator and execute it to verify its correctness.
The K&S ISA supports the instruction BZERO MMMMM, which means, if the current ALU result is zero, set the program counter to the memory address MMMMM. Use this instruction to write a K&S program that uses a loop to multiply R0 and R1, placing the result in R2. Your program may change the value of R0 or R1 if necessary.
Notes:
HALT instruction at the end of your program.Copyright © 2018, 2019 Charlie Curtsinger and Jerod Weinman
This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.