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;

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

346 if self.TBEType != None:
347 code('''
348
349// Set and Reset for tbe variable
350void set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${ident}_TBE* m_new_tbe);
351void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
352''')
353
354 # Prototype the actions that the controller can take
355 code('''
356
357// Actions
358''')
359 if self.TBEType != None and self.EntryType != None:
360 for action in self.actions.itervalues():
361 code('/** \\brief ${{action.desc}} */')
361 code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);')
362 code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& '
363 'm_tbe_ptr, ${{self.EntryType.c_ident}}*& '
364 'm_cache_entry_ptr, const Address& addr);')
365 elif self.TBEType != None:
366 for action in self.actions.itervalues():
367 code('/** \\brief ${{action.desc}} */')
365 code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, const Address& addr);')
368 code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& '
369 'm_tbe_ptr, const Address& addr);')
370 elif self.EntryType != None:
371 for action in self.actions.itervalues():
372 code('/** \\brief ${{action.desc}} */')
369 code('void ${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);')
373 code('void ${{action.ident}}(${{self.EntryType.c_ident}}*& '
374 'm_cache_entry_ptr, const Address& addr);')
375 else:
376 for action in self.actions.itervalues():
377 code('/** \\brief ${{action.desc}} */')
378 code('void ${{action.ident}}(const Address& addr);')
379
380 # the controller internal variables
381 code('''
382

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

434
435 # include object classes
436 seen_types = set()
437 for var in self.objects:
438 if var.type.ident not in seen_types and not var.type.isPrimitive:
439 code('#include "mem/protocol/${{var.type.c_ident}}.hh"')
440 seen_types.add(var.type.ident)
441
442 num_in_ports = len(self.in_ports)
443
444 code('''
445$c_ident *
446${c_ident}Params::create()
447{
448 return new $c_ident(this);
449}
450
451int $c_ident::m_num_controllers = 0;

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

462#endif
463
464/** \\brief constructor */
465$c_ident::$c_ident(const Params *p)
466 : AbstractController(p)
467{
468 m_machineID.type = MachineType_${ident};
469 m_machineID.num = m_version;
470 m_num_controllers++;
471
472 m_in_ports = $num_in_ports;
473''')
464 num_in_ports = len(self.in_ports)
465 code(' m_in_ports = $num_in_ports;')
474 code.indent()
475
476 #
477 # After initializing the universal machine parameters, initialize the
470 # this machines config parameters. Also detemine if these configuration
471 # params include a sequencer. This information will be used later for
472 # contecting the sequencer back to the L1 cache controller.
478 # this machines config parameters. Also if these configuration params
479 # include a sequencer, connect the it to the controller.
480 #
474 contains_dma_sequencer = False
475 sequencers = []
481 for param in self.config_parameters:
477 if param.name == "dma_sequencer":
478 contains_dma_sequencer = True
479 elif re.compile("sequencer").search(param.name):
480 sequencers.append(param.name)
482 if param.pointer:
483 code('m_${{param.name}}_ptr = p->${{param.name}};')
484 else:
485 code('m_${{param.name}} = p->${{param.name}};')
485
486 #
487 # For the l1 cache controller, add the special atomic support which
488 # includes passing the sequencer a pointer to the controller.
489 #
490 for seq in sequencers:
491 code('''
492m_${{seq}}_ptr->setController(this);
493 ''')
494
495 #
496 # For the DMA controller, pass the sequencer a pointer to the
497 # controller.
498 #
499 if self.ident == "DMA":
500 if not contains_dma_sequencer:
501 self.error("The DMA controller must include the sequencer " \
502 "configuration parameter")
503
504 code('''
505m_dma_sequencer_ptr->setController(this);
506''')
486 if re.compile("sequencer").search(param.name):
487 code('m_${{param.name}}_ptr->setController(this);')
488
508 code('m_num_controllers++;')
489 for var in self.objects:
490 if var.ident.find("mandatoryQueue") >= 0:
491 code('''
492m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();
493m_${{var.c_ident}}_ptr->setReceiver(this);
494''')
495 else:
496 if "network" in var and "physical_network" in var and \

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

667
668 code.dedent()
669 code('''
670 AbstractController::init();
671 resetStats();
672}
673''')
674
695 has_mandatory_q = False
675 mq_ident = "NULL"
676 for port in self.in_ports:
677 if port.code.find("mandatoryQueue_ptr") >= 0:
698 has_mandatory_q = True
678 mq_ident = "m_%s_mandatoryQueue_ptr" % self.ident
679
700 if has_mandatory_q:
701 mq_ident = "m_%s_mandatoryQueue_ptr" % self.ident
702 else:
703 mq_ident = "NULL"
704
680 seq_ident = "NULL"
681 for param in self.config_parameters:
682 if param.name == "sequencer":
683 assert(param.pointer)
684 seq_ident = "m_%s_ptr" % param.name
685
686 code('''
687

--- 827 unchanged lines hidden ---