CORC 1312
Lab #9: Inside the Computer


This lab is based on the material in Chapter 10 of the Pearson book and the CPU simulators.
  1. First look at the simple CPU datapath simulator:

    This simulator models a simple CPU containing 4 registers. Using the simulator, you can follow the progress of data as it traverses the CPU datapath from the registers to the ALU and back to the registers. In this simple simulator, there is no Control Unit. Instead, the user acts as the Control Unit by clicking knobs to select the appropriate registers and functions.

  2. The simple CPU Datapath simulator describes the way in which a computer mainpulates data that is already stored in registers. However, it does not show how data gets into the registers in the first place, or how the results of an arithmetic operation get out of the CPU. The Datapath with Memory simulator incorporates memory into the simulator:


    Example:
    1. Enter two numbers into memory , by typing values into slots 0 and 1 of memory.
    2. Copy one data value into R0, by clicking on the R/W button next to memory slot 0. (R/W indicates that this is the memory cell that will be read from or written into.) Also click on the arrows surrounding the main memory bus so that they connect main memory to the registers, by connecting main memory to the C Bus and configuring the C Bus address to go to R0.
      Execute this step.
    3. Copy the second value into a register: Click on the R/W button next to memory cell 1. Set the C Bus know to R1.
      Execute. (This will copy the value from memory cell 1 into R1).
    4. Configure the A Bus knob to R0, the B Bus knob to R1, the ALU operation to A+B. Click on the R/W know next to memory cell 2. Set the switches on the main memory bus so that the result from the C Bus goes back to main memory.
      Execute.
      NOTE: Did you notice that it takes more time to transfer data between main memory and the CPU than it does to perform a CPU datapath cycle?

  3. In the previous examples, the user had to control the flow of information by clicking knobs and switches. The key idea behind a stored program computer is that these kinds of tasks can be represented as instructions and stored in main memory along with the data. The control unit can fetch the instructions from main memory and carry out the tasks. The Stored Program Computer simulator can be used to simulate how a program is executed.

    Machine Language The simulator uses a simple machine language. Since each memory cell can contain 16 bits, each machine language instruction is 16 bits long. The first 9 or 10 bits are used to determine the type of operation being performed. The last 6 bits are used to specify register numbers or memory addresses. (2 bits are sufficient for register numbers, because there are only 4 registers. 5 bits are sufficient for addressing main memory, since there are only 32 memory cells.)

    Instructions: (See text in Chapter 10 for more detail)

    1010000100 RR RR RR	Add contents of last two registers, store result in the first listed
    1010001000 RR RR RR 	Subtract contents of third register from second, store result in first
    100000010 RR MMMMM	Load contents from memory into register specified
    100000100 RR MMMMM	Store results from register into memory
    100100010000 RR RR		Copy contents from second register into first
    1111111111111111		Halt the program
    

    Example: Load the following program into memory ( Click on the box to the left of the memory cell to change it from Auto to 2 to indicate that you are entering values in binary. :

    1000000100000101	(load memory location 5 into R0)
    1000000100100110	(load memory location 6 into R1)
    1010000100100001	(add R0 and R1, store result in R2)
    1000001001000111	(Store data from R2 into memory location 7)
    1111111111111111	(HALT)
    0000000000001001	(data: 9 in binary)
    0000000000000001   	(data: 1 in binary)
    
    Execute the simulator to see what happens. Note that you no longer have to set the knobs yourself.

    Assembler Language
    It is too difficult to write programs in binary! Assembler language allow us to use words instead of binary codes. For example, the instruction 1010000100000110 can be represented by ADD R0 R1 R2 The simulator allows you to enter instructions in assembly language. You can then view the instructions in either assembly language or in binary, by clicking on the arrow next to the View As box to the left of the instruction.

    Example: Load the following into memory and click on Execute:

    LOAD R0 5
    LOAD R1 6
    ADD R2 R0 R1
    STORE 7 R2
    HALT
    9
    1
    
    
    
More on: memory and into
Fastest SFTP, FTP and FTPS Client on the Planet, FREE GoFTP Client