CPSC 220, Fall 2018
Testing Larc-in-Logisim

For this week, you will continue working on Larc-in-Logisim, which you started last week. This web page has some information about testing your simulation when it is finished.

Testing

First of all, note that you can change the contents of an individual memory location in a Logisim ROM or RAM — just click on the contents of the memory location and start typing the new value. This means that you can set the PC to zero, enter one or two Larc instructions at the start of ROM, and turn the clock on and off by hand to execute one instruction. This lets you test your simulation on individual instructions. (Remember that you can open up the Register File circuit and view the numbers stored in the registers. And you can use the Poke Tool on wires to check the inputs and output of the ALU or any other circuit.)

For more complete testing, you will want to run some longer programs. The file /classes/cs220/Larc-in-Logisim/TEST-PROGRAMS contains some programs that you can use for testing. The programs are in the form of files that you can load into your simiulation's ROM, that is, into the instruction memory. The programs are in files named test1.ROM, test2.ROM, test3.ROM, and test4.ROM. For the fourth program, test4.ROM, you must also load the file test4.RAM into the data memory.

To load one of the programs into ROM, right-click the ROM and select the command "Load Image" from the pop-up menu. A file can be loaded into RAM in the same way.

The files with names like test1.RAM-AFTER-RUN contain a copy of the data memory after the program has run corectly. They are in the format that Logisim uses for image files. After running one of the programs, you can save the RAM to a file by right-clicking the RAM and selecting the "Save Image" command. You can also view the contents of RAM in a window by selecting the "Edit Contents" command.

The program in test1.ROM uses all of the arithmetic instructions, and it stores the results into memory. Some of the memory stores use SIMM offsets. This program does not use any jumps.

The program in test2.ROM simply counts down from 0xf to zero, storing the numbers in memory. Mostly, it is meant to test branch instructions.

The program in test3.ROM computes the 3N+1 sequence starting from 27 and stores the terms of the sequence in memory. The sequence has over 100 terms, so the program takes a little time to run. (The first instruction in the program, 811b, stores the starting point of the sequence in location 1. You can change the LIMM in this instruction to get a shorter sequence.) This program uses the jalr instruction.

The program in test4.ROM uses the QuickSort algorithm to sort a list of numbers in data memory. (Remember to load both data memory and instruction memory for this example.) You should only try this one when you are pretty sure that your simulation is working! It's meant as an example of a more realistic program. It's also the only test program that uses the lw instruction. Sorting the list takes quite a while to run at the default speed, so you probably want to change the Tick Frequency to something like 64 Hz. The second instuction in the program (in memory location 1) loads the end address of the list into register 3. To get a shorter program run, you can change that instruction to sort just part of the list. For example, change it to 8310 to sort just the first 16 items in the list.