Deleted Added
sdiff udiff text old ( 6999:f226c098c393 ) new ( 7002:48a19d52d939 )
full compact
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
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('''
221extern std::stringstream ${ident}_transitionComment;
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;
233 const std::string toString() const;
234 const std::string getName() const;
235 const MachineType getMachineType() const;
236 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }
237 void print(std::ostream& out) const;
238 void printConfig(std::ostream& out) const;
239 void wakeup();
240 void printStats(std::ostream& out) const;
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
260std::string m_name;
261int m_transitions_per_cycle;
262int m_buffer_size;
263int m_recycle_latency;
264map<std::string, std::string> m_cfg;
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
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;
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
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);
887 void dumpStats(std::ostream& out) const;
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}
949void ${ident}_Profiler::dumpStats(std::ostream& out) const
950{
951 using namespace std;
952
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 ---