StateMachine.py (10304:a2f88c6d9e54) | StateMachine.py (10305:76745b567dc3) |
---|---|
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; --- 369 unchanged lines hidden (view full) --- 378 379 # the controller internal variables 380 code(''' 381 382// Objects 383''') 384 for var in self.objects: 385 th = var.get("template", "") | 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; --- 369 unchanged lines hidden (view full) --- 378 379 # the controller internal variables 380 code(''' 381 382// Objects 383''') 384 for var in self.objects: 385 th = var.get("template", "") |
386 code('${{var.type.c_ident}}$th* m_${{var.c_ident}}_ptr;') | 386 code('${{var.type.c_ident}}$th* m_${{var.ident}}_ptr;') |
387 388 code.dedent() 389 code('};') 390 code('#endif // __${ident}_CONTROLLER_H__') 391 code.write(path, '%s.hh' % c_ident) 392 393 def printControllerCC(self, path, includes): 394 '''Output the actions for performing the actions''' --- 88 unchanged lines hidden (view full) --- 483 else: 484 code('m_${{param.name}} = p->${{param.name}};') 485 if re.compile("sequencer").search(param.name): 486 code('m_${{param.name}}_ptr->setController(this);') 487 488 for var in self.objects: 489 if var.ident.find("mandatoryQueue") >= 0: 490 code(''' | 387 388 code.dedent() 389 code('};') 390 code('#endif // __${ident}_CONTROLLER_H__') 391 code.write(path, '%s.hh' % c_ident) 392 393 def printControllerCC(self, path, includes): 394 '''Output the actions for performing the actions''' --- 88 unchanged lines hidden (view full) --- 483 else: 484 code('m_${{param.name}} = p->${{param.name}};') 485 if re.compile("sequencer").search(param.name): 486 code('m_${{param.name}}_ptr->setController(this);') 487 488 for var in self.objects: 489 if var.ident.find("mandatoryQueue") >= 0: 490 code(''' |
491m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 492m_${{var.c_ident}}_ptr->setReceiver(this); | 491m_${{var.ident}}_ptr = new ${{var.type.c_ident}}(); 492m_${{var.ident}}_ptr->setReceiver(this); |
493''') 494 else: 495 if "network" in var and "physical_network" in var and \ 496 var["network"] == "To": 497 has_peer = True 498 code(''' | 493''') 494 else: 495 if "network" in var and "physical_network" in var and \ 496 var["network"] == "To": 497 has_peer = True 498 code(''' |
499m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}(); 500peerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr; 501m_${{var.c_ident}}_ptr->setSender(this); | 499m_${{var.ident}}_ptr = new ${{var.type.c_ident}}(); 500peerQueueMap[${{var["physical_network"]}}] = m_${{var.ident}}_ptr; 501m_${{var.ident}}_ptr->setSender(this); |
502''') 503 504 code(''' 505if (p->peer != NULL) 506 connectWithPeer(p->peer); 507 508for (int state = 0; state < ${ident}_State_NUM; state++) { 509 for (int event = 0; event < ${ident}_Event_NUM; event++) { --- 17 unchanged lines hidden (view full) --- 527 528 // initialize objects 529 530''') 531 532 code.indent() 533 for var in self.objects: 534 vtype = var.type | 502''') 503 504 code(''' 505if (p->peer != NULL) 506 connectWithPeer(p->peer); 507 508for (int state = 0; state < ${ident}_State_NUM; state++) { 509 for (int event = 0; event < ${ident}_Event_NUM; event++) { --- 17 unchanged lines hidden (view full) --- 527 528 // initialize objects 529 530''') 531 532 code.indent() 533 for var in self.objects: 534 vtype = var.type |
535 vid = "m_%s_ptr" % var.c_ident | 535 vid = "m_%s_ptr" % var.ident |
536 if "network" not in var: 537 # Not a network port object 538 if "primitive" in vtype: 539 code('$vid = new ${{vtype.c_ident}};') 540 if "default" in var: 541 code('(*$vid) = ${{var["default"]}};') 542 else: 543 # Normal Object --- 77 unchanged lines hidden (view full) --- 621 code(''' 622if (m_buffer_size > 0) { 623 $vid->resize(m_buffer_size); 624} 625''') 626 627 # set description (may be overriden later by port def) 628 code(''' | 536 if "network" not in var: 537 # Not a network port object 538 if "primitive" in vtype: 539 code('$vid = new ${{vtype.c_ident}};') 540 if "default" in var: 541 code('(*$vid) = ${{var["default"]}};') 542 else: 543 # Normal Object --- 77 unchanged lines hidden (view full) --- 621 code(''' 622if (m_buffer_size > 0) { 623 $vid->resize(m_buffer_size); 624} 625''') 626 627 # set description (may be overriden later by port def) 628 code(''' |
629$vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.c_ident}}]"); | 629$vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.ident}}]"); |
630 631''') 632 633 if vtype.isBuffer: 634 if "recycle_latency" in var: 635 code('$vid->setRecycleLatency( ' \ 636 'Cycles(${{var["recycle_latency"]}}));') 637 else: --- 31 unchanged lines hidden (view full) --- 669 AbstractController::init(); 670 resetStats(); 671} 672''') 673 674 mq_ident = "NULL" 675 for port in self.in_ports: 676 if port.code.find("mandatoryQueue_ptr") >= 0: | 630 631''') 632 633 if vtype.isBuffer: 634 if "recycle_latency" in var: 635 code('$vid->setRecycleLatency( ' \ 636 'Cycles(${{var["recycle_latency"]}}));') 637 else: --- 31 unchanged lines hidden (view full) --- 669 AbstractController::init(); 670 resetStats(); 671} 672''') 673 674 mq_ident = "NULL" 675 for port in self.in_ports: 676 if port.code.find("mandatoryQueue_ptr") >= 0: |
677 mq_ident = "m_%s_mandatoryQueue_ptr" % self.ident | 677 mq_ident = "m_mandatoryQueue_ptr" |
678 679 seq_ident = "NULL" 680 for param in self.config_parameters: 681 if param.name == "sequencer": 682 assert(param.pointer) 683 seq_ident = "m_%s_ptr" % param.name 684 685 code(''' --- 264 unchanged lines hidden (view full) --- 950 code(''' 951bool 952$c_ident::functionalReadBuffers(PacketPtr& pkt) 953{ 954''') 955 for var in self.objects: 956 vtype = var.type 957 if vtype.isBuffer: | 678 679 seq_ident = "NULL" 680 for param in self.config_parameters: 681 if param.name == "sequencer": 682 assert(param.pointer) 683 seq_ident = "m_%s_ptr" % param.name 684 685 code(''' --- 264 unchanged lines hidden (view full) --- 950 code(''' 951bool 952$c_ident::functionalReadBuffers(PacketPtr& pkt) 953{ 954''') 955 for var in self.objects: 956 vtype = var.type 957 if vtype.isBuffer: |
958 vid = "m_%s_ptr" % var.c_ident | 958 vid = "m_%s_ptr" % var.ident |
959 code('if ($vid->functionalRead(pkt)) { return true; }') 960 code(''' 961 return false; 962} 963''') 964 965 # Function for functional writes to messages buffered in the controller 966 code(''' 967uint32_t 968$c_ident::functionalWriteBuffers(PacketPtr& pkt) 969{ 970 uint32_t num_functional_writes = 0; 971''') 972 for var in self.objects: 973 vtype = var.type 974 if vtype.isBuffer: | 959 code('if ($vid->functionalRead(pkt)) { return true; }') 960 code(''' 961 return false; 962} 963''') 964 965 # Function for functional writes to messages buffered in the controller 966 code(''' 967uint32_t 968$c_ident::functionalWriteBuffers(PacketPtr& pkt) 969{ 970 uint32_t num_functional_writes = 0; 971''') 972 for var in self.objects: 973 vtype = var.type 974 if vtype.isBuffer: |
975 vid = "m_%s_ptr" % var.c_ident | 975 vid = "m_%s_ptr" % var.ident |
976 code('num_functional_writes += $vid->functionalWrite(pkt);') 977 code(''' 978 return num_functional_writes; 979} 980''') 981 982 # Check if this controller has a peer, if yes then write the 983 # function for connecting to the peer. 984 if has_peer: 985 code(''' 986 987void 988$c_ident::getQueuesFromPeer(AbstractController *peer) 989{ 990''') 991 for var in self.objects: 992 if "network" in var and "physical_network" in var and \ 993 var["network"] == "From": 994 code(''' | 976 code('num_functional_writes += $vid->functionalWrite(pkt);') 977 code(''' 978 return num_functional_writes; 979} 980''') 981 982 # Check if this controller has a peer, if yes then write the 983 # function for connecting to the peer. 984 if has_peer: 985 code(''' 986 987void 988$c_ident::getQueuesFromPeer(AbstractController *peer) 989{ 990''') 991 for var in self.objects: 992 if "network" in var and "physical_network" in var and \ 993 var["network"] == "From": 994 code(''' |
995m_${{var.c_ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}}); 996assert(m_${{var.c_ident}}_ptr != NULL); 997m_${{var.c_ident}}_ptr->setReceiver(this); | 995m_${{var.ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}}); 996assert(m_${{var.ident}}_ptr != NULL); 997m_${{var.ident}}_ptr->setReceiver(this); |
998 999''') 1000 code('}') 1001 1002 code.write(path, "%s.cc" % c_ident) 1003 1004 def printCWakeup(self, path, includes): 1005 '''Output the wakeup loop for the events''' --- 120 unchanged lines hidden (view full) --- 1126 if self.TBEType != None: 1127 code(''' 1128 ${{self.TBEType.c_ident}}* m_tbe_ptr, 1129''') 1130 code(''' 1131 const Address addr) 1132{ 1133''') | 998 999''') 1000 code('}') 1001 1002 code.write(path, "%s.cc" % c_ident) 1003 1004 def printCWakeup(self, path, includes): 1005 '''Output the wakeup loop for the events''' --- 120 unchanged lines hidden (view full) --- 1126 if self.TBEType != None: 1127 code(''' 1128 ${{self.TBEType.c_ident}}* m_tbe_ptr, 1129''') 1130 code(''' 1131 const Address addr) 1132{ 1133''') |
1134 code.indent() 1135 |
|
1134 if self.TBEType != None and self.EntryType != None: 1135 code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);') 1136 elif self.TBEType != None: 1137 code('${ident}_State state = getState(m_tbe_ptr, addr);') 1138 elif self.EntryType != None: 1139 code('${ident}_State state = getState(m_cache_entry_ptr, addr);') 1140 else: 1141 code('${ident}_State state = getState(addr);') 1142 1143 code(''' | 1136 if self.TBEType != None and self.EntryType != None: 1137 code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);') 1138 elif self.TBEType != None: 1139 code('${ident}_State state = getState(m_tbe_ptr, addr);') 1140 elif self.EntryType != None: 1141 code('${ident}_State state = getState(m_cache_entry_ptr, addr);') 1142 else: 1143 code('${ident}_State state = getState(addr);') 1144 1145 code(''' |
1144 ${ident}_State next_state = state; | 1146${ident}_State next_state = state; |
1145 | 1147 |
1146 DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n", 1147 *this, curCycle(), ${ident}_State_to_string(state), 1148 ${ident}_Event_to_string(event), addr); | 1148DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n", 1149 *this, curCycle(), ${ident}_State_to_string(state), 1150 ${ident}_Event_to_string(event), addr); |
1149 | 1151 |
1150 TransitionResult result = | 1152TransitionResult result = |
1151''') 1152 if self.TBEType != None and self.EntryType != None: 1153 code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);') 1154 elif self.TBEType != None: 1155 code('doTransitionWorker(event, state, next_state, m_tbe_ptr, addr);') 1156 elif self.EntryType != None: 1157 code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);') 1158 else: 1159 code('doTransitionWorker(event, state, next_state, addr);') 1160 1161 code(''' | 1153''') 1154 if self.TBEType != None and self.EntryType != None: 1155 code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);') 1156 elif self.TBEType != None: 1157 code('doTransitionWorker(event, state, next_state, m_tbe_ptr, addr);') 1158 elif self.EntryType != None: 1159 code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);') 1160 else: 1161 code('doTransitionWorker(event, state, next_state, addr);') 1162 1163 code(''' |
1162 if (result == TransitionResult_Valid) { 1163 DPRINTF(RubyGenerated, "next_state: %s\\n", 1164 ${ident}_State_to_string(next_state)); 1165 countTransition(state, event); 1166 DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n", 1167 curTick(), m_version, "${ident}", 1168 ${ident}_Event_to_string(event), 1169 ${ident}_State_to_string(state), 1170 ${ident}_State_to_string(next_state), 1171 addr, GET_TRANSITION_COMMENT()); | |
1172 | 1164 |
1173 CLEAR_TRANSITION_COMMENT(); | 1165if (result == TransitionResult_Valid) { 1166 DPRINTF(RubyGenerated, "next_state: %s\\n", 1167 ${ident}_State_to_string(next_state)); 1168 countTransition(state, event); 1169 1170 DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n", 1171 curTick(), m_version, "${ident}", 1172 ${ident}_Event_to_string(event), 1173 ${ident}_State_to_string(state), 1174 ${ident}_State_to_string(next_state), 1175 addr, GET_TRANSITION_COMMENT()); 1176 1177 CLEAR_TRANSITION_COMMENT(); |
1174''') 1175 if self.TBEType != None and self.EntryType != None: 1176 code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);') 1177 code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 1178 elif self.TBEType != None: 1179 code('setState(m_tbe_ptr, addr, next_state);') 1180 code('setAccessPermission(addr, next_state);') 1181 elif self.EntryType != None: 1182 code('setState(m_cache_entry_ptr, addr, next_state);') 1183 code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 1184 else: 1185 code('setState(addr, next_state);') 1186 code('setAccessPermission(addr, next_state);') 1187 1188 code(''' | 1178''') 1179 if self.TBEType != None and self.EntryType != None: 1180 code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);') 1181 code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 1182 elif self.TBEType != None: 1183 code('setState(m_tbe_ptr, addr, next_state);') 1184 code('setAccessPermission(addr, next_state);') 1185 elif self.EntryType != None: 1186 code('setState(m_cache_entry_ptr, addr, next_state);') 1187 code('setAccessPermission(m_cache_entry_ptr, addr, next_state);') 1188 else: 1189 code('setState(addr, next_state);') 1190 code('setAccessPermission(addr, next_state);') 1191 1192 code(''' |
1189 } else if (result == TransitionResult_ResourceStall) { 1190 DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 1191 curTick(), m_version, "${ident}", 1192 ${ident}_Event_to_string(event), 1193 ${ident}_State_to_string(state), 1194 ${ident}_State_to_string(next_state), 1195 addr, "Resource Stall"); 1196 } else if (result == TransitionResult_ProtocolStall) { 1197 DPRINTF(RubyGenerated, "stalling\\n"); 1198 DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 1199 curTick(), m_version, "${ident}", 1200 ${ident}_Event_to_string(event), 1201 ${ident}_State_to_string(state), 1202 ${ident}_State_to_string(next_state), 1203 addr, "Protocol Stall"); 1204 } | 1193} else if (result == TransitionResult_ResourceStall) { 1194 DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 1195 curTick(), m_version, "${ident}", 1196 ${ident}_Event_to_string(event), 1197 ${ident}_State_to_string(state), 1198 ${ident}_State_to_string(next_state), 1199 addr, "Resource Stall"); 1200} else if (result == TransitionResult_ProtocolStall) { 1201 DPRINTF(RubyGenerated, "stalling\\n"); 1202 DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n", 1203 curTick(), m_version, "${ident}", 1204 ${ident}_Event_to_string(event), 1205 ${ident}_State_to_string(state), 1206 ${ident}_State_to_string(next_state), 1207 addr, "Protocol Stall"); 1208} |
1205 | 1209 |
1206 return result; | 1210return result; 1211''') 1212 code.dedent() 1213 code(''' |
1207} 1208 1209TransitionResult 1210${ident}_Controller::doTransitionWorker(${ident}_Event event, 1211 ${ident}_State state, 1212 ${ident}_State& next_state, 1213''') 1214 --- 90 unchanged lines hidden (view full) --- 1305 1306 # Walk through all of the unique code blocks and spit out the 1307 # corresponding case statement elements 1308 for case,transitions in cases.iteritems(): 1309 # Iterative over all the multiple transitions that share 1310 # the same code 1311 for trans in transitions: 1312 code(' case HASH_FUN($trans):') | 1214} 1215 1216TransitionResult 1217${ident}_Controller::doTransitionWorker(${ident}_Event event, 1218 ${ident}_State state, 1219 ${ident}_State& next_state, 1220''') 1221 --- 90 unchanged lines hidden (view full) --- 1312 1313 # Walk through all of the unique code blocks and spit out the 1314 # corresponding case statement elements 1315 for case,transitions in cases.iteritems(): 1316 # Iterative over all the multiple transitions that share 1317 # the same code 1318 for trans in transitions: 1319 code(' case HASH_FUN($trans):') |
1313 code(' $case') | 1320 code(' $case\n') |
1314 1315 code(''' 1316 default: 1317 fatal("Invalid transition\\n" 1318 "%s time: %d addr: %s event: %s state: %s\\n", 1319 name(), curCycle(), addr, event, state); 1320 } | 1321 1322 code(''' 1323 default: 1324 fatal("Invalid transition\\n" 1325 "%s time: %d addr: %s event: %s state: %s\\n", 1326 name(), curCycle(), addr, event, state); 1327 } |
1328 |
|
1321 return TransitionResult_Valid; 1322} 1323''') 1324 code.write(path, "%s_Transitions.cc" % self.ident) 1325 1326 1327 # ************************** 1328 # ******* HTML Files ******* --- 178 unchanged lines hidden --- | 1329 return TransitionResult_Valid; 1330} 1331''') 1332 code.write(path, "%s_Transitions.cc" % self.ident) 1333 1334 1335 # ************************** 1336 # ******* HTML Files ******* --- 178 unchanged lines hidden --- |