Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / vera / include / plusArgMacros.vri
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: plusArgMacros.vri
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#ifndef INC__TMP_PLUSARGMACROS_VRI
36#define INC__TMP_PLUSARGMACROS_VRI
37
38// WARNING: do not quote your text when using these macros
39// The macro will add them. You will not have a clash with a var name
40// that is the same as the text even though it "looks" that way.
41// for example, this is OK:
42// integer myint ; getPlusargDec(myint,myint); // sims -vcs_run_args=+myint=5
43// because it really becomes:
44// myint = get_plus_arg(NUM, "myint=");
45
46// You are expected to include the trailing =
47
48// see examples below
49
50#ifdef NTB
51// returns arg in PLUSvar and inferred status in PLUSvar if PLUSvar not null/0
52// but it is better to use mChkPlusarg to be sure a plus arg exists
53#define mChkPlusarg(PLUSname) test_plusargs("PLUSname")
54#define mGetPlusargStr(PLUSname,PLUSvar) void = value_plusargs("PLUSname%s", PLUSvar)
55#define mGetPlusargDec(PLUSname,PLUSvar) void = value_plusargs("PLUSname%d", PLUSvar)
56#define mGetPlusargHex(PLUSname,PLUSvar) void = value_plusargs("PLUSname%h", PLUSvar)
57
58// use these if you are using a string variable as the PLUSname rather than text.
59#define mChkPlusargSvar(PLUSname) test_plusargs(PLUSname)
60// THESE MAY NEED { } ARROUND THEM. THEY ARE TWO STATEMENTS, NOT ONE!!!
61#define mGetPlusargStrSvar(PLUSname,PLUSvar) sprintf(PLUSname,"%s%%s",PLUSname); void = value_plusargs(PLUSname, PLUSvar)
62#define mGetPlusargDecSvar(PLUSname,PLUSvar) sprintf(PLUSname,"%s%%d",PLUSname); void = value_plusargs(PLUSname, PLUSvar)
63#define mGetPlusargHexSvar(PLUSname,PLUSvar) sprintf(PLUSname,"%s%%h",PLUSname); void = value_plusargs(PLUSname, PLUSvar)
64#else
65// returns arg in PLUSvar and inferred status in PLUSvar if PLUSvar not null/0
66// but it is better to use mChkPlusarg to be sure a plus arg exists
67#define mChkPlusarg(PLUSname) get_plus_arg(CHECK, "PLUSname")
68#define mGetPlusargStr(PLUSname,PLUSvar) PLUSvar = get_plus_arg(STR, "PLUSname")
69#define mGetPlusargDec(PLUSname,PLUSvar) PLUSvar = get_plus_arg(NUM, "PLUSname")
70#define mGetPlusargHex(PLUSname,PLUSvar) PLUSvar = get_plus_arg(HNUM, "PLUSname")
71
72// use these if you are using a string variable as the PLUSname rather than text.
73#define mChkPlusargSvar(PLUSname) get_plus_arg(CHECK, PLUSname)
74#define mGetPlusargStrSvar(PLUSname,PLUSvar) PLUSvar = get_plus_arg(STR, PLUSname)
75#define mGetPlusargDecSvar(PLUSname,PLUSvar) PLUSvar = get_plus_arg(NUM, PLUSname)
76#define mGetPlusargHexSvar(PLUSname,PLUSvar) PLUSvar = get_plus_arg(HNUM, PLUSname)
77
78#endif
79
80
81
82// // usage:
83// //
84// // a flag
85// sims -vcs_run_args=+seed
86// // value (missing)
87// sims -vcs_run_args=+seed=
88// // value (string)
89// sims -vcs_run_args=+seed=me
90// // value (decimal)
91// sims -vcs_run_args=+seed=1234
92// // value (hex)
93// sims -vcs_run_args=+seed=0xA5b
94//
95// // in the code
96// reg [2048:0] retstr;
97// integer reti;
98// reg [63:0] reth;
99//
100// if (mChkPlusarg(seed=)) {
101// mGetPlusargStr(seed=,retstr);
102// printf("retstr not null, is %s\n",retstr);
103// } else printf("retstr not found.\n");
104//
105// if (mChkPlusarg(seed=)) {
106// mGetPlusargDec(seed=,reti);
107// printf("reti not null, is %0d\n",reti);
108// } else printf("reti not found.\n");
109//
110// if (mChkPlusarg(seed=)) {
111// mGetPlusargHex(seed=,reth);
112// printf("reth not null, is %0h\n",reth);
113// } else printf("reth not found.\n");
114
115
116
117
118
119#endif