1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 36 unchanged lines hidden (view full) ---

45#####################################################################
46
47import copy
48import datetime
49import re
50import sys
51import time
52
53import convert
53import proxy
54import ticks
55from util import *
56
58import SimObject
59
57def isSimObject(*args, **kwargs):
58 return SimObject.isSimObject(*args, **kwargs)
59
60def isSimObjectSequence(*args, **kwargs):
61 return SimObject.isSimObjectSequence(*args, **kwargs)
62
63def isSimObjectClass(*args, **kwargs):
64 return SimObject.isSimObjectClass(*args, **kwargs)

--- 638 unchanged lines hidden (view full) ---

703 else:
704 raise TypeError, "Enum-derived class must define "\
705 "attribute 'map' or 'vals'"
706
707 cls.cxx_type = 'Enums::%s' % name
708
709 super(MetaEnum, cls).__init__(name, bases, init_dict)
710
714 def __str__(cls):
715 return cls.__name__
716
711 # Generate C++ class declaration for this enum type.
712 # Note that we wrap the enum in a class/struct to act as a namespace,
713 # so that the enum strings can be brief w/o worrying about collisions.
714 def cxx_decl(cls):
721 code = "#ifndef __ENUM__%s\n" % cls
722 code += '#define __ENUM__%s\n' % cls
715 name = cls.__name__
716 code = "#ifndef __ENUM__%s\n" % name
717 code += '#define __ENUM__%s\n' % name
718 code += '\n'
719 code += 'namespace Enums {\n'
725 code += ' enum %s {\n' % cls
720 code += ' enum %s {\n' % name
721 for val in cls.vals:
722 code += ' %s = %d,\n' % (val, cls.map[val])
728 code += ' Num_%s = %d,\n' % (cls, len(cls.vals))
723 code += ' Num_%s = %d,\n' % (name, len(cls.vals))
724 code += ' };\n'
730 code += ' extern const char *%sStrings[Num_%s];\n' % (cls, cls)
725 code += ' extern const char *%sStrings[Num_%s];\n' % (name, name)
726 code += '}\n'
727 code += '\n'
728 code += '#endif\n'
729 return code
730
731 def cxx_def(cls):
737 code = '#include "enums/%s.hh"\n' % cls
732 name = cls.__name__
733 code = '#include "enums/%s.hh"\n' % name
734 code += 'namespace Enums {\n'
739 code += ' const char *%sStrings[Num_%s] =\n' % (cls, cls)
735 code += ' const char *%sStrings[Num_%s] =\n' % (name, name)
736 code += ' {\n'
737 for val in cls.vals:
738 code += ' "%s",\n' % val
739 code += ' };\n'
740 code += '}\n'
741 return code
742
743# Base class for enum types.

--- 417 unchanged lines hidden (view full) ---

1161# proxy objects (via set_param_desc()) so that proxy error messages
1162# make sense.
1163class PortParamDesc(object):
1164 __metaclass__ = Singleton
1165
1166 ptype_str = 'Port'
1167 ptype = Port
1168
1169baseEnums = allEnums.copy()
1170baseParams = allParams.copy()
1171
1172def clear():
1173 global allEnums, allParams
1174
1175 allEnums = baseEnums.copy()
1176 allParams = baseParams.copy()
1177
1178__all__ = ['Param', 'VectorParam',
1179 'Enum', 'Bool', 'String', 'Float',
1180 'Int', 'Unsigned', 'Int8', 'UInt8', 'Int16', 'UInt16',
1181 'Int32', 'UInt32', 'Int64', 'UInt64',
1182 'Counter', 'Addr', 'Tick', 'Percent',
1183 'TcpPort', 'UdpPort', 'EthernetAddr',
1184 'MemorySize', 'MemorySize32',
1185 'Latency', 'Frequency', 'Clock',
1186 'NetworkBandwidth', 'MemoryBandwidth',
1187 'Range', 'AddrRange', 'TickRange',
1188 'MaxAddr', 'MaxTick', 'AllMemory',
1189 'Time',
1190 'NextEthernetAddr', 'NULL',
1191 'Port', 'VectorPort']
1192
1193import SimObject