2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
32 // This file is not part of the regular simulator. It is solely for
33 // testing the parameter code. Edit the Makefile to add param_test.cc
34 // to the sources list, then use configs/test.ini as the configuration
37 #include "sim/sim_object.hh"
38 #include "mem/cache/cache.hh"
40 class ParamTest
: public SimObject
43 ParamTest(string name
)
48 virtual ~ParamTest() {}
51 enum Enum1Type
{ Enum0
};
52 enum Enum2Type
{ Enum10
};
54 BEGIN_DECLARE_SIM_OBJECT_PARAMS(ParamTest
)
57 VectorParam
<int> vecint
;
58 Param
<string
> stringparam
;
59 VectorParam
<string
> vecstring
;
60 Param
<bool> boolparam
;
61 VectorParam
<bool> vecbool
;
62 SimObjectParam
<BaseMemory
*> memobj
;
63 SimObjectVectorParam
<BaseMemory
*> vecmemobj
;
64 SimpleEnumParam
<Enum1Type
> enum1
;
65 MappedEnumParam
<Enum2Type
> enum2
;
66 SimpleEnumVectorParam
<Enum1Type
> vecenum1
;
67 MappedEnumVectorParam
<Enum2Type
> vecenum2
;
69 END_DECLARE_SIM_OBJECT_PARAMS(ParamTest
)
71 const char *enum1_strings
[] =
73 "zero", "one", "two", "three"
76 const EnumParamMap enum2_map
[] =
84 BEGIN_INIT_SIM_OBJECT_PARAMS(ParamTest
)
86 INIT_PARAM(intparam
, "intparam"),
87 INIT_PARAM(vecint
, "vecint"),
88 INIT_PARAM(stringparam
, "stringparam"),
89 INIT_PARAM(vecstring
, "vecstring"),
90 INIT_PARAM(boolparam
, "boolparam"),
91 INIT_PARAM(vecbool
, "vecbool"),
92 INIT_PARAM(memobj
, "memobj"),
93 INIT_PARAM(vecmemobj
, "vecmemobj"),
94 INIT_ENUM_PARAM(enum1
, "enum1", enum1_strings
),
95 INIT_ENUM_PARAM(enum2
, "enum2", enum2_map
),
96 INIT_ENUM_PARAM(vecenum1
, "vecenum1", enum1_strings
),
97 INIT_ENUM_PARAM(vecenum2
, "vecenum2", enum2_map
)
99 END_INIT_SIM_OBJECT_PARAMS(ParamTest
)
102 CREATE_SIM_OBJECT(ParamTest
)
104 return new ParamTest(getInstanceName());
107 REGISTER_SIM_OBJECT("ParamTest", ParamTest
)