X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fdatamodel%2Farchitecture%2FArchitecture.java;fp=dol%2Fsrc%2Fdol%2Fdatamodel%2Farchitecture%2FArchitecture.java;h=06d510d12d76e61e94a2f0b3f49f23ed95c69168;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/datamodel/architecture/Architecture.java b/dol/src/dol/datamodel/architecture/Architecture.java new file mode 100644 index 0000000..06d510d --- /dev/null +++ b/dol/src/dol/datamodel/architecture/Architecture.java @@ -0,0 +1,400 @@ +/* $Id: Architecture.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.datamodel.architecture; + +import java.util.Hashtable; +import java.util.Vector; + +import dol.visitor.ArchiVisitor; + + +/** + * This class defines an architecture. + */ +public class Architecture extends ArchiResource { + /** + * Constructor to create an architecture with a name, + * empty processor list, empty memory list, empty hwChannel list and empty connection list. + */ + public Architecture(String name) { + super(name); + _processorList = new Vector(); + _memoryList = new Vector(); + _hwChannelList = new Vector(); + _varList = new Vector(); + _connectionList = new Vector(); + _readPathList = new Vector(); + _writePathList = new Vector(); + _pathList = new Vector(); + _processorPathList = new Hashtable>>(); + + } + + /** + * Accept a visitor + * + * @param x visitor object + */ + public void accept(ArchiVisitor x) { + x.visitComponent(this); + } + + /** + * Clone this Architecture. + * + * @return new instance of the Architecure + */ + /* + @SuppressWarnings("unchecked") + public Object clone() { + Architecture newObj = (Architecture) super.clone(); + newObj.setProcessorList((Vector)_processorList.clone()); + newObj.setMemoryList((Vector)_memoryList.clone()); + newObj.setHWChannelList((Vector)_hwChannelList.clone()); + newObj.setVarList((Vector)_varList.clone()); + newObj.setConnectionList((Vector)_connectionList.clone()); + newObj.setReadPathList((Vector)_readPathList.clone()); + newObj.setWritePathList((Vector)_writePathList.clone()); + newObj.setPathList((Vector>)_pathList.clone()); + return newObj; + } + */ + + + /** + * Get the processor list of a Architecture. + * + * @return the processor list + */ + public Vector getProcessorList() { + return _processorList; + } + + /** + * Get the memory list of a Architecture. + * + * @return the memory list + */ + public Vector getMemoryList() { + return _memoryList; + } + + /** + * Get the hwChannel list of a Architecture. + * + * @return the hwChannel list + */ + public Vector getHWChannelList() { + return _hwChannelList; + } + + /** + * Get the paths list of a Architecture. + * + * @return the paths list + */ + public Vector getReadPathList() { + return _readPathList; + } + + /** + * Get the write paths list of a Architecture. + * + * @return the paths list + */ + public Vector getWritePathList( ) { + return _writePathList; + } + + /** + * Set the processor paths list of a Architecture. + * + * @param pathList The new list + */ + public void setPathList(Vector pathList) { + _pathList = pathList; + } + + /** + * Get the processor paths list of a Architecture. + * + * @return the processor paths list + */ + public Vector getPathList() { + return _pathList; + } + + /** + * Return a processor/memory/hwChannel which has a specific name. Return null if + * processor cannot be found. + * + * @param name the name of the processor/memory/hwChannel to search for. + * @return the processor/memory/hwChannel with the specific name. + */ + public Processor getProcessor(String name) { + for (Processor processor : _processorList) { + if (processor.getName().equals(name)) { + return processor; + } + } + return null; + } + + /** + * + */ + public Memory getMemory(String name) { + for (Memory memory : _memoryList) { + if (memory.getName().equals(name)) { + return memory; + } + } + return null; + } + + /** + * + */ + public HWChannel getHWChannel(String name) { + for (HWChannel hwChannel : _hwChannelList) { + if (hwChannel.getName().equals(name)) { + return hwChannel; + } + } + return null; + } + + + /** + * Return a read path which has a specific name. Return null if + * not found. + * + * @param name the name of the read path to search for. + * @return the read path with the specific name. + */ + public ReadPath getReadPath(String name) { + for (ReadPath p : _readPathList) { + if (p.getName().equals(name)) { + return p; + } + } + return null; + } + + /** + * Return a write path which has a specific name. Return null if + * not found. + * + * @param name the name of the write path to search for. + * @return the write path with the specific name. + */ + public WritePath getWritePath(String name) { + for (WritePath p : _writePathList) { + if (p.getName().equals(name)) { + return p; + } + } + return null; + } + + public Vector getVarList() { return _varList; } + + public Vector getConnectionList() { + return _connectionList; + } + + /** + * Compute all paths between processors. + */ + public void computePaths() { + for (WritePath w : _writePathList) { + String channelBuffer = w.getCHBuf().getName(); + for (ReadPath r : _readPathList) { + if (r.getCHBuf().getName().equals(channelBuffer)) { + Path path = new Path(); + path.setWritePath(w); + path.setReadPath(r); + _pathList.add(path); + } + } + } + + /* + //print all paths in this architecture + for (int j = 0; j < _pathList.size(); j++) { + Vector path = _pathList.elementAt(j).getPath(); + for (int k = 0; k < path.size(); k++) { + System.out.print(path.elementAt(k). + getName() + (k < path.size() - 1 ? " -> " : "")); + } + System.out.println(); + } + System.out.println("Found " + _pathList.size() + " paths."); + */ + + computeProcessorPath(); + } + + /** + * Compute all write path from one processor to another processor + * in this architecture. + */ + protected void computeProcessorPath() { + //iterate over all path in this architecture + for (int j = 0; j < _pathList.size(); j++) { + Processor startProcessor = _pathList.elementAt(j).getStartProcessor(); + Processor targetProcessor = _pathList.elementAt(j).getTargetProcessor(); + + //create new hashtable entry for this start processor + if (!_processorPathList.containsKey(startProcessor)) { + Hashtable> + processorPathList = new Hashtable>(); + _processorPathList.put(startProcessor, processorPathList); + } + + Hashtable> + processorPathList = _processorPathList. + get(startProcessor); + + //create new path list for this target processor + if(!processorPathList.containsKey(targetProcessor)) { + Vector processorPath = new Vector(); + processorPathList.put(targetProcessor, processorPath); + } + + Vector processorPath = + processorPathList.get(targetProcessor); + + //add this path to the list of paths + processorPath.add(_pathList.elementAt(j)); + } + + /* + //print all processor to processor path + int pathCounter = 0; + for (int j = 0; j < _processorList.size(); j++) { + for (int k = 0; k < _processorList.size(); k++) { + Vector processorPathList = + getPaths(_processorList.elementAt(j), + _processorList.elementAt(k)); + for (int l = 0; l < processorPathList.size(); l++) { + pathCounter++; + Vector path = processorPathList. + elementAt(l).getPath(); + for (int m = 0; m < path.size(); m++) { + System.out.print(path.elementAt(m).getName() + + (m < path.size() - 1 ? " -> " : "")); + } + System.out.println(); + } + } + } + System.out.println("Found " + pathCounter + " paths."); + */ + } + + /** + * Get all write paths from the given start processor to the given + * target processor. + * + * @param startProcessor processor where write path begins + * @param targetProcessor processor where write path ends + * @return vector of all write paths between startProcessor and + * targetProcessor + */ + public Vector getPaths( + Processor startProcessor, Processor targetProcessor) { + if (_processorPathList.get(startProcessor) == null) { + return null; + } + return _processorPathList.get(startProcessor).get(targetProcessor); + } + + /** + * Register the RX/TX/CH buffer to each resource. + * Can be used for dotty generation. + */ + public void registerRWPath2Resource() + { + for (ReadPath r : _readPathList) { + // register rxbuf + String memName = r.getRXBuf().getName(); + for (Memory m : _memoryList) { + if (m.getName().equals(memName)) { + m.getRXBufList().add(r.getName()); + } + } + + // register chbuf + memName = r.getCHBuf().getName(); + for (Memory m : _memoryList) { + if (m.getName().equals(memName)) { + m.getCHBufList().add(r.getName() + "_RPath"); + } + } + + // register pathes via a communication resource + for (HWChannel c : r.getHWChannelList()) { + if (c.getName().equals(r.getName())) { + // premise: a path cannot go via a bus twice. + c.getPathList().add(r.getName() + "_RPath"); + } + } + } + + for (WritePath w : _writePathList) { + // register txbuf + String memName = w.getTXBuf().getName(); + for (Memory m : _memoryList) { + if (m.getName().equals(memName)) { + m.getTXBufList().add(w.getName()); + } + } + + // register chbuf + memName = w.getCHBuf().getName(); + for (Memory m : _memoryList) { + if (m.getName().equals(memName)) { + m.getCHBufList().add(w.getName() + "_WPath"); + } + } + + // register pathes via a communication resource + for (HWChannel c : w.getHWChannelList()) { + if (c.getName().equals(w.getName())) { + // premise: a path cannot go via a bus twice. + c.getPathList().add(w.getName() + "_WPath"); + } + } + } + } + + /** List of the processors in the Architecture */ + protected Vector _processorList = null; + + /** List of the memories in the Architecture */ + protected Vector _memoryList = null; + + /** List of hwChannels in the Architecture */ + protected Vector _hwChannelList = null; + + /** List of variables in the Architecture */ + protected Vector _varList = null; + + /** List of connections in the Architecture: for simplified arch*/ + protected Vector _connectionList = null; + + /** List of read paths in the Architecture: for detail arch */ + protected Vector _readPathList = null; + + /** List of write paths in the Architecture: for detail arch */ + protected Vector _writePathList = null; + + /** List of paths in the Architecture */ + protected Vector _pathList = null; + + /** hashtable to access all processor to processor path */ + protected Hashtable>> _processorPathList = null; +}