Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / samfe / src / Repository.py
CommitLineData
920dae64
AT
1# ========== Copyright Header Begin ==========================================
2#
3# OpenSPARC T2 Processor File: Repository.py
4# Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
5# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
6#
7# The above named program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public
9# License version 2 as published by the Free Software Foundation.
10#
11# The above named program is distributed in the hope that it will be
12# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public
17# License along with this work; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19#
20# ========== Copyright Header End ============================================
21"""repository for focus object, breakpoints, watchpoints, etc.
22"""
23
24# message header
25msghead = __name__
26msghead_dbx = "DBX-" + msghead
27
28
29# a global id counter to generate unique ids for watchpoints, breakpoints,
30# etc. Use Repository.nextid() to receive the next available id.
31__objectid = 0
32
33def nextid():
34 """function used to generate a unique id for watchpoints, breakpoints, etc.
35 """
36 global __objectid
37 __objectid += 1
38 return str(__objectid)
39
40
41class Repository:
42 """class that serves as repository for shared data
43 """
44
45 def __init__ (self):
46 """
47 globals - top level globals(), so that we can eval() expression in
48 other places as they are at top level.
49 """
50 self.console = None
51 self.topName = None
52 self.globals = None
53 self.riesling = None
54 self.fldTable = None
55 self.modTable = None
56 self.cmdTable = None
57 self.symTable = None
58 self.memLoad = None
59
60 #self.cycle = 0L
61 # the current focus module, in original string
62 self.focusSrc = None
63 # the corresponding riesling backend module
64 self.focus = None
65 self.groups = { }
66 self.breakpoints = { }
67 self.watchpoints = { }
68 self.cmdAlias = { }
69 # 1 means in rioesling interpreter mode, otherwise in normal python
70 # mode
71 self.imode = 0
72 # 1 means output message will be printed
73 self.echo = 1
74
75 # arch config
76 self.ncpus = 0
77 self.ncores = 0
78 self.nucores = 0
79 self.nstrands = 0
80 # pointer (as uint64_t) to backend system object
81 self.sysAddr = 0L
82 self.optdir = None
83 # fp values
84 self.nSpregs = 0
85 self.nDpregs = 0
86 self.nQpregs = 0
87 # array to cpu/core/strand objects
88 self.cpus = None
89 self.cores = None
90 self.ucores = None
91 self.strands = None
92 self.riesLib = None
93 self.socketAPI = None
94 self.prompt = 'NA'
95 # used in sam mode to indicate whether blaze is running or not,
96 # blaze must be in 'stop" mode when conduct breakpoint operaiton.
97 # this variable remains as 0 when not in sam mode.
98 self.running = 0
99 # keep track of blaze numcpu and corresponding pmask
100 self.blazeNumcpu = 1
101 self.pmask = 0x1L
102 # indicate the type of cpu architecture, e.g., n2, etc
103 self.arch = None
104
105
106 def addBreakpoint (self, breakpoint):
107 """
108 """
109 if self.breakpoints.has_key(breakpoint.id):
110 raise KeyError, "duplicated breakpoint id %d" % breakpoint.id
111
112 self.breakpoints[breakpoint.id] = breakpoint
113
114
115 def deleteBreakpoint (self, id):
116 """
117 """
118 idstr = str(id)
119 if self.breakpoints.has_key(idstr):
120 del self.breakpoints[idstr]
121 else:
122 raise KeyError, "does not have breakpoint with id=%s" % idstr
123
124
125 def showBreakpoint (self, focus=None):
126 """
127 """
128 ids = self.breakpoints.keys()
129 ids.sort()
130 result = [ ]
131 for id in ids:
132 bpoint = self.breakpoints[id]
133 if (focus == None) or (focus == bpoint.modSrc):
134 result.append("id=%s, mod=%s, cmd='%s', action=%s" % (bpoint.id, bpoint.modSrc, bpoint.src, bpoint.action))
135
136 return '\n'.join(result)
137
138
139 def addWatchpoint (self, watchpoint):
140 """
141 """
142 if self.watchpoints.has_key(watchpoint.id):
143 raise KeyError, "duplicated watchpoint id %d" % watchpoint.id
144
145 self.watchpoints[watchpoint.id] = watchpoint
146
147
148 def showWatchpoint (self):
149 """
150 """
151 ids = self.watchpoints.keys()
152 ids.sort()
153 result = [ ]
154 for id in ids:
155 wpoint = self.watchpoints[id]
156 result.append("id=%s, disable=%d, cmd='%s', watch='%s', action=%s" % (wpoint.id, wpoint.disable, wpoint.src, wpoint.watch, wpoint.action))
157 result.append("DBX: id=%s, watchExpr=%s" % (wpoint.id, wpoint.watchExpr)) #dbx
158 return '\n'.join(result)
159
160
161"""self-testing
162"""
163if __name__ == "__main__":
164 pass