X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2FCellConstantVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2FCellConstantVisitor.java;h=ce7e2a131a07318aeeefe3b8acf1f195ad2548c3;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cell/CellConstantVisitor.java b/dol/src/dol/visitor/cell/CellConstantVisitor.java new file mode 100644 index 0000000..ce7e2a1 --- /dev/null +++ b/dol/src/dol/visitor/cell/CellConstantVisitor.java @@ -0,0 +1,128 @@ +package dol.visitor.cell; + +import java.io.FileOutputStream; +import java.io.OutputStream; + +import dol.datamodel.pn.Channel; +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.visitor.PNVisitor; +import dol.main.UserInterface; +import dol.util.CodePrintStream; + +/** + * This class is a class for a constant file + * + * @author lschor, 2008-11-08 + * + * Revision: + * 2008-11-08: Created + */ +public class CellConstantVisitor extends PNVisitor { + + /** + * Constructor. + * + * @param dir path of this file + */ + public CellConstantVisitor(String dir, CellMapping mapping) { + _dir = dir; + _mapping = mapping; + } + + /** + * Visit process network. + * + * @param x process network that needs to be rendered + */ + public void visitComponent(ProcessNetwork x) { + try { + _ui = UserInterface.getInstance(); + String filename = _dir + _delimiter + "lib" + _delimiter + "constant.h"; + OutputStream file = new FileOutputStream(filename); + _mainPS = new CodePrintStream(file); + + int numSpes = 0; + + for (Process p : x.getProcessList()) { + if (p.getNumOfInports() > 0 && p.getNumOfOutports() > 0) + numSpes++; + } + + //create header section + _mainPS.println("// ========================"); + _mainPS.println("// constant.h file"); + _mainPS.println("// ========================"); + + // Includes + _mainPS.println("#include "); + + // Define the number of FIFO queues and the number of processes + _mainPS.println("#ifndef _CONSTANT_H_"); + _mainPS.println("#define _CONSTANT_H_"); + _mainPS.println(""); + _mainPS.println("#define NUM_PROCS " + x.getProcessList().size() + + " // total number of processes"); + _mainPS.println("#define NUM_PROCS_SPU " + _mapping.getNrSPUProcess() + + " // number of processes to map on the SPU"); + _mainPS.println("#define NUM_PROCS_PPU " + _mapping.getNrPPUProcess() + + " // number of processes to map to the PPU"); + _mainPS.println("#define NUM_SPES " + _mapping.getNrSPE() + + " // number of SPE's to be used (PS3 = 6)"); + _mainPS.println("#define NUM_FIFO " + x.getChannelList().size() + + " // number of FIFOs we use"); + _mainPS.println("#define FIFO_SIZE_FACTOR 10 " + + " // factor to increase the IN-Channels of the PPE"); + _mainPS.println("#define ALIGNMENT_FACTOR 7 " + + " // alignment factor for the DMA transfers (at least 4, " + + "7 for optimal performance)"); + _mainPS.println("#define ALIGNMENT_FACTOR_POWER2 128"); + _mainPS.println("#define BLOCKED_MAX_NR 5 " + + " // number of times a process should wait until " + + "resending a request"); + _mainPS.println("#define STORE_REQUESTS " + + " // defines if one would like to store requests which" + + "cannot be worked out currently (see also FastCommunication.cpp)"); + _mainPS.println(""); + _mainPS.print("static unsigned long int FIFO_SIZE[NUM_FIFO] = {"); + for (int indx = 0; indx < x.getChannelList().size(); indx++) { + int size = x.getChannelList().elementAt(indx).getSize(); + if (x.getChannelList().elementAt(indx).getTokenSize() != 0) { + size *= x.getChannelList().elementAt(indx).getTokenSize(); + } + if(indx == x.getChannelList().size() - 1) { + _mainPS.print(size); + } else { + _mainPS.print(size + ", "); + } + } + + _mainPS.println("}; // Size of the FIFOs"); + _mainPS.println(""); + _mainPS.println("#endif // _CONSTANT_H_ "); + } + catch (Exception e) { + System.out.println("CellModuleVisitor: exception occured: " + + e.getMessage()); + e.printStackTrace(); + } + } + + /** + * + * @param x process that needs to be processed + */ + public void visitComponent(Process x) { + } + + /** + * + * @param x channel that needs to be processed + */ + public void visitComponent(Channel x) { + } + + protected CellMapping _mapping; + protected CodePrintStream _mainPS = null; + protected String _dir = null; +}