Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / dev / ram / src / SS_Memory.py
CommitLineData
920dae64
AT
1# ========== Copyright Header Begin ==========================================
2#
3# OpenSPARC T2 Processor File: SS_Memory.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
22import os
23import Pfe_Memory
24
25class Memory(Pfe_Memory.Memory):
26 def __init__(self,memory):
27 Pfe_Memory.Memory.__init__(self)
28 self.__memory__ = memory
29
30 def load(self,filename,addr=None):
31 os.stat(filename) # Test for excisting filename
32 if addr == None:
33 self.__memory__.load(filename)
34 else:
35 self.__memory__.load(filename,addr)
36
37 def save(self,filename,addr,size):
38 self.__memory__.save(filename,addr,size)
39
40
41 def __ldb__(self,addr): return self.__memory__.peek8u (addr)
42 def __ldh__(self,addr): return self.__memory__.peek16u(addr &~ 1)
43 def __ldw__(self,addr): return self.__memory__.peek32u(addr &~ 3)
44 def __ldx__(self,addr): return self.__memory__.peek64 (addr &~ 7)
45
46 def __stb__(self,addr,data): self.__memory__.poke8 (addr,data)
47 def __sth__(self,addr,data): self.__memory__.poke16(addr &~ 1,data)
48 def __stw__(self,addr,data): self.__memory__.poke32(addr &~ 3,long(data))
49 def __stx__(self,addr,data): self.__memory__.poke64(addr &~ 7,data)
50
51
52
53
54
55
56
57