Deleted Added
sdiff udiff text old ( 7832:de7601e6e19d ) new ( 7839:9e556fb25900 )
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;

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

41 "DMASequencer": "DMASequencer"
42 }
43
44class StateMachine(Symbol):
45 def __init__(self, symtab, ident, location, pairs, config_parameters):
46 super(StateMachine, self).__init__(symtab, ident, location, pairs)
47 self.table = None
48 self.config_parameters = config_parameters
49 for param in config_parameters:
50 if param.pointer:
51 var = Var(symtab, param.name, location, param.type_ast.type,
52 "(*m_%s_ptr)" % param.name, {}, self)
53 else:
54 var = Var(symtab, param.name, location, param.type_ast.type,
55 "m_%s" % param.name, {}, self)
56 self.symtab.registerSym(param.name, var)
57
58 self.states = orderdict()
59 self.events = orderdict()
60 self.actions = orderdict()
61 self.transitions = []
62 self.in_ports = []
63 self.functions = []
64 self.objects = []
65
66 self.message_buffer_names = []
67
68 def __repr__(self):
69 return "[StateMachine: %s]" % self.ident
70
71 def addState(self, state):
72 assert self.table is None

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

102 def addFunc(self, func):
103 # register func in the symbol table
104 self.symtab.registerSym(str(func), func)
105 self.functions.append(func)
106
107 def addObject(self, obj):
108 self.objects.append(obj)
109
110 # Needs to be called before accessing the table
111 def buildTable(self):
112 assert self.table is None
113
114 table = {}
115
116 for trans in self.transitions:
117 # Track which actions we touch so we know if we use them

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

259 code('${{param.type_ast.type}}* m_${{param.ident}}_ptr;')
260 else:
261 code('${{param.type_ast.type}} m_${{param.ident}};')
262
263 code('''
264int m_number_of_TBEs;
265
266TransitionResult doTransition(${ident}_Event event,
267 ${ident}_State state,
268 const Address& addr);
269
270TransitionResult doTransitionWorker(${ident}_Event event,
271 ${ident}_State state,
272 ${ident}_State& next_state,
273 const Address& addr);
274
275std::string m_name;
276int m_transitions_per_cycle;
277int m_buffer_size;
278int m_recycle_latency;
279std::map<std::string, std::string> m_cfg;
280NodeID m_version;

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

294// Internal functions
295''')
296
297 for func in self.functions:
298 proto = func.prototype
299 if proto:
300 code('$proto')
301
302 code('''
303
304// Actions
305''')
306 for action in self.actions.itervalues():
307 code('/** \\brief ${{action.desc}} */')
308 code('void ${{action.ident}}(const Address& addr);')
309
310 # the controller internal variables
311 code('''
312
313// Objects
314''')
315 for var in self.objects:
316 th = var.get("template_hack", "")

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

726 if param.type_ast.type.ident == "CacheMemory" or \
727 param.type_ast.type.ident == "MemoryControl":
728 assert(param.pointer)
729 code(' m_${{param.ident}}_ptr->clearStats();')
730
731 code('''
732 m_profiler.clearStats();
733}
734
735// Actions
736''')
737
738 for action in self.actions.itervalues():
739 if "c_code" not in action:
740 continue
741
742 code('''
743/** \\brief ${{action.desc}} */
744void
745$c_ident::${{action.ident}}(const Address& addr)
746{
747 DPRINTF(RubyGenerated, "executing\\n");
748 ${{action["c_code"]}}
749}
750
751''')
752 code.write(path, "%s.cc" % c_ident)

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

772#include "mem/protocol/Types.hh"
773#include "mem/ruby/system/System.hh"
774
775using namespace std;
776
777void
778${ident}_Controller::wakeup()
779{
780 // DEBUG_EXPR(GENERATED_COMP, MedPrio, *this);
781 // DEBUG_EXPR(GENERATED_COMP, MedPrio, g_eventQueue_ptr->getTime());
782
783 int counter = 0;
784 while (true) {
785 // Some cases will put us into an infinite loop without this limit
786 assert(counter <= m_transitions_per_cycle);
787 if (counter == m_transitions_per_cycle) {
788 // Count how often we are fully utilized
789 g_system_ptr->getProfiler()->controllerBusy(m_machineID);
790

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

845
846#define HASH_FUN(state, event) ((int(state)*${ident}_Event_NUM)+int(event))
847
848#define GET_TRANSITION_COMMENT() (${ident}_transitionComment.str())
849#define CLEAR_TRANSITION_COMMENT() (${ident}_transitionComment.str(""))
850
851TransitionResult
852${ident}_Controller::doTransition(${ident}_Event event,
853 ${ident}_State state,
854 const Address &addr)
855{
856 ${ident}_State next_state = state;
857
858 DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n",
859 *this,
860 g_eventQueue_ptr->getTime(),
861 ${ident}_State_to_string(state),
862 ${ident}_Event_to_string(event),
863 addr);
864
865 TransitionResult result =
866 doTransitionWorker(event, state, next_state, addr);
867
868 if (result == TransitionResult_Valid) {
869 DPRINTF(RubyGenerated, "next_state: %s\\n",
870 ${ident}_State_to_string(next_state));
871 m_profiler.countTransition(state, event);
872 DPRINTFR(ProtocolTrace, "%7d %3s %10s%20s %6s>%-6s %s %s\\n",
873 g_eventQueue_ptr->getTime(), m_version, "${ident}",
874 ${ident}_Event_to_string(event),
875 ${ident}_State_to_string(state),
876 ${ident}_State_to_string(next_state),
877 addr, GET_TRANSITION_COMMENT());
878
879 CLEAR_TRANSITION_COMMENT();
880 ${ident}_setState(addr, next_state);
881 } else if (result == TransitionResult_ResourceStall) {
882 DPRINTFR(ProtocolTrace, "%7s %3s %10s%20s %6s>%-6s %s %s\\n",
883 g_eventQueue_ptr->getTime(), m_version, "${ident}",
884 ${ident}_Event_to_string(event),
885 ${ident}_State_to_string(state),
886 ${ident}_State_to_string(next_state),
887 addr, "Resource Stall");
888 } else if (result == TransitionResult_ProtocolStall) {

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

897
898 return result;
899}
900
901TransitionResult
902${ident}_Controller::doTransitionWorker(${ident}_Event event,
903 ${ident}_State state,
904 ${ident}_State& next_state,
905 const Address& addr)
906{
907 switch(HASH_FUN(state, event)) {
908''')
909
910 # This map will allow suppress generating duplicate code
911 cases = orderdict()
912

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

945 for action in actions:
946 if action.ident == "z_stall":
947 stall = True
948 break
949
950 if stall:
951 case('return TransitionResult_ProtocolStall;')
952 else:
953 for action in actions:
954 case('${{action.ident}}(addr);')
955 case('return TransitionResult_Valid;')
956
957 case = str(case)
958
959 # Look to see if this transition code is unique.
960 if case not in cases:
961 cases[case] = []
962

--- 419 unchanged lines hidden ---