dol: initial dol commit
[jump.git] / dol / src / dol / helper / profiler / PortProfile.java
1 /* $Id: PortProfile.java 203 2010-10-11 08:59:47Z dchokshi $ */\r
2 package dol.helper.profiler;\r
3 \r
4 /**\r
5  * Functional simulation profile information for a port.\r
6  */\r
7 public class PortProfile {\r
8 \r
9     /**\r
10      * Constructor.\r
11      *\r
12      * @param name name of the port this profile belongs to\r
13      */\r
14     public PortProfile(String name, ProcessProfile processProfile) {\r
15         _name = name;\r
16         _processProfile = processProfile;\r
17         _accesses = new Range();\r
18         _tokenSize = new Range();\r
19         _currentTokenSize = new Range();\r
20     }\r
21 \r
22     /**\r
23      * Return the name of the channel this profile belongs to.\r
24      *\r
25      * @return name of the channel this profile belongs to\r
26      */\r
27     public String getName() {\r
28         return _name;\r
29     }\r
30 \r
31     /**\r
32      * Add a read or write access to this port.\r
33      *\r
34      * @param tokenSize number of bytes communicated in this access\r
35      */\r
36     public void addAccess(int tokenSize) {\r
37         _currentAccesses++;\r
38         _currentTokenSize.merge(tokenSize);\r
39     }\r
40 \r
41     /**\r
42      * Add an initial read or write access to this port (access happened\r
43      * during init() phase).\r
44      *\r
45      * @param tokenSize number of bytes communicated in this access\r
46      */\r
47     public void addInitialAccess(int tokenSize) {\r
48         _initialAccesses++;\r
49         if (_initialTokenSize == null) {\r
50             _initialTokenSize = new Range(tokenSize);\r
51         } else {\r
52             _initialTokenSize.merge(tokenSize);\r
53         }\r
54     }\r
55 \r
56     /**\r
57      *\r
58      */\r
59     public void update() {\r
60         _accesses.merge(_currentAccesses);\r
61         _tokenSize.merge(_currentTokenSize);\r
62 \r
63         _currentAccesses = 0;\r
64         _currentTokenSize.reset();\r
65     }\r
66 \r
67     public int getInitialAccesses() {\r
68         return _initialAccesses;\r
69     }\r
70 \r
71     public Range getInitialTokenSize() {\r
72         if (_initialTokenSize == null) {\r
73             return new Range(0);\r
74         } else {\r
75             return _initialTokenSize;\r
76         }\r
77     }\r
78 \r
79     public Range getAccesses() {\r
80         return _accesses;\r
81     }\r
82 \r
83     public Range getTokenSize() {\r
84         return _tokenSize;\r
85     }\r
86 \r
87     String _name;\r
88     Range _accesses;\r
89     Range _tokenSize;\r
90     int _currentAccesses;\r
91     Range _currentTokenSize;\r
92     int _initialAccesses;\r
93     Range _initialTokenSize = null;\r
94     ProcessProfile _processProfile;\r
95 }\r