dol: initial dol commit
[jump.git] / dol / src / dol / helper / profiler / PortProfile.java
diff --git a/dol/src/dol/helper/profiler/PortProfile.java b/dol/src/dol/helper/profiler/PortProfile.java
new file mode 100644 (file)
index 0000000..cd040ab
--- /dev/null
@@ -0,0 +1,95 @@
+/* $Id: PortProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */\r
+package dol.helper.profiler;\r
+\r
+/**\r
+ * Functional simulation profile information for a port.\r
+ */\r
+public class PortProfile {\r
+\r
+    /**\r
+     * Constructor.\r
+     *\r
+     * @param name name of the port this profile belongs to\r
+     */\r
+    public PortProfile(String name, ProcessProfile processProfile) {\r
+        _name = name;\r
+        _processProfile = processProfile;\r
+        _accesses = new Range();\r
+        _tokenSize = new Range();\r
+        _currentTokenSize = new Range();\r
+    }\r
+\r
+    /**\r
+     * Return the name of the channel this profile belongs to.\r
+     *\r
+     * @return name of the channel this profile belongs to\r
+     */\r
+    public String getName() {\r
+        return _name;\r
+    }\r
+\r
+    /**\r
+     * Add a read or write access to this port.\r
+     *\r
+     * @param tokenSize number of bytes communicated in this access\r
+     */\r
+    public void addAccess(int tokenSize) {\r
+        _currentAccesses++;\r
+        _currentTokenSize.merge(tokenSize);\r
+    }\r
+\r
+    /**\r
+     * Add an initial read or write access to this port (access happened\r
+     * during init() phase).\r
+     *\r
+     * @param tokenSize number of bytes communicated in this access\r
+     */\r
+    public void addInitialAccess(int tokenSize) {\r
+        _initialAccesses++;\r
+        if (_initialTokenSize == null) {\r
+            _initialTokenSize = new Range(tokenSize);\r
+        } else {\r
+            _initialTokenSize.merge(tokenSize);\r
+        }\r
+    }\r
+\r
+    /**\r
+     *\r
+     */\r
+    public void update() {\r
+        _accesses.merge(_currentAccesses);\r
+        _tokenSize.merge(_currentTokenSize);\r
+\r
+        _currentAccesses = 0;\r
+        _currentTokenSize.reset();\r
+    }\r
+\r
+    public int getInitialAccesses() {\r
+        return _initialAccesses;\r
+    }\r
+\r
+    public Range getInitialTokenSize() {\r
+        if (_initialTokenSize == null) {\r
+            return new Range(0);\r
+        } else {\r
+            return _initialTokenSize;\r
+        }\r
+    }\r
+\r
+    public Range getAccesses() {\r
+        return _accesses;\r
+    }\r
+\r
+    public Range getTokenSize() {\r
+        return _tokenSize;\r
+    }\r
+\r
+    String _name;\r
+    Range _accesses;\r
+    Range _tokenSize;\r
+    int _currentAccesses;\r
+    Range _currentTokenSize;\r
+    int _initialAccesses;\r
+    Range _initialTokenSize = null;\r
+    ProcessProfile _processProfile;\r
+}\r