StateMachine.py (6999:f226c098c393) StateMachine.py (7002:48a19d52d939)
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;

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

191 *
192 * Auto generated C++ code started by $__file__:$__line__
193 * Created by slicc definition of Module "${{self.short}}"
194 */
195
196#ifndef ${ident}_CONTROLLER_H
197#define ${ident}_CONTROLLER_H
198
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;

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

191 *
192 * Auto generated C++ code started by $__file__:$__line__
193 * Created by slicc definition of Module "${{self.short}}"
194 */
195
196#ifndef ${ident}_CONTROLLER_H
197#define ${ident}_CONTROLLER_H
198
199#include <iostream>
200#include <sstream>
201#include <string>
202
199#include "params/$c_ident.hh"
200
201#include "mem/ruby/common/Global.hh"
202#include "mem/ruby/common/Consumer.hh"
203#include "mem/ruby/slicc_interface/AbstractController.hh"
204#include "mem/protocol/TransitionResult.hh"
205#include "mem/protocol/Types.hh"
206#include "mem/protocol/${ident}_Profiler.hh"
207''')
208
209 seen_types = set()
210 for var in self.objects:
211 if var.type.ident not in seen_types and not var.type.isPrimitive:
212 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
213 seen_types.add(var.type.ident)
214
215 # for adding information to the protocol debug trace
216 code('''
203#include "params/$c_ident.hh"
204
205#include "mem/ruby/common/Global.hh"
206#include "mem/ruby/common/Consumer.hh"
207#include "mem/ruby/slicc_interface/AbstractController.hh"
208#include "mem/protocol/TransitionResult.hh"
209#include "mem/protocol/Types.hh"
210#include "mem/protocol/${ident}_Profiler.hh"
211''')
212
213 seen_types = set()
214 for var in self.objects:
215 if var.type.ident not in seen_types and not var.type.isPrimitive:
216 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
217 seen_types.add(var.type.ident)
218
219 # for adding information to the protocol debug trace
220 code('''
217extern stringstream ${ident}_transitionComment;
221extern std::stringstream ${ident}_transitionComment;
218
219class $c_ident : public AbstractController {
220#ifdef CHECK_COHERENCE
221#endif /* CHECK_COHERENCE */
222public:
223 typedef ${c_ident}Params Params;
224 $c_ident(const Params *p);
225 static int getNumControllers();
226 void init();
227 MessageBuffer* getMandatoryQueue() const;
228 const int & getVersion() const;
222
223class $c_ident : public AbstractController {
224#ifdef CHECK_COHERENCE
225#endif /* CHECK_COHERENCE */
226public:
227 typedef ${c_ident}Params Params;
228 $c_ident(const Params *p);
229 static int getNumControllers();
230 void init();
231 MessageBuffer* getMandatoryQueue() const;
232 const int & getVersion() const;
229 const string toString() const;
230 const string getName() const;
233 const std::string toString() const;
234 const std::string getName() const;
231 const MachineType getMachineType() const;
232 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
235 const MachineType getMachineType() const;
236 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
233 void print(ostream& out) const;
234 void printConfig(ostream& out) const;
237 void print(std::ostream& out) const;
238 void printConfig(std::ostream& out) const;
235 void wakeup();
239 void wakeup();
236 void printStats(ostream& out) const;
240 void printStats(std::ostream& out) const;
237 void clearStats();
238 void blockOnQueue(Address addr, MessageBuffer* port);
239 void unblock(Address addr);
240private:
241''')
242
243 code.indent()
244 # added by SS
245 for param in self.config_parameters:
246 if param.pointer:
247 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;')
248 else:
249 code('${{param.type_ast.type}} m_${{param.ident}};')
250
251 code('''
252int m_number_of_TBEs;
253
254TransitionResult doTransition(${ident}_Event event, ${ident}_State state, const Address& addr); // in ${ident}_Transitions.cc
255TransitionResult doTransitionWorker(${ident}_Event event, ${ident}_State state, ${ident}_State& next_state, const Address& addr); // in ${ident}_Transitions.cc
241 void clearStats();
242 void blockOnQueue(Address addr, MessageBuffer* port);
243 void unblock(Address addr);
244private:
245''')
246
247 code.indent()
248 # added by SS
249 for param in self.config_parameters:
250 if param.pointer:
251 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;')
252 else:
253 code('${{param.type_ast.type}} m_${{param.ident}};')
254
255 code('''
256int m_number_of_TBEs;
257
258TransitionResult doTransition(${ident}_Event event, ${ident}_State state, const Address& addr); // in ${ident}_Transitions.cc
259TransitionResult doTransitionWorker(${ident}_Event event, ${ident}_State state, ${ident}_State& next_state, const Address& addr); // in ${ident}_Transitions.cc
256string m_name;
260std::string m_name;
257int m_transitions_per_cycle;
258int m_buffer_size;
259int m_recycle_latency;
261int m_transitions_per_cycle;
262int m_buffer_size;
263int m_recycle_latency;
260map< string, string > m_cfg;
264map<std::string, std::string> m_cfg;
261NodeID m_version;
262Network* m_net_ptr;
263MachineID m_machineID;
264bool m_is_blocking;
265map< Address, MessageBuffer* > m_block_map;
266${ident}_Profiler s_profiler;
267static int m_num_controllers;
268// Internal functions

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

307
308 code('''
309/** \\file $ident.cc
310 *
311 * Auto generated C++ code started by $__file__:$__line__
312 * Created by slicc definition of Module "${{self.short}}"
313 */
314
265NodeID m_version;
266Network* m_net_ptr;
267MachineID m_machineID;
268bool m_is_blocking;
269map< Address, MessageBuffer* > m_block_map;
270${ident}_Profiler s_profiler;
271static int m_num_controllers;
272// Internal functions

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

311
312 code('''
313/** \\file $ident.cc
314 *
315 * Auto generated C++ code started by $__file__:$__line__
316 * Created by slicc definition of Module "${{self.short}}"
317 */
318
319#include <sstream>
320#include <string>
321
315#include "mem/ruby/common/Global.hh"
316#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
317#include "mem/protocol/${ident}_Controller.hh"
318#include "mem/protocol/${ident}_State.hh"
319#include "mem/protocol/${ident}_Event.hh"
320#include "mem/protocol/Types.hh"
321#include "mem/ruby/system/System.hh"
322#include "mem/ruby/common/Global.hh"
323#include "mem/ruby/slicc_interface/RubySlicc_includes.hh"
324#include "mem/protocol/${ident}_Controller.hh"
325#include "mem/protocol/${ident}_State.hh"
326#include "mem/protocol/${ident}_Event.hh"
327#include "mem/protocol/Types.hh"
328#include "mem/ruby/system/System.hh"
329
330using namespace std;
322''')
323
324 # include object classes
325 seen_types = set()
326 for var in self.objects:
327 if var.type.ident not in seen_types and not var.type.isPrimitive:
328 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
329 seen_types.add(var.type.ident)

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

858
859 code('''
860// Auto generated C++ code started by $__file__:$__line__
861// ${ident}: ${{self.short}}
862
863#ifndef ${ident}_PROFILER_H
864#define ${ident}_PROFILER_H
865
331''')
332
333 # include object classes
334 seen_types = set()
335 for var in self.objects:
336 if var.type.ident not in seen_types and not var.type.isPrimitive:
337 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
338 seen_types.add(var.type.ident)

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

867
868 code('''
869// Auto generated C++ code started by $__file__:$__line__
870// ${ident}: ${{self.short}}
871
872#ifndef ${ident}_PROFILER_H
873#define ${ident}_PROFILER_H
874
875#include <iostream>
876
866#include "mem/ruby/common/Global.hh"
867#include "mem/protocol/${ident}_State.hh"
868#include "mem/protocol/${ident}_Event.hh"
869
870class ${ident}_Profiler {
871 public:
872 ${ident}_Profiler();
873 void setVersion(int version);
874 void countTransition(${ident}_State state, ${ident}_Event event);
875 void possibleTransition(${ident}_State state, ${ident}_Event event);
877#include "mem/ruby/common/Global.hh"
878#include "mem/protocol/${ident}_State.hh"
879#include "mem/protocol/${ident}_Event.hh"
880
881class ${ident}_Profiler {
882 public:
883 ${ident}_Profiler();
884 void setVersion(int version);
885 void countTransition(${ident}_State state, ${ident}_Event event);
886 void possibleTransition(${ident}_State state, ${ident}_Event event);
876 void dumpStats(ostream& out) const;
887 void dumpStats(std::ostream& out) const;
877 void clearStats();
878
879 private:
880 int m_counters[${ident}_State_NUM][${ident}_Event_NUM];
881 int m_event_counters[${ident}_Event_NUM];
882 bool m_possible[${ident}_State_NUM][${ident}_Event_NUM];
883 int m_version;
884};

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

930 assert(m_possible[state][event]);
931 m_counters[state][event]++;
932 m_event_counters[event]++;
933}
934void ${ident}_Profiler::possibleTransition(${ident}_State state, ${ident}_Event event)
935{
936 m_possible[state][event] = true;
937}
888 void clearStats();
889
890 private:
891 int m_counters[${ident}_State_NUM][${ident}_Event_NUM];
892 int m_event_counters[${ident}_Event_NUM];
893 bool m_possible[${ident}_State_NUM][${ident}_Event_NUM];
894 int m_version;
895};

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

941 assert(m_possible[state][event]);
942 m_counters[state][event]++;
943 m_event_counters[event]++;
944}
945void ${ident}_Profiler::possibleTransition(${ident}_State state, ${ident}_Event event)
946{
947 m_possible[state][event] = true;
948}
938void ${ident}_Profiler::dumpStats(ostream& out) const
949void ${ident}_Profiler::dumpStats(std::ostream& out) const
939{
950{
951 using namespace std;
952
940 out << " --- ${ident} " << m_version << " ---" << endl;
941 out << " - Event Counts -" << endl;
942 for (int event = 0; event < ${ident}_Event_NUM; event++) {
943 int count = m_event_counters[event];
944 out << (${ident}_Event) event << " " << count << endl;
945 }
946 out << endl;
947 out << " - Transitions -" << endl;

--- 193 unchanged lines hidden ---
953 out << " --- ${ident} " << m_version << " ---" << endl;
954 out << " - Event Counts -" << endl;
955 for (int event = 0; event < ${ident}_Event_NUM; event++) {
956 int count = m_event_counters[event];
957 out << (${ident}_Event) event << " " << count << endl;
958 }
959 out << endl;
960 out << " - Transitions -" << endl;

--- 193 unchanged lines hidden ---