Requesting assistance in understanding PLPTool's code architecture

54 views
Skip to first unread message

Cameron Bartee

unread,
Jun 4, 2015, 11:21:00 PM6/4/15
to progressive-le...@googlegroups.com

Hello, my name is Cameron Bartee, and I am one of the students working with Dr. Sohoni on PLP this summer.

 

I am on the team whose task is to create a plug-in for Eclipse that will allow users to write, run, and debug programs in PLP assembly language.  Essentially, the plug-in is intended to provide all the functionality that PLPTool offers, while simultaneously having the benefits of greater user familiarity (assuming many students who will be learning with PLP have previous experience using Eclipse) and accessibility for students with disabilities.  Furthermore, we may use the Eclipse plugin as a base onto which we will add even more new features.

 

As I understand it, this is going to involve taking the actual “engine” that runs the PLP assembly code from the existing PLPTool and somehow connecting it to Eclipse’s UI, thus allowing users to run and debug their PLP assembly programs from Eclipse’s workbench.  I say “engine,” but I am not actually sure what the term is I am looking for; I am referring to the part of PLPTool that simulates the PLP hardware and runs the PLP assembly code; separate and distinct (I assume) from PLPTool’s UI code.

 

So!  To anyone who is knowledgeable on the topic: could you please help me (and the rest of the team) begin to get an understanding of how PLPTool’s code is structured, which parts specifically are responsible for running the simulation of the PLP assembly code, and some understanding of how that code works?  I am currently accessing PLPTool’s code from this GitHub repository:

 

https://github.com/jabocg/progressive-learning-platform/tree/master/reference/sw/PLPTool

 

Please include any details that you think will be important; recall that our team’s task is taking the part of PLPTool responsible for simulating the execution of PLP assembly and “attaching” that to Eclipse’s UI such that assembly code execution and debugging are possible through Eclipse.

 

Any help you can provide is greatly appreciated!

Wira Mulia

unread,
Jun 23, 2015, 3:57:32 PM6/23/15
to progressive-le...@googlegroups.com

I am not familiar with Eclipse's workbench and its plugin API. I think you will need to look up how to tap into some of its workflow elements and callbacks framework.

Yes, the assembler and simulator are separate from the UI code. The pseudo-MIPS implementation is in the plptool.mips package. The classes here extend the framework in the root plptool package. If you are going to integrate the PLPTool assembler/simulator, you will only need the classes under plptool.mips.

plptool.mips.Asm is the PLP CPU assembler. It expects either a source string (and an identifier / path), or an ArrayList of PLPAsmSource objects. Then you can call the preprocess() and assemble() functions to assemble the source code and populate the rest of the data structure (symbol table, object code, etc.). If assembly is successful, then you can pass this Asm instance to a SimCore instance to be simulated.

An alternate method of integrating PLPTool would be to use the ProjectDriver class. This class provides a more project-oriented model (create new project, add new source files, etc.). It's probably easier to hook up Eclipse's framework to this as this class also does a bit of prep work, but it's not strictly necessary.

We can do a Google Hangout so I can walk through the code with you.

--
You received this message because you are subscribed to the Google Groups "progressive-learning-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to progressive-learning...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cameron Bartee

unread,
Jun 23, 2015, 8:42:32 PM6/23/15
to progressive-le...@googlegroups.com

Ah, hello! Thank you for the reply! Nice to be in contact with you, Mr. Mulia! :)

I actually have done quite a bit of poking around in the code since I first made this post, and I have discovered much about the classes you mention in your post.

I experimented with ProjectDriver and discovered how to load and save assembly files and projects and how to run the simulation from this class.  This class is being considered for use as the base of our PLP Eclipse plugin, but several factors may make it more desirable to use the plptool.mips classes directly.

As for the Asm and SimCore classes, I managed to figure out how to get them to run by experimenting with the code.  Here is the test class I used to get it working (I am unsure of how to properly post code on Google Groups, and so I apologize if the formatting is messed up.  If it is, I'll do a follow-up post where I will attempt to fix the formatting.  Also, I'll attach a .java file to this post containing this code, plus additional comments):

package testclasses;


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;


import plptool.PLPAsmSource;
import plptool.mips.Asm;
import plptool.mips.SimCore;
import plptool.mods.MemModule;
import plptool.dmf.CallbackRegistry;


public class TestSimCore2 {


 
 
public static void main(String[] args) {


 
if(!CallbackRegistry.INITIALIZED)
 
CallbackRegistry.setup(null);


 
ArrayList<PLPAsmSource> asms = getAsms();
 
Asm a = new Asm(asms);
 a
.preprocess(0);
 a
.assemble();
 
SimCore s = new SimCore(a, a.getAddrTable()[0]);
 s
.bus.add(new MemModule(a.getAddrTable()[0], 2048, true));
 s
.bus.enableAllModules();
 s
.reset();
 
 
/* Next, we actually run the program, and then print out the
 * contents of the registers and then a memory location.
 */

 
 
//Step through the code:
 
for(int i = 0; i < 50; i++)
 s
.stepW();
 
 
//Print out the contents of all the registers:
 
for(int i = 0; i < 32; i++)
 
System.out.println(s.regfile.read(i));
 
 
//Print out a memory location:
 
System.out.println("Here's the contents of memory:");
 
System.out.println(s.bus.read(0x10000100));
 
 
}
 
 
public static ArrayList<PLPAsmSource> getAsms(){
 
 
ArrayList<PLPAsmSource> asms = new ArrayList<PLPAsmSource>();
 
PLPAsmSource asm = null;
 
File asmDir = new File("PLP\\asmFiles");
 
File[] asmFiles = asmDir.listFiles();
 
BufferedReader in = null;
 
 
for(int i = 0; i < asmFiles.length; i++){
 
try {
//--------------VVV  This is the bit where we read in the files  VVV
 
in = new BufferedReader(new FileReader(asmFiles[i]));
 
int c;
 
StringBuilder s = new StringBuilder();
 
while((c = in.read()) != -1)
 s
.append((char)c);
 
asm = new PLPAsmSource(s.toString(), asmFiles[i].getName(), i);
 asms
.add(asm);
//--------------^^^  This is the bit where we read in the files ^^^
 
//Bunches of error handling below here:
 
} catch (FileNotFoundException e) {
 
System.out.println("Whoops! File not found.");
 e
.printStackTrace();
 
} catch (IOException e) {
 
System.out.println("Whoops! IOException.");
 e
.printStackTrace();
 
} finally {
 
try {
 
in.close();
 
} catch (IOException e) {
 
System.out.println("Whoops! IOException.");
 e
.printStackTrace();
 
}
 
}
 
}


 
//Finally, we can return our result!
 
return asms;
 
}


}

Again, in the attached file you can find this same code with more comments. If you happen to notice anything I'm doing wrong in the code there, or if there is some better way to do something, let me know!

Thank you very much for your offer to walk through the code with me!  However, at the moment I don't believe it is necessary - given the progress I've made in understanding how to use the PLPTool code, currently the main problem I am facing involves setting up functionality within the Eclipse plugin to launch the PLP simulation.  But, I may run into problems understanding the PLPTool code in the future, and should that situation arise, I would be grateful if you would provide your assistance.
To unsubscribe from this group and stop receiving emails from it, send an email to progressive-learning-platform+unsub...@googlegroups.com.
TestSimCore2.java
Reply all
Reply to author
Forward
0 new messages