1 /* $Id: CbeConstantVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.cbe;
4 import java.io.FileOutputStream;
5 import java.io.OutputStream;
6 import java.util.HashMap;
8 import dol.datamodel.pn.Channel;
9 import dol.datamodel.pn.Port;
10 import dol.datamodel.pn.Process;
11 import dol.datamodel.pn.ProcessNetwork;
12 import dol.main.UserInterface;
13 import dol.util.CodePrintStream;
14 import dol.visitor.PNVisitor;
17 * This class is a class for a constant file
19 * @author lschor, 2008-11-08
24 public class CbeConstantVisitor extends PNVisitor {
29 * @param dir path of this file
31 public CbeConstantVisitor(String dir, HashMap<Port, Integer> portMap) {
37 * Visit process network.
39 * @param x process network that needs to be rendered
41 public void visitComponent(ProcessNetwork x) {
43 _ui = UserInterface.getInstance();
44 String filename = _dir + _delimiter + "lib" + _delimiter
46 OutputStream file = new FileOutputStream(filename);
47 _mainPS = new CodePrintStream(file);
51 for (Process p : x.getProcessList())
53 if (p.getNumOfInports() > 0 && p.getNumOfOutports() > 0)
57 //create header section
58 _mainPS.println("// ========================");
59 _mainPS.println("// constant.c file");
60 _mainPS.println("// ========================");
63 _mainPS.println("#include <stdio.h>");
65 //define the number of FIFO queues and the number of processes
66 _mainPS.println("#ifndef _CONSTANT_H_");
67 _mainPS.println("#define _CONSTANT_H_");
69 _mainPS.println("#define NUM_PROCS "
70 + x.getProcessList().size());
71 _mainPS.println("#define NUM_SPES " + numSpes);
72 _mainPS.println("#define NUM_FIFO "
73 + x.getChannelList().size());
75 _mainPS.println("#endif // _CONSTANT_H_ ");
79 System.out.println("CbeModuleVisitor: exception occured: "
87 * @param x process that needs to be processed
89 public void visitComponent(Process x) {
94 * @param x channel that needs to be processed
96 public void visitComponent(Channel x) {
99 protected CodePrintStream _mainPS = null;
100 protected String _dir = null;
101 protected HashMap<Port, Integer> _portMap;