Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / verilog / niu / sparse_mem_model / pli / src / mempli.cc
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: mempli.cc
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35// Copyright 2001 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
36//
37// This software and any related documentation (the "Materials") are the
38// confidential proprietary information of AMD. Unless otherwise provided
39// in an agreement specifically licensing the Materials, the Materials are
40// provided in confidence and may not to be used, distributed, modified, or
41// reproduced in whole or in part by any means.
42//
43// LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY
44// EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO
45// WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY
46// PARTICULAR PURPOSE, OR WARRANTIES ARISING FORM CONDUCT, COURSE OF
47// DEALING, OR USAGE OF TRADE. IN NO EVENT SHALL AMD OR ITS LICENSORS BE
48// LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
49// DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF
50// INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE THE
51// MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
52// DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION OR
53// LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE
54// ABOVE LIMITATION MAY NOT APPLY TO YOU.
55//
56// AMD does not assume any responsibility for any errors which may appear
57// in the Materials nor any responsibility to support or update the
58// Materials. AMD retains the right to modify the Materials at any time,
59// without notice, and is not obligated to provide such modified Materials
60// to you.
61//
62// NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make
63// any further information, software, technical information, know-how, or
64// show-how available to you.
65//
66// U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
67// "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government
68// is subject to the restrictions as set forth in FAR 52.227-14 and DFAR
69// 252.227-7013, et seq., or its successor. Use of the Materials by the
70// Government constitutes acknowledgement of AMD's proprietary rights in
71// them.
72//
73////////////////////////////////////////////////////////////////////////////////
74
75#include <iostream>
76#include <fstream>
77#include <stdlib.h>
78#include <string.h>
79#include <ctype.h>
80#include <stdio.h>
81#include "ext_sys_mem.h"
82#include "vcsuser.h"
83
84// global variables
85SYS_MEM SystemMem;
86SYS_MEM SlaveMem;
87
88/*==========================================================================*/
89extern "C" int SysMem_SetRandom() {
90/*==========================================================================*/
91 SystemMem.SetDefaultMemRandom();
92 SlaveMem.SetDefaultMemRandom();
93return 0;
94}
95
96/*==========================================================================*/
97extern "C" int SysRead_Data() {
98/*==========================================================================*/
99
100 unsigned int addrh;
101 unsigned int addrl;
102 unsigned int tempData;
103 int iMemType;
104
105 iMemType = tf_getp(1);
106 addrh = tf_getp(2);
107 addrl = tf_getp(3);
108 addrl = addrl & (~0x3);
109
110 if (iMemType == 1) {
111 SystemMem.read(addrh,addrl,&tempData); // host
112 //io_printf(" System MEM read addr %08x data %08x\n",addrl,tempData);
113 } else {
114 SlaveMem.read(addrh,addrl,&tempData); // host
115 //io_printf(" Slave MEM read addr %08x data %08x\n",addrl,tempData);
116 }
117
118 tf_putp(4,tempData);
119 return 0;
120}
121
122/*==========================================================================*/
123extern "C" int SysWrite_Data() {
124/*==========================================================================*/
125
126 unsigned int addrh;
127 unsigned int addrl;
128 unsigned int be;
129 unsigned int data;
130 int iMemType;
131
132 iMemType = tf_getp(1);
133 addrh = tf_getp(2);
134 addrl = tf_getp(3);
135 data = tf_getp(4);
136 be = tf_getp(5);
137
138 addrl = addrl & (~0x3);
139 be = (~(be & 0x0f)) & 0x0f;
140
141 if (iMemType == 1) {
142 SystemMem.write(addrh,addrl,be,data);
143 //io_printf(" System MEM write addr %08x data %08x be %08x\n",addrl,data,be);
144 } else {
145 SlaveMem.write(addrh,addrl,be,data);
146 //io_printf(" Slave MEM write addr %08x data %08x be %08x\n",addrl,data,be);
147 }
148 return 0;
149}
150
151
152
153
154
155
156