Deleted Added
sdiff udiff text old ( 6863:21fbf0412e0d ) new ( 6877:2a1a3d916ca8 )
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;

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

119 if not action.used:
120 error_msg = "Unused action: %s" % action.ident
121 if "desc" in action:
122 error_msg += ", " + action.desc
123 action.warning(error_msg)
124 self.table = table
125
126 def writeCodeFiles(self, path):
127 self.printControllerHH(path)
128 self.printControllerCC(path)
129 self.printCSwitch(path)
130 self.printCWakeup(path)
131 self.printProfilerCC(path)
132 self.printProfilerHH(path)
133
134 for func in self.functions:
135 func.writeCodeFiles(path)
136
137 def printControllerHH(self, path):
138 '''Output the method declarations for the class declaration'''
139 code = code_formatter()
140 ident = self.ident
141 c_ident = "%s_Controller" % self.ident
142
143 self.message_buffer_names = []
144
145 code('''
146/** \\file $ident.hh
147 *
148 * Auto generated C++ code started by $__file__:$__line__
149 * Created by slicc definition of Module "${{self.short}}"
150 */
151
152#ifndef ${ident}_CONTROLLER_H
153#define ${ident}_CONTROLLER_H
154
155#include "mem/ruby/common/Global.hh"
156#include "mem/ruby/common/Consumer.hh"
157#include "mem/ruby/slicc_interface/AbstractController.hh"
158#include "mem/protocol/TransitionResult.hh"
159#include "mem/protocol/Types.hh"
160#include "mem/protocol/${ident}_Profiler.hh"
161''')
162

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

169 # for adding information to the protocol debug trace
170 code('''
171extern stringstream ${ident}_transitionComment;
172
173class $c_ident : public AbstractController {
174#ifdef CHECK_COHERENCE
175#endif /* CHECK_COHERENCE */
176public:
177 $c_ident(const string & name);
178 static int getNumControllers();
179 void init(Network* net_ptr, const vector<string> & argv);
180 MessageBuffer* getMandatoryQueue() const;
181 const int & getVersion() const;
182 const string toString() const;
183 const string getName() const;
184 const MachineType getMachineType() const;
185 void print(ostream& out) const;
186 void printConfig(ostream& out) const;
187 void wakeup();

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

273 # include object classes
274 seen_types = set()
275 for var in self.objects:
276 if var.type.ident not in seen_types and not var.type.isPrimitive:
277 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
278 seen_types.add(var.type.ident)
279
280 code('''
281int $c_ident::m_num_controllers = 0;
282
283stringstream ${ident}_transitionComment;
284#define APPEND_TRANSITION_COMMENT(str) (${ident}_transitionComment << str)
285/** \\brief constructor */
286$c_ident::$c_ident(const string &name)
287 : m_name(name)
288{
289''')
290 code.indent()
291
292 code('m_num_controllers++;')
293 for var in self.objects:
294 if var.ident.find("mandatoryQueue") >= 0:
295 code('m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();')
296
297 code.dedent()
298 code('''
299}
300
301void $c_ident::init(Network *net_ptr, const vector<string> &argv)
302{
303 for (size_t i = 0; i < argv.size(); i += 2) {
304 if (argv[i] == "version")
305 m_version = atoi(argv[i+1].c_str());
306 else if (argv[i] == "transitions_per_cycle")
307 m_transitions_per_cycle = atoi(argv[i+1].c_str());
308 else if (argv[i] == "buffer_size")
309 m_buffer_size = atoi(argv[i+1].c_str());
310 else if (argv[i] == "recycle_latency")
311 m_recycle_latency = atoi(argv[i+1].c_str());
312 else if (argv[i] == "number_of_TBEs")
313 m_number_of_TBEs = atoi(argv[i+1].c_str());
314''')
315
316 code.indent()
317 code.indent()
318 for param in self.config_parameters:
319 code('else if (argv[i] == "${{param.name}}")')
320 if param.type_ast.type.ident == "int":
321 code(' m_${{param.name}} = atoi(argv[i+1].c_str());')
322 elif param.type_ast.type.ident == "bool":
323 code(' m_${{param.name}} = string_to_bool(argv[i+1]);')
324 else:
325 self.error("only int and bool parameters are "\
326 "currently supported")
327 code.dedent()
328 code.dedent()
329 code('''
330 }
331
332 m_net_ptr = net_ptr;
333 m_machineID.type = MachineType_${ident};
334 m_machineID.num = m_version;
335 for (size_t i = 0; i < argv.size(); i += 2) {
336 if (argv[i] != "version")
337 m_cfg[argv[i]] = argv[i+1];
338 }
339
340 // Objects
341 s_profiler.setVersion(m_version);
342''')
343
344 code.indent()
345 for var in self.objects:
346 vtype = var.type

--- 692 unchanged lines hidden ---