Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / fnx / vlib / FNXPCIEXactor / src / FNXPCIEXactorAssertCovDatabase.vr
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: FNXPCIEXactorAssertCovDatabase.vr
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#include "DenaliPCIE.vri"
36
37// FNXPCIEXactor library
38#include "FNXPCIEXactorDefines.vri"
39
40// report library
41#include "cReport.vrh"
42#include "FNXPCIEXactorReportMacros.vri"
43
44class FNXPCIEXactorAssertCovDatabase {
45
46 // Base Class and Method Names For QR Macros
47 local string ClassName = "FNXPCIEXactorAssertCovDatabase";
48 local string MethodName = null;
49
50 local ReportClass MyReport;
51
52 // Assertion Coverage Database Array
53 local integer AssertCov[*];
54
55 local string XactorName;
56
57 // constructor
58 task new( ReportClass _Report,
59 string _XactorName );
60
61 // public methods
62 task Reset();
63 task Add( denaliPcieErrorTypeT covPt );
64 function bit Covered( denaliPcieErrorTypeT covPt );
65 function integer Count( denaliPcieErrorTypeT covPt );
66 function string GetStr();
67 task Display( ReportType rptType );
68}
69
70task FNXPCIEXactorAssertCovDatabase::new( ReportClass _Report,
71 string _XactorName )
72{
73 string MethodName = "new";
74
75 MyReport = _Report;
76 XactorName = _XactorName;
77 Reset();
78}
79
80task FNXPCIEXactorAssertCovDatabase::Reset()
81{
82 string MethodName = "Reset";
83 integer i;
84
85 // Allocate Assertion Coverage Database Dynamic Array and Init to Zero
86 AssertCov = new[PCIE_MAX_ERROR_ID];
87 for (i=0; i < PCIE_MAX_ERROR_ID; i++)
88 AssertCov[i] = 0;
89}
90
91task FNXPCIEXactorAssertCovDatabase::Add( denaliPcieErrorTypeT covPt )
92{
93 string MethodName = "Add";
94
95 AssertCov[covPt]++;
96}
97
98function bit FNXPCIEXactorAssertCovDatabase::Covered( denaliPcieErrorTypeT covPt )
99{
100 string MethodName = "Covered";
101
102 if (AssertCov[covPt] > 0)
103 Covered = 1;
104 else
105 Covered = 0;
106}
107
108function integer FNXPCIEXactorAssertCovDatabase::Count( denaliPcieErrorTypeT covPt )
109{
110 string MethodName = "Count";
111
112 Count = AssertCov[covPt];
113}
114
115function string FNXPCIEXactorAssertCovDatabase::GetStr()
116{
117 string MethodName = "GetStr";
118 string tmp, coveredStr, covPtStr, whiteSpaceStr;
119 denaliPcieErrorTypeT covPt;
120 integer i, j, numWhiteSpaces, maxStrLen;
121
122 // Get Maximum Length of an Assertion Coverage Point's String for Display Formatting Purposes
123 maxStrLen = 0;
124 for (i=0; i < PCIE_MAX_ERROR_ID; i++) {
125 cast_assign( covPt, i );
126 sprintf( covPtStr, "%s", covPt );
127 if (covPtStr.len() > maxStrLen)
128 maxStrLen = covPtStr.len();
129 }
130
131 // Add Assertion Coverage Table Header to GetStr
132 sprintf( GetStr, "\n" );
133 sprintf( tmp, "---------------------------------------------------------------------------\n" );
134 GetStr = { GetStr, tmp };
135 sprintf( tmp, " %s Assertion Coverage Database Contents\n", XactorName );
136 GetStr = { GetStr, tmp };
137 sprintf( tmp, "---------------------------------------------------------------------------\n" );
138 GetStr = { GetStr, tmp };
139
140 // Add Every Assertion Coverage Point to GetStr
141 for (i=0; i < PCIE_MAX_ERROR_ID; i++) {
142 cast_assign( covPt, i );
143 if (Covered(covPt))
144 coveredStr = " Covered ";
145 else
146 coveredStr = "Not Covered";
147 sprintf( covPtStr, "%s", covPt );
148 numWhiteSpaces = maxStrLen - covPtStr.len();
149 whiteSpaceStr = "";
150 for (j=0; j < numWhiteSpaces; j++)
151 whiteSpaceStr = { whiteSpaceStr, " " };
152 sprintf( tmp, " %s%s | %s | %0d\n", covPtStr, whiteSpaceStr, coveredStr, Count(covPt) );
153 GetStr = { GetStr, tmp };
154 }
155}
156
157task FNXPCIEXactorAssertCovDatabase::Display( ReportType rptType )
158{
159 string MethodName = "Display";
160
161 PCIEX_QR_Type( rptType, GetStr() );
162}