CPSC 220, Fall 2022
Completing and 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.

Several Larc machine language test programs are available that can be loaded into your simulation. You can find them in the folder

/classes/cs220/Larc-in-Logisim/larc-tests

The ABOUT.txt file in that folder has information about the tests and instructions for using them. You can also download this zip archive that contains the test file directory.

Your group's completed simulation is due next Thursday. It should be in the directory assigned to your group in /classes/cs220/Larc-in-Logisim.

Testing

You can start testing your simulation as soon as you start wiring the major components together. For example, after connecting the output of the instruction ROM to an instruction-decoding circuit, you can store an instruction code in ROM and see whether the decoding circuit produces the outputs that you expect. As you build the circuitry for executing instructions, you can check that all the wires are carrying the values that you expect.

Remember 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 by double-clicking it with the Poke tool, so that you can 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 test files testall.ROM, test1.ROM, test2.ROM, test3.ROM, and test4.ROM are provided for that purpose in the directory mentioned above. Read more about the tests in ABOUT.txt.

You will want to make sure that your simulation works for the testall.ROM test, since that test will definitely be used for grading. That file contains machine language code in hexadecimal format. You should be able to figure out what each instruction means. The assembly language code for the program is in testall.s.

But you might want to start with the simpler tests in test1.ROM and test2.ROM. And I certainly hope that you will want to try your simulation on the more realistic programs in test3.ROM and test4.ROM!

The diff Command

After running one of the tests, you will want to make sure that the content of RAM is correct. You can save the data to a file and compare it with the "RAM-AFTER-RUN" file for that test. But it can be difficult to spot small difference in two files just by looking at them.

On Linux and MacOS, the diff command can be used to check two files for differences. (Windows is supposed to have a similar command called fc.) Note that if the files are identical, the diff command will give no output at all. You get output if the files are different. For text files, the output will show the differences. (Actually, the output shows what changes have to be made to the first file to transform it into an identical copy of the second.) For example to check whether the content of the files myOutput.txt and test4.RAM-AFTER-RUN are different, use the command

    diff  myOutput.txt  test4.RAM-AFTER-RUN