2 * Copyright (c) 2003 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.
30 // This file is not part of the regular simulator. It is solely for
31 // testing the parameter code. Edit the Makefile to add param_test.cc
32 // to the sources list, then use configs/test.ini as the configuration
35 #include "sim/sim_object.hh"
36 #include "mem/cache/cache.hh"
38 class ParamTest
: public SimObject
41 ParamTest(string name
)
46 virtual ~ParamTest() {}
49 enum Enum1Type
{ Enum0
};
50 enum Enum2Type
{ Enum10
};
52 BEGIN_DECLARE_SIM_OBJECT_PARAMS(ParamTest
)
55 VectorParam
<int> vecint
;
56 Param
<string
> stringparam
;
57 VectorParam
<string
> vecstring
;
58 Param
<bool> boolparam
;
59 VectorParam
<bool> vecbool
;
60 SimObjectParam
<mem_hierarchy_obj
*> memobj
;
61 SimObjectVectorParam
<mem_hierarchy_obj
*> vecmemobj
;
62 SimpleEnumParam
<Enum1Type
> enum1
;
63 MappedEnumParam
<Enum2Type
> enum2
;
64 SimpleEnumVectorParam
<Enum1Type
> vecenum1
;
65 MappedEnumVectorParam
<Enum2Type
> vecenum2
;
67 END_DECLARE_SIM_OBJECT_PARAMS(ParamTest
)
69 const char *enum1_strings
[] =
71 "zero", "one", "two", "three"
74 const EnumParamMap enum2_map
[] =
82 BEGIN_INIT_SIM_OBJECT_PARAMS(ParamTest
)
84 INIT_PARAM(intparam
, "intparam"),
85 INIT_PARAM(vecint
, "vecint"),
86 INIT_PARAM(stringparam
, "stringparam"),
87 INIT_PARAM(vecstring
, "vecstring"),
88 INIT_PARAM(boolparam
, "boolparam"),
89 INIT_PARAM(vecbool
, "vecbool"),
90 INIT_PARAM(memobj
, "memobj"),
91 INIT_PARAM(vecmemobj
, "vecmemobj"),
92 INIT_ENUM_PARAM(enum1
, "enum1", enum1_strings
),
93 INIT_ENUM_PARAM(enum2
, "enum2", enum2_map
),
94 INIT_ENUM_PARAM(vecenum1
, "vecenum1", enum1_strings
),
95 INIT_ENUM_PARAM(vecenum2
, "vecenum2", enum2_map
)
97 END_INIT_SIM_OBJECT_PARAMS(ParamTest
)
100 CREATE_SIM_OBJECT(ParamTest
)
102 return new ParamTest(getInstanceName());
105 REGISTER_SIM_OBJECT("ParamTest", ParamTest
)