Looking at CPUSim
1/3/2005
Over the weekend, I have been looking at CPUSim. I need to look at that some more and get a target machine set up for my use. I see that you can include source files for assembly in another source file, and that may be enough. What I am thinking of is writing a memory management unit. I'll have to have that for object allocation.
It would be nice if I had a way that they could submit a jar file containing their work to me and I could link it with mine and test it. This might work after we get to chapter 4. I would need some kind or servlet or CGI interface to let them attach a file to a form and send it.
I think that I need to finish the study of CPU Sim and get the target machine set up before I can go any further. I could also compile chapter 8.
I need to try firing up CPUSim and seeing what the machines look like. To run it, it seems that all that I have to do is run (double click on) the batch file D:\uofm\c4041s2005\CPUSim3.1.17\Cpusim.bat.
Running CPUSim
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\xalan.jar
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\jhall.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\crimson.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\CPUSimHelp3.3.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\acm.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\CPUSim4.0.2.jar;%CLASSPATH%
java cpusim.Main
Analysis of the CPUSim machine structure
Here is an analysis of the CPUSim machine structure.
Analysis of the Wombat machines
See the analysis of Dale Skrien's Wombat machines.
I may need to create my own version of one of these machines to make the addressing capable of handling large enough areas of RAM. I do need to recall that some of the addressing will be relative to locations on the stack. I may need to add instructions to access off the frame pointer.
Instruction design
Memory requirements
See a table of the number of bytes or registers that can be addressed by a register or field of a given width.
I want enough memory available so that I can compile reasonable programs. If I use two byte instructions, or 16 bits, I have very little to work with. So I'm inclined to start with three byte instructions and try it from there. If I don't need the full 8 bits of the first instruction for the opcode and other operands, it won't hurt to have extra bits for the address.
I also have to remember that if I use multiple bytes for a value, as Java uses four bytes per slot, then I have to keep my word size in mind as I calculate addresses. This also cuts down the number of values that I can have. I could represent ints as 4 bytes and booleans as 4 bytes. If I do something different, then I probably have to include more instructions in the machine.
I also have to remember that I must leave enough bits in the instruction to address the registers in register arrays that I use.
Work on Wombat4w
This page describes my Wombat4w design.
Work on Wombat5w
This page describes my Wombat5w design.
New CPUSim analysis
2/2/2007
There is CPUSim material in both E:\CPUSim4.0.2, mainly docs, and E:\c4041s2007\cpusim4.0.2, mainly jars.
Files in E:\c4041s2007\cpusim4.0.2
acm.jar looks like a drawing package.
CPUSim3.1InstrManualfolder.zip Has the various wombat machines.
CPUSim4.0.2.jar is the main jar, containing a cpusim.Main class.
CPUSim4.02.zip contains the material that is expanded in E:\CPUSim4.0.2.
CPUSimHelp3.3.jar is a bunch of HTML files, not classes.
crimson.jar An XML package
file(2).txt Dale Skrien's letter explaining the changes in CPUSim
jhall.jar Some kind of help mechanism
xalan.jar XSL and XML processing
So I guess I need all of these in a class path.
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\xalan.jar
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\jhall.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\crimson.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\CPUSimHelp3.3.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\acm.jar;%CLASSPATH%
set CLASSPATH=E:\c4041s2007\cpusim4.0.2\CPUSim4.0.2.jar;%CLASSPATH%
java cpusim.Main
I tried it, and it popped up a large, empty window with some menus.
It gave an error creating the help window. No further specifics.
Maybe it needs the help jar file in the class path. I'll try it again.
I still got an error.
4:55 Well, I don't understand the problem with the help.
4:59 I added the CPUSimHelp3.3.jar to the class path, and now the help works.
Well, it opened my machine, and it seems that it "works" so far. But now comes the hard part. I have to analyze the machines in great detail.
New instructions in Wombat4w
load_h (13) A1 A2 const ; 13 bit const: +-4096
Heap[A[op2]+op3]->A[op1]
store_h (14) A1 A2 const ; 13 bit const: +-4096
A[op1]->Heap[A[op2]+op3]
The idea is that A1 holds whatever we want to load or store, A2 holds the base address of the object on the heap, and the const (op3) is the fixed offset from the base address.
Wombat4w may be enough to compile to.
Differences between Wombat4 and Wombat4w
Hardware
The register sizes were increased.
Microinstructions
Arithmetic
Added mar+buf1->mar.
Several differences, added top->mar.
Some differences, none added.
Some differences, added A[ir(8-10)]->buf1.
Memory Access
Added Heap[mar]->mdr and mdr->Heap[mar].
EQUs
Fetch Sequence
Increment the pc by 3 instead of 2.
Machine instructions
Needs analysis.
Added registers A4 through A7.
Differences between Wombat4w and Wombat5w
Hardware
Registers
Wombat5w drops the top register and adds abuffer1 and nextHeap, both of 16 bits. This looks somewhat inconsistent since nextHeap will refer to the heap as top did to the stack.
Microinstructions
Set
It adds clear-buf2.
Increment
It replaces Inc4-top and dec4-top by Inc4-A[7] and dec4-A[7].
Shift
It adds buf1 RSA 16 and buf2 RSA 18.
Arithmetic
It drops top+mar->top and top-mar->top and adds A[7]+mar->A[7], A[7]-mar->A[7], and abuf1+buf2->abuf1.
It drops top->mar and adds abuf1->nextHeap, buffer1(16-31)->mar, ir(10-23)->buffer2(0-13), ir(8-23)->buf1(0-15), and nextHeap->buf2(16-31).
It adds buf1->A[ir(7-9)] and buf2->A[ir(21-23)].
It adds A[ir(7-9)](16-31)->abuf1 and A[ir(7-9)]->buf1.
Memory Access
Replaces top->mdr by A[7]->mdr and mdr->Stack[top] by mdr->Stack[A[7]]. Adds Stack[mar]->mdr and >mdr->Stack[mar].
Machine Instructions
Needs analysis.
Comments (0)
You don't have permission to comment on this page.