summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:43 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2014-09-01 16:55:43 -0500
commit557200725ccf98b50d9fd288e1eb0c5ffc7875ea (patch)
treee9b4a7de833120e79b1b149707a0647eb9641a85 /src
parent6ceb1aadc2d64576c4506657da6b3ba1b7a2d4ea (diff)
downloadgem5-557200725ccf98b50d9fd288e1eb0c5ffc7875ea.tar.xz
ruby: slicc: donot prefix machine name to variables
This changeset does away with prefixing of member variables of state machines with the identity of the machine itself.
Diffstat (limited to 'src')
-rw-r--r--src/mem/protocol/MOESI_CMP_token-L1cache.sm2
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.py2
-rw-r--r--src/mem/slicc/symbols/StateMachine.py106
-rw-r--r--src/mem/slicc/symbols/Var.py7
4 files changed, 59 insertions, 58 deletions
diff --git a/src/mem/protocol/MOESI_CMP_token-L1cache.sm b/src/mem/protocol/MOESI_CMP_token-L1cache.sm
index 2b15dc8bf..238689efa 100644
--- a/src/mem/protocol/MOESI_CMP_token-L1cache.sm
+++ b/src/mem/protocol/MOESI_CMP_token-L1cache.sm
@@ -201,7 +201,7 @@ machine(L1Cache, "Token protocol")
// Constant that provides hysteresis for calculated the estimated average
int averageLatencyHysteresis, default="(8)";
Cycles averageLatencyCounter,
- default="(Cycles(500) << (*m_L1Cache_averageLatencyHysteresis_ptr))";
+ default="(Cycles(500) << (*m_averageLatencyHysteresis_ptr))";
Cycles averageLatencyEstimate() {
DPRINTF(RubySlicc, "%d\n",
diff --git a/src/mem/slicc/ast/ObjDeclAST.py b/src/mem/slicc/ast/ObjDeclAST.py
index 4fd85d143..5cb662fc0 100644
--- a/src/mem/slicc/ast/ObjDeclAST.py
+++ b/src/mem/slicc/ast/ObjDeclAST.py
@@ -70,8 +70,6 @@ class ObjDeclAST(DeclAST):
c_code = "m_machineID"
elif self.ident == "clusterID":
c_code = "m_clusterID"
- elif machine:
- c_code = "(*m_%s_%s_ptr)" % (machine.ident, self.ident)
else:
c_code = "(*m_%s_ptr)" % (self.ident)
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 2a65d3972..6048383a5 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -383,7 +383,7 @@ void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
''')
for var in self.objects:
th = var.get("template", "")
- code('${{var.type.c_ident}}$th* m_${{var.c_ident}}_ptr;')
+ code('${{var.type.c_ident}}$th* m_${{var.ident}}_ptr;')
code.dedent()
code('};')
@@ -488,17 +488,17 @@ $c_ident::$c_ident(const Params *p)
for var in self.objects:
if var.ident.find("mandatoryQueue") >= 0:
code('''
-m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();
-m_${{var.c_ident}}_ptr->setReceiver(this);
+m_${{var.ident}}_ptr = new ${{var.type.c_ident}}();
+m_${{var.ident}}_ptr->setReceiver(this);
''')
else:
if "network" in var and "physical_network" in var and \
var["network"] == "To":
has_peer = True
code('''
-m_${{var.c_ident}}_ptr = new ${{var.type.c_ident}}();
-peerQueueMap[${{var["physical_network"]}}] = m_${{var.c_ident}}_ptr;
-m_${{var.c_ident}}_ptr->setSender(this);
+m_${{var.ident}}_ptr = new ${{var.type.c_ident}}();
+peerQueueMap[${{var["physical_network"]}}] = m_${{var.ident}}_ptr;
+m_${{var.ident}}_ptr->setSender(this);
''')
code('''
@@ -532,7 +532,7 @@ $c_ident::init()
code.indent()
for var in self.objects:
vtype = var.type
- vid = "m_%s_ptr" % var.c_ident
+ vid = "m_%s_ptr" % var.ident
if "network" not in var:
# Not a network port object
if "primitive" in vtype:
@@ -626,7 +626,7 @@ if (m_buffer_size > 0) {
# set description (may be overriden later by port def)
code('''
-$vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.c_ident}}]");
+$vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{var.ident}}]");
''')
@@ -674,7 +674,7 @@ $vid->setDescription("[Version " + to_string(m_version) + ", ${ident}, name=${{v
mq_ident = "NULL"
for port in self.in_ports:
if port.code.find("mandatoryQueue_ptr") >= 0:
- mq_ident = "m_%s_mandatoryQueue_ptr" % self.ident
+ mq_ident = "m_mandatoryQueue_ptr"
seq_ident = "NULL"
for param in self.config_parameters:
@@ -955,7 +955,7 @@ $c_ident::functionalReadBuffers(PacketPtr& pkt)
for var in self.objects:
vtype = var.type
if vtype.isBuffer:
- vid = "m_%s_ptr" % var.c_ident
+ vid = "m_%s_ptr" % var.ident
code('if ($vid->functionalRead(pkt)) { return true; }')
code('''
return false;
@@ -972,7 +972,7 @@ $c_ident::functionalWriteBuffers(PacketPtr& pkt)
for var in self.objects:
vtype = var.type
if vtype.isBuffer:
- vid = "m_%s_ptr" % var.c_ident
+ vid = "m_%s_ptr" % var.ident
code('num_functional_writes += $vid->functionalWrite(pkt);')
code('''
return num_functional_writes;
@@ -992,9 +992,9 @@ $c_ident::getQueuesFromPeer(AbstractController *peer)
if "network" in var and "physical_network" in var and \
var["network"] == "From":
code('''
-m_${{var.c_ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}});
-assert(m_${{var.c_ident}}_ptr != NULL);
-m_${{var.c_ident}}_ptr->setReceiver(this);
+m_${{var.ident}}_ptr = peer->getPeerQueue(${{var["physical_network"]}});
+assert(m_${{var.ident}}_ptr != NULL);
+m_${{var.ident}}_ptr->setReceiver(this);
''')
code('}')
@@ -1131,6 +1131,8 @@ ${ident}_Controller::doTransition(${ident}_Event event,
const Address addr)
{
''')
+ code.indent()
+
if self.TBEType != None and self.EntryType != None:
code('${ident}_State state = getState(m_tbe_ptr, m_cache_entry_ptr, addr);')
elif self.TBEType != None:
@@ -1141,13 +1143,13 @@ ${ident}_Controller::doTransition(${ident}_Event event,
code('${ident}_State state = getState(addr);')
code('''
- ${ident}_State next_state = state;
+${ident}_State next_state = state;
- DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n",
- *this, curCycle(), ${ident}_State_to_string(state),
- ${ident}_Event_to_string(event), addr);
+DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n",
+ *this, curCycle(), ${ident}_State_to_string(state),
+ ${ident}_Event_to_string(event), addr);
- TransitionResult result =
+TransitionResult result =
''')
if self.TBEType != None and self.EntryType != None:
code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);')
@@ -1159,18 +1161,20 @@ ${ident}_Controller::doTransition(${ident}_Event event,
code('doTransitionWorker(event, state, next_state, addr);')
code('''
- if (result == TransitionResult_Valid) {
- DPRINTF(RubyGenerated, "next_state: %s\\n",
- ${ident}_State_to_string(next_state));
- countTransition(state, event);
- DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n",
- curTick(), m_version, "${ident}",
- ${ident}_Event_to_string(event),
- ${ident}_State_to_string(state),
- ${ident}_State_to_string(next_state),
- addr, GET_TRANSITION_COMMENT());
-
- CLEAR_TRANSITION_COMMENT();
+
+if (result == TransitionResult_Valid) {
+ DPRINTF(RubyGenerated, "next_state: %s\\n",
+ ${ident}_State_to_string(next_state));
+ countTransition(state, event);
+
+ DPRINTFR(ProtocolTrace, "%15d %3s %10s%20s %6s>%-6s %s %s\\n",
+ curTick(), m_version, "${ident}",
+ ${ident}_Event_to_string(event),
+ ${ident}_State_to_string(state),
+ ${ident}_State_to_string(next_state),
+ addr, GET_TRANSITION_COMMENT());
+
+ CLEAR_TRANSITION_COMMENT();
''')
if self.TBEType != None and self.EntryType != None:
code('setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);')
@@ -1186,24 +1190,27 @@ ${ident}_Controller::doTransition(${ident}_Event event,
code('setAccessPermission(addr, next_state);')
code('''
- } else if (result == TransitionResult_ResourceStall) {
- DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n",
- curTick(), m_version, "${ident}",
- ${ident}_Event_to_string(event),
- ${ident}_State_to_string(state),
- ${ident}_State_to_string(next_state),
- addr, "Resource Stall");
- } else if (result == TransitionResult_ProtocolStall) {
- DPRINTF(RubyGenerated, "stalling\\n");
- DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n",
- curTick(), m_version, "${ident}",
- ${ident}_Event_to_string(event),
- ${ident}_State_to_string(state),
- ${ident}_State_to_string(next_state),
- addr, "Protocol Stall");
- }
+} else if (result == TransitionResult_ResourceStall) {
+ DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n",
+ curTick(), m_version, "${ident}",
+ ${ident}_Event_to_string(event),
+ ${ident}_State_to_string(state),
+ ${ident}_State_to_string(next_state),
+ addr, "Resource Stall");
+} else if (result == TransitionResult_ProtocolStall) {
+ DPRINTF(RubyGenerated, "stalling\\n");
+ DPRINTFR(ProtocolTrace, "%15s %3s %10s%20s %6s>%-6s %s %s\\n",
+ curTick(), m_version, "${ident}",
+ ${ident}_Event_to_string(event),
+ ${ident}_State_to_string(state),
+ ${ident}_State_to_string(next_state),
+ addr, "Protocol Stall");
+}
- return result;
+return result;
+''')
+ code.dedent()
+ code('''
}
TransitionResult
@@ -1310,7 +1317,7 @@ if (!checkResourceAvailable(%s_RequestType_%s, addr)) {
# the same code
for trans in transitions:
code(' case HASH_FUN($trans):')
- code(' $case')
+ code(' $case\n')
code('''
default:
@@ -1318,6 +1325,7 @@ if (!checkResourceAvailable(%s_RequestType_%s, addr)) {
"%s time: %d addr: %s event: %s state: %s\\n",
name(), curCycle(), addr, event, state);
}
+
return TransitionResult_Valid;
}
''')
diff --git a/src/mem/slicc/symbols/Var.py b/src/mem/slicc/symbols/Var.py
index e16199a1e..2a4ef23db 100644
--- a/src/mem/slicc/symbols/Var.py
+++ b/src/mem/slicc/symbols/Var.py
@@ -32,17 +32,12 @@ class Var(Symbol):
machine=None):
super(Var, self).__init__(symtab, ident, location, pairs)
- if machine:
- self.c_ident = "%s_%s" % (machine, ident)
- else:
- self.c_ident = ident
-
self.machine = machine
self.type = type
self.code = code
def __repr__(self):
- return "[Var id: %s]" % (self.c_ident)
+ return "[Var id: %s]" % (self.ident)
def writeCodeFiles(self, path, includes):
pass