StateMachine.py (9102:5464eb9a684b) StateMachine.py (9104:27d56b644e78)
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
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;

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

56 else:
57 var = Var(symtab, param.name, location, param.type_ast.type,
58 "m_%s" % param.name, {}, self)
59 self.symtab.registerSym(param.name, var)
60
61 self.states = orderdict()
62 self.events = orderdict()
63 self.actions = orderdict()
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
2# Copyright (c) 2009 The Hewlett-Packard Development Company
3# All rights reserved.
4#
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;

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

56 else:
57 var = Var(symtab, param.name, location, param.type_ast.type,
58 "m_%s" % param.name, {}, self)
59 self.symtab.registerSym(param.name, var)
60
61 self.states = orderdict()
62 self.events = orderdict()
63 self.actions = orderdict()
64 self.request_types = orderdict()
64 self.transitions = []
65 self.in_ports = []
66 self.functions = []
67 self.objects = []
68 self.TBEType = None
69 self.EntryType = None
70
71 self.message_buffer_names = []

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

92 if action.short == other.short:
93 other.warning("Duplicate action shorthand: %s" % other.ident)
94 other.warning(" shorthand = %s" % other.short)
95 action.warning("Duplicate action shorthand: %s" % action.ident)
96 action.error(" shorthand = %s" % action.short)
97
98 self.actions[action.ident] = action
99
65 self.transitions = []
66 self.in_ports = []
67 self.functions = []
68 self.objects = []
69 self.TBEType = None
70 self.EntryType = None
71
72 self.message_buffer_names = []

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

93 if action.short == other.short:
94 other.warning("Duplicate action shorthand: %s" % other.ident)
95 other.warning(" shorthand = %s" % other.short)
96 action.warning("Duplicate action shorthand: %s" % action.ident)
97 action.error(" shorthand = %s" % action.short)
98
99 self.actions[action.ident] = action
100
101 def addRequestType(self, request_type):
102 assert self.table is None
103 self.request_types[request_type.ident] = request_type
104
100 def addTransition(self, trans):
101 assert self.table is None
102 self.transitions.append(trans)
103
104 def addInPort(self, var):
105 self.in_ports.append(var)
106
107 def addFunc(self, func):

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

984 code.write(path, "%s.cc" % c_ident)
985
986 def printCWakeup(self, path):
987 '''Output the wakeup loop for the events'''
988
989 code = self.symtab.codeFormatter()
990 ident = self.ident
991
105 def addTransition(self, trans):
106 assert self.table is None
107 self.transitions.append(trans)
108
109 def addInPort(self, var):
110 self.in_ports.append(var)
111
112 def addFunc(self, func):

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

989 code.write(path, "%s.cc" % c_ident)
990
991 def printCWakeup(self, path):
992 '''Output the wakeup loop for the events'''
993
994 code = self.symtab.codeFormatter()
995 ident = self.ident
996
997 outputRequest_types = True
998 if len(self.request_types) == 0:
999 outputRequest_types = False
1000
992 code('''
993// Auto generated C++ code started by $__file__:$__line__
994// ${ident}: ${{self.short}}
995
996#include <sys/types.h>
997#include <unistd.h>
998
999#include <cassert>
1000
1001#include "base/misc.hh"
1002#include "debug/RubySlicc.hh"
1003#include "mem/protocol/${ident}_Controller.hh"
1004#include "mem/protocol/${ident}_Event.hh"
1005#include "mem/protocol/${ident}_State.hh"
1001 code('''
1002// Auto generated C++ code started by $__file__:$__line__
1003// ${ident}: ${{self.short}}
1004
1005#include <sys/types.h>
1006#include <unistd.h>
1007
1008#include <cassert>
1009
1010#include "base/misc.hh"
1011#include "debug/RubySlicc.hh"
1012#include "mem/protocol/${ident}_Controller.hh"
1013#include "mem/protocol/${ident}_Event.hh"
1014#include "mem/protocol/${ident}_State.hh"
1015''')
1016
1017 if outputRequest_types:
1018 code('''#include "mem/protocol/${ident}_RequestType.hh"''')
1019
1020 code('''
1006#include "mem/protocol/Types.hh"
1007#include "mem/ruby/common/Global.hh"
1008#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
1009#include "mem/ruby/system/System.hh"
1010
1011using namespace std;
1012
1013void

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

1205
1206 case = self.symtab.codeFormatter()
1207 # Only set next_state if it changes
1208 if trans.state != trans.nextState:
1209 ns_ident = trans.nextState.ident
1210 case('next_state = ${ident}_State_${ns_ident};')
1211
1212 actions = trans.actions
1021#include "mem/protocol/Types.hh"
1022#include "mem/ruby/common/Global.hh"
1023#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
1024#include "mem/ruby/system/System.hh"
1025
1026using namespace std;
1027
1028void

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

1220
1221 case = self.symtab.codeFormatter()
1222 # Only set next_state if it changes
1223 if trans.state != trans.nextState:
1224 ns_ident = trans.nextState.ident
1225 case('next_state = ${ident}_State_${ns_ident};')
1226
1227 actions = trans.actions
1228 request_types = trans.request_types
1213
1214 # Check for resources
1215 case_sorter = []
1216 res = trans.resources
1217 for key,val in res.iteritems():
1218 if key.type.ident != "DNUCAStopTable":
1219 val = '''
1220if (!%s.areNSlotsAvailable(%s))
1221 return TransitionResult_ResourceStall;
1222''' % (key.code, val)
1223 case_sorter.append(val)
1224
1225
1226 # Emit the code sequences in a sorted order. This makes the
1227 # output deterministic (without this the output order can vary
1228 # since Map's keys() on a vector of pointers is not deterministic
1229 for c in sorted(case_sorter):
1230 case("$c")
1231
1229
1230 # Check for resources
1231 case_sorter = []
1232 res = trans.resources
1233 for key,val in res.iteritems():
1234 if key.type.ident != "DNUCAStopTable":
1235 val = '''
1236if (!%s.areNSlotsAvailable(%s))
1237 return TransitionResult_ResourceStall;
1238''' % (key.code, val)
1239 case_sorter.append(val)
1240
1241
1242 # Emit the code sequences in a sorted order. This makes the
1243 # output deterministic (without this the output order can vary
1244 # since Map's keys() on a vector of pointers is not deterministic
1245 for c in sorted(case_sorter):
1246 case("$c")
1247
1248 # Record access types for this transition
1249 for request_type in request_types:
1250 case('recordRequestType(${ident}_RequestType_${{request_type.ident}}, addr);')
1251
1232 # Figure out if we stall
1233 stall = False
1234 for action in actions:
1235 if action.ident == "z_stall":
1236 stall = True
1237 break
1238
1239 if stall:

--- 441 unchanged lines hidden ---
1252 # Figure out if we stall
1253 stall = False
1254 for action in actions:
1255 if action.ident == "z_stall":
1256 stall = True
1257 break
1258
1259 if stall:

--- 441 unchanged lines hidden ---