X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcbe%2FCbeConstantVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcbe%2FCbeConstantVisitor.java;h=594673b4af971a99ac7f657dbc7ec6a575e7651c;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cbe/CbeConstantVisitor.java b/dol/src/dol/visitor/cbe/CbeConstantVisitor.java new file mode 100644 index 0000000..594673b --- /dev/null +++ b/dol/src/dol/visitor/cbe/CbeConstantVisitor.java @@ -0,0 +1,102 @@ +/* $Id: CbeConstantVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.cbe; + +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.util.HashMap; + +import dol.datamodel.pn.Channel; +import dol.datamodel.pn.Port; +import dol.datamodel.pn.Process; +import dol.datamodel.pn.ProcessNetwork; +import dol.main.UserInterface; +import dol.util.CodePrintStream; +import dol.visitor.PNVisitor; + +/** + * This class is a class for a constant file + * + * @author lschor, 2008-11-08 + * + * Revision: + * 2008-11-08: Created + */ +public class CbeConstantVisitor extends PNVisitor { + + /** + * Constructor. + * + * @param dir path of this file + */ + public CbeConstantVisitor(String dir, HashMap portMap) { + _dir = dir; + _portMap = portMap; + } + + /** + * 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.c 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()); + _mainPS.println("#define NUM_SPES " + numSpes); + _mainPS.println("#define NUM_FIFO " + + x.getChannelList().size()); + _mainPS.println(""); + _mainPS.println("#endif // _CONSTANT_H_ "); + _mainPS.println(""); + } + catch (Exception e) { + System.out.println("CbeModuleVisitor: 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 CodePrintStream _mainPS = null; + protected String _dir = null; + protected HashMap _portMap; +}