diff --git a/src/mem/ruby/slicc_interface/AbstractCacheEntry.hh b/src/mem/ruby/slicc_interface/AbstractCacheEntry.hh
--- a/src/mem/ruby/slicc_interface/AbstractCacheEntry.hh
+++ b/src/mem/ruby/slicc_interface/AbstractCacheEntry.hh
@@ -48,11 +48,17 @@
AbstractCacheEntry();
virtual ~AbstractCacheEntry() = 0;
+ // Get/Set permission of cache entry
+ AccessPermission getPermission() const;
+ void changePermission(AccessPermission new_perm);
+
Address m_Address; // Address of this block, required by CacheMemory
Time m_LastRef; // Last time this block was referenced, required
// by CacheMemory
AccessPermission m_Permission; // Access permission for this
// block, required by CacheMemory
+ int m_locked; // Holds info whether the address is locked,
+ // required for implementing LL/SC
};
inline std::ostream&
@@ -64,4 +70,3 @@
}
#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCACHEENTRY_HH__
-
diff --git a/src/mem/ruby/slicc_interface/AbstractCacheEntry.cc b/src/mem/ruby/slicc_interface/AbstractCacheEntry.cc
--- a/src/mem/ruby/slicc_interface/AbstractCacheEntry.cc
+++ b/src/mem/ruby/slicc_interface/AbstractCacheEntry.cc
@@ -32,9 +32,26 @@
{
m_Address.setAddress(0);
m_Permission = AccessPermission_NotPresent;
+ m_locked = -1;
}
AbstractCacheEntry::~AbstractCacheEntry()
{
}
+AccessPermission
+AbstractCacheEntry::getPermission() const
+{
+ return m_Permission;
+}
+
+void
+AbstractCacheEntry::changePermission(AccessPermission new_perm)
+{
+ m_Permission = new_perm;
+ if ((new_perm == AccessPermission_Invalid) ||
+ (new_perm == AccessPermission_NotPresent) ||
+ (new_perm == AccessPermission_Stale)) {
+ m_locked = -1;
+ }
+}
diff --git a/src/mem/ruby/system/CacheMemory.hh b/src/mem/ruby/system/CacheMemory.hh
--- a/src/mem/ruby/system/CacheMemory.hh
+++ b/src/mem/ruby/system/CacheMemory.hh
@@ -82,7 +82,7 @@
bool cacheAvail(const Address& address) const;
// find an unused entry and sets the tag appropriate for the address
- void allocate(const Address& address, AbstractCacheEntry* new_entry);
+ AbstractCacheEntry* allocate(const Address& address, AbstractCacheEntry* new_entry);
// Explicitly free up this address
void deallocate(const Address& address);
@@ -91,12 +91,8 @@
Address cacheProbe(const Address& address) const;
// looks an address up in the cache
- AbstractCacheEntry& lookup(const Address& address);
- const AbstractCacheEntry& lookup(const Address& address) const;
-
- // Get/Set permission of cache block
- AccessPermission getPermission(const Address& address) const;
- void changePermission(const Address& address, AccessPermission new_perm);
+ AbstractCacheEntry* lookup(const Address& address);
+ const AbstractCacheEntry* lookup(const Address& address) const;
int getLatency() const { return m_latency; }
@@ -158,7 +154,6 @@
// The second index is the the amount associativity.
m5::hash_map
m_tag_index;
std::vector > m_cache;
- std::vector > m_locked;
AbstractReplacementPolicy *m_replacementPolicy_ptr;
diff --git a/src/mem/ruby/system/CacheMemory.cc b/src/mem/ruby/system/CacheMemory.cc
--- a/src/mem/ruby/system/CacheMemory.cc
+++ b/src/mem/ruby/system/CacheMemory.cc
@@ -75,13 +75,10 @@
assert(false);
m_cache.resize(m_cache_num_sets);
- m_locked.resize(m_cache_num_sets);
for (int i = 0; i < m_cache_num_sets; i++) {
m_cache[i].resize(m_cache_assoc);
- m_locked[i].resize(m_cache_assoc);
for (int j = 0; j < m_cache_assoc; j++) {
m_cache[i][j] = NULL;
- m_locked[i][j] = -1;
}
}
}
@@ -255,7 +252,7 @@
return false;
}
-void
+AbstractCacheEntry*
CacheMemory::allocate(const Address& address, AbstractCacheEntry* entry)
{
assert(address == line_address(address));
@@ -273,13 +270,13 @@
set[i]->m_Permission = AccessPermission_Invalid;
DPRINTF(RubyCache, "Allocate clearing lock for addr: %x\n",
address);
- m_locked[cacheSet][i] = -1;
+ set[i]->m_locked = -1;
m_tag_index[address] = i;
m_replacementPolicy_ptr->
touch(cacheSet, i, g_eventQueue_ptr->getTime());
- return;
+ return entry;
}
}
panic("Allocate didn't find an available entry");
@@ -296,9 +293,6 @@
if (loc != -1) {
delete m_cache[cacheSet][loc];
m_cache[cacheSet][loc] = NULL;
- DPRINTF(RubyCache, "Deallocate clearing lock for addr: %x\n",
- address);
- m_locked[cacheSet][loc] = -1;
m_tag_index.erase(address);
}
}
@@ -316,49 +310,25 @@
}
// looks an address up in the cache
-AbstractCacheEntry&
+AbstractCacheEntry*
CacheMemory::lookup(const Address& address)
{
assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
- assert(loc != -1);
- return *m_cache[cacheSet][loc];
+ if(loc == -1) return NULL;
+ return m_cache[cacheSet][loc];
}
// looks an address up in the cache
-const AbstractCacheEntry&
+const AbstractCacheEntry*
CacheMemory::lookup(const Address& address) const
{
assert(address == line_address(address));
Index cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
- assert(loc != -1);
- return *m_cache[cacheSet][loc];
-}
-
-AccessPermission
-CacheMemory::getPermission(const Address& address) const
-{
- assert(address == line_address(address));
- return lookup(address).m_Permission;
-}
-
-void
-CacheMemory::changePermission(const Address& address,
- AccessPermission new_perm)
-{
- assert(address == line_address(address));
- lookup(address).m_Permission = new_perm;
- Index cacheSet = addressToCacheSet(address);
- int loc = findTagInSet(cacheSet, address);
- if ((new_perm == AccessPermission_Invalid) ||
- (new_perm == AccessPermission_NotPresent) ||
- (new_perm == AccessPermission_Stale)) {
- DPRINTF(RubyCache, "Permission clearing lock for addr: %x\n", address);
- m_locked[cacheSet][loc] = -1;
- }
- assert(getPermission(address) == new_perm);
+ if(loc == -1) return NULL;
+ return m_cache[cacheSet][loc];
}
// Sets the most recently used bit for a cache block
@@ -460,10 +430,10 @@
CacheMemory::getMemoryValue(const Address& addr, char* value,
unsigned size_in_bytes)
{
- AbstractCacheEntry& entry = lookup(line_address(addr));
+ AbstractCacheEntry* entry = lookup(line_address(addr));
unsigned startByte = addr.getAddress() - line_address(addr).getAddress();
for (unsigned i = 0; i < size_in_bytes; ++i) {
- value[i] = entry.getDataBlk().getByte(i + startByte);
+ value[i] = entry->getDataBlk().getByte(i + startByte);
}
}
@@ -471,11 +441,11 @@
CacheMemory::setMemoryValue(const Address& addr, char* value,
unsigned size_in_bytes)
{
- AbstractCacheEntry& entry = lookup(line_address(addr));
+ AbstractCacheEntry* entry = lookup(line_address(addr));
unsigned startByte = addr.getAddress() - line_address(addr).getAddress();
assert(size_in_bytes > 0);
for (unsigned i = 0; i < size_in_bytes; ++i) {
- entry.getDataBlk().setByte(i + startByte, value[i]);
+ entry->getDataBlk().setByte(i + startByte, value[i]);
}
// entry = lookup(line_address(addr));
@@ -489,7 +459,7 @@
Index cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
- m_locked[cacheSet][loc] = context;
+ m_cache[cacheSet][loc]->m_locked = context;
}
void
@@ -500,7 +470,7 @@
Index cacheSet = addressToCacheSet(address);
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
- m_locked[cacheSet][loc] = -1;
+ m_cache[cacheSet][loc]->m_locked = -1;
}
bool
@@ -511,7 +481,7 @@
int loc = findTagInSet(cacheSet, address);
assert(loc != -1);
DPRINTF(RubyCache, "Testing Lock for addr: %llx cur %d con %d\n",
- address, m_locked[cacheSet][loc], context);
- return m_locked[cacheSet][loc] == context;
+ address, m_cache[cacheSet][loc]->m_locked, context);
+ return m_cache[cacheSet][loc]->m_locked == context;
}
diff --git a/src/mem/ruby/system/TBETable.hh b/src/mem/ruby/system/TBETable.hh
--- a/src/mem/ruby/system/TBETable.hh
+++ b/src/mem/ruby/system/TBETable.hh
@@ -61,8 +61,7 @@
return (m_number_of_TBEs - m_map.size()) >= n;
}
- ENTRY& lookup(const Address& address);
- const ENTRY& lookup(const Address& address) const;
+ ENTRY* lookup(const Address& address);
// Print cache contents
void print(std::ostream& out) const;
@@ -117,21 +116,13 @@
// looks an address up in the cache
template
-inline ENTRY&
+inline ENTRY*
TBETable::lookup(const Address& address)
{
- assert(isPresent(address));
- return m_map.find(address)->second;
+ if(m_map.find(address) != m_map.end()) return &(m_map.find(address)->second);
+ return NULL;
}
-// looks an address up in the cache
-template
-inline const ENTRY&
-TBETable::lookup(const Address& address) const
-{
- assert(isPresent(address));
- return m_map.find(address)->second;
-}
template
inline void
diff --git a/src/mem/slicc/ast/ActionDeclAST.py b/src/mem/slicc/ast/ActionDeclAST.py
--- a/src/mem/slicc/ast/ActionDeclAST.py
+++ b/src/mem/slicc/ast/ActionDeclAST.py
@@ -39,6 +39,11 @@
def generate(self):
resources = {}
+
+ machine = self.symtab.state_machine
+ if machine is None:
+ self.error("Action declaration not part of a machine.")
+
if self.statement_list:
# Add new local vars
self.symtab.pushFrame()
@@ -52,6 +57,16 @@
"addr", self.pairs)
self.symtab.newSymbol(var)
+ if machine.TBEType != None:
+ var = Var(self.symtab, "tbe", self.location, machine.TBEType,
+ "(*m_tbe_ptr)", self.pairs)
+ self.symtab.newSymbol(var)
+
+ if machine.EntryType != None:
+ var = Var(self.symtab, "cache_entry", self.location,
+ machine.EntryType, "(*m_cache_entry_ptr)", self.pairs)
+ self.symtab.newSymbol(var)
+
# Do not allows returns in actions
code = self.slicc.codeFormatter()
self.statement_list.generate(code, None)
@@ -61,10 +76,6 @@
self.symtab.popFrame()
- machine = self.symtab.state_machine
- if machine is None:
- self.error("Action declaration not part of a machine.")
-
action = Action(self.symtab, self.ident, resources, self.location,
self.pairs)
machine.addAction(action)
diff --git a/src/mem/slicc/ast/FormalParamAST.py b/src/mem/slicc/ast/FormalParamAST.py
--- a/src/mem/slicc/ast/FormalParamAST.py
+++ b/src/mem/slicc/ast/FormalParamAST.py
@@ -48,7 +48,17 @@
param = "param_%s" % self.ident
# Add to symbol table
- v = Var(self.symtab, self.ident, self.location, type, param,
- self.pairs)
- self.symtab.newSymbol(v)
+ if self.pointer or str(type) == "TBE" or (
+ "interface" in type and type["interface"] == "AbstractCacheEntry"):
+
+ v = Var(self.symtab, self.ident, self.location, type,
+ "(*%s)" % param, self.pairs)
+ self.symtab.newSymbol(v)
+ return type, "%s* %s" % (type.c_ident, param)
+
+ else:
+ v = Var(self.symtab, self.ident, self.location, type, param,
+ self.pairs)
+ self.symtab.newSymbol(v)
+
return type, "%s %s" % (type.c_ident, param)
diff --git a/src/mem/slicc/ast/FuncCallExprAST.py b/src/mem/slicc/ast/FuncCallExprAST.py
--- a/src/mem/slicc/ast/FuncCallExprAST.py
+++ b/src/mem/slicc/ast/FuncCallExprAST.py
@@ -89,6 +89,7 @@
len(func.param_types), len(self.exprs))
cvec = []
+ type_vec = []
for expr,expected_type in zip(self.exprs, func.param_types):
# Check the types of the parameter
actual_type,param_code = expr.inline(True)
@@ -96,6 +97,7 @@
expr.error("Type mismatch: expected: %s actual: %s" % \
(expected_type, actual_type))
cvec.append(param_code)
+ type_vec.append(expected_type)
# OK, the semantics of "trigger" here is that, ports in the
# machine have different priorities. We always check the first
@@ -115,8 +117,25 @@
code('''
{
Address addr = ${{cvec[1]}};
- TransitionResult result = doTransition(${{cvec[0]}}, ${machine}_getState(addr), addr);
+''')
+ if machine.TBEType != None and machine.EntryType != None:
+ code('''
+ TransitionResult result = doTransition(${{cvec[0]}}, m_tbe_ptr, m_cache_entry_ptr, addr);
+''')
+ elif machine.TBEType != None:
+ code('''
+ TransitionResult result = doTransition(${{cvec[0]}}, m_tbe_ptr, addr);
+''')
+ elif machine.EntryType != None:
+ code('''
+ TransitionResult result = doTransition(${{cvec[0]}}, m_cache_entry_ptr, addr);
+''')
+ else:
+ code('''
+ TransitionResult result = doTransition(${{cvec[0]}}, addr);
+''')
+ code('''
if (result == TransitionResult_Valid) {
counter++;
continue; // Check the first port again
@@ -175,6 +194,16 @@
elif self.proc_name == "continueProcessing":
code("counter++;")
code("continue; // Check the first port again")
+
+ elif self.proc_name == "set_cache_entry":
+ code("set_cache_entry(m_cache_entry_ptr, %s);" %(cvec[0]));
+ elif self.proc_name == "unset_cache_entry":
+ code("unset_cache_entry(m_cache_entry_ptr);");
+ elif self.proc_name == "set_tbe":
+ code("set_tbe(m_tbe_ptr, %s);" %(cvec[0]));
+ elif self.proc_name == "unset_tbe":
+ code("unset_tbe(m_tbe_ptr);");
+
else:
# Normal function
@@ -184,7 +213,27 @@
if "external" not in func and not func.isInternalMachineFunc:
internal = "m_chip_ptr->"
- params = ', '.join(str(c) for c in cvec)
+ params = ""
+ first_param = True
+
+ for (param_code, type) in zip(cvec, type_vec):
+ if str(type) == "TBE" or ("interface" in type and
+ type["interface"] == "AbstractCacheEntry"):
+
+ if first_param:
+ params = str(param_code).replace('*','')
+ first_param = False
+ else:
+ params += ', '
+ params += str(param_code).replace('*','');
+ else:
+ if first_param:
+ params = str(param_code)
+ first_param = False
+ else:
+ params += ', '
+ params += str(param_code);
+
fix = code.nofix()
code('(${internal}${{func.c_ident}}($params))')
code.fix(fix)
diff --git a/src/mem/slicc/ast/InPortDeclAST.py b/src/mem/slicc/ast/InPortDeclAST.py
--- a/src/mem/slicc/ast/InPortDeclAST.py
+++ b/src/mem/slicc/ast/InPortDeclAST.py
@@ -117,19 +117,30 @@
void_type, [], [], "", pairs, None)
symtab.newSymbol(func)
- if self.statements is not None:
- rcode = self.slicc.codeFormatter()
- rcode.indent()
- rcode.indent()
- self.statements.generate(rcode, None)
- in_port["c_code_in_port"] = str(rcode)
- symtab.popFrame()
-
- # Add port to state machine
machine = symtab.state_machine
if machine is None:
self.error("InPort declaration not part of a machine.")
+ if machine.TBEType != None:
+ var = Var(self.symtab, "tbe", self.location, machine.TBEType,
+ "*m_tbe_ptr", self.pairs)
+ self.symtab.newSymbol(var)
+
+ if machine.EntryType != None:
+ var = Var(self.symtab, "cache_entry", self.location,
+ machine.EntryType, "*m_cache_entry_ptr", self.pairs)
+ self.symtab.newSymbol(var)
+
+ if self.statements is not None:
+ rcode = self.slicc.codeFormatter()
+ rcode.indent()
+ rcode.indent()
+ self.statements.generate(rcode, None)
+ in_port["c_code_in_port"] = str(rcode)
+
+ symtab.popFrame()
+
+ # Add port to state machine
machine.addInPort(in_port)
# Include max_rank to be used by StateMachine.py
diff --git a/src/mem/slicc/ast/MethodCallExprAST.py b/src/mem/slicc/ast/MethodCallExprAST.py
--- a/src/mem/slicc/ast/MethodCallExprAST.py
+++ b/src/mem/slicc/ast/MethodCallExprAST.py
@@ -97,48 +97,67 @@
prefix = ""
implements_interface = False
- if methodId not in obj_type.methods:
+
+ if methodId in obj_type.methods:
+ return_type = obj_type.methods[methodId].return_type
+
+ else:
#
- # The initial method check has failed, but before generating an
- # error we must check whether any of the paramTypes implement
- # an interface. If so, we must check if the method ids using
- # the inherited types exist.
- #
- # This code is a temporary fix and only checks for the methodId
- # where all paramTypes are converted to their inherited type. The
- # right way to do this is to replace slicc's simple string
- # comparison for determining the correct overloaded method, with a
- # more robust param by param check.
- #
- implemented_paramTypes = []
- for paramType in paramTypes:
- implemented_paramType = paramType
- if paramType.isInterface:
- implements_interface = True
- implemented_paramType.abstract_ident = paramType["interface"]
+ # Check whether the method is implemented by the super class
+ if "interface" in obj_type:
+ interface_type = self.symtab.find(obj_type["interface"]);
+
+ if methodId in interface_type.methods:
+ return_type = interface_type.methods[methodId].return_type
+ obj_type = interface_type
+
else:
- implemented_paramType.abstract_ident = paramType.c_ident
-
- implemented_paramTypes.append(implemented_paramType)
+ self.error("Invalid method call: " \
+ "Type '%s' does not have a method %s, '%s'",
+ obj_type, self.proc_name, methodId)
- if implements_interface:
- implementedMethodId = obj_type.methodIdAbstract(self.proc_name,
- implemented_paramTypes)
else:
- implementedMethodId = ""
-
- if implementedMethodId not in obj_type.methods:
- self.error("Invalid method call: " \
- "Type '%s' does not have a method '%s' nor '%s'",
- obj_type, methodId, implementedMethodId)
- else:
- #
- # Replace the methodId with the implementedMethodId found in
- # the method list.
- #
- methodId = implementedMethodId
-
- return_type = obj_type.methods[methodId].return_type
+ #
+ # The initial method check has failed, but before generating an
+ # error we must check whether any of the paramTypes implement
+ # an interface. If so, we must check if the method ids using
+ # the inherited types exist.
+ #
+ # This code is a temporary fix and only checks for the methodId
+ # where all paramTypes are converted to their inherited type. The
+ # right way to do this is to replace slicc's simple string
+ # comparison for determining the correct overloaded method, with a
+ # more robust param by param check.
+ #
+ implemented_paramTypes = []
+ for paramType in paramTypes:
+ implemented_paramType = paramType
+ if paramType.isInterface:
+ implements_interface = True
+ implemented_paramType.abstract_ident = paramType["interface"]
+ else:
+ implemented_paramType.abstract_ident = paramType.c_ident
+
+ implemented_paramTypes.append(implemented_paramType)
+
+ if implements_interface:
+ implementedMethodId = obj_type.methodIdAbstract(self.proc_name,
+ implemented_paramTypes)
+ else:
+ implementedMethodId = ""
+
+ if implementedMethodId not in obj_type.methods:
+ self.error("Invalid method call: " \
+ "Type '%s' does not have a method %s, '%s' nor '%s'",
+ obj_type, self.proc_name, methodId, implementedMethodId)
+ else:
+ #
+ # Replace the methodId with the implementedMethodId found in
+ # the method list.
+ #
+ methodId = implementedMethodId
+ return_type = obj_type.methods[methodId].return_type
+
if return_type.isInterface:
prefix = "static_cast<%s &>" % return_type.c_ident
prefix = "%s((%s)." % (prefix, code)
diff --git a/src/mem/slicc/ast/TypeDeclAST.py b/src/mem/slicc/ast/TypeDeclAST.py
--- a/src/mem/slicc/ast/TypeDeclAST.py
+++ b/src/mem/slicc/ast/TypeDeclAST.py
@@ -50,10 +50,15 @@
def generate(self):
ident = str(self.type_ast)
+ machine = self.symtab.state_machine
# Make the new type
new_type = Type(self.symtab, ident, self.location, self.pairs,
self.state_machine)
+
+ if machine:
+ machine.addType(new_type)
+
self.symtab.newSymbol(new_type)
# Add all of the fields of the type to it
diff --git a/src/mem/slicc/ast/__init__.py b/src/mem/slicc/ast/__init__.py
--- a/src/mem/slicc/ast/__init__.py
+++ b/src/mem/slicc/ast/__init__.py
@@ -46,6 +46,7 @@
from slicc.ast.IfStatementAST import *
from slicc.ast.InPortDeclAST import *
from slicc.ast.InfixOperatorExprAST import *
+from slicc.ast.IsValidPtrExprAST import *
from slicc.ast.LiteralExprAST import *
from slicc.ast.MachineAST import *
from slicc.ast.MemberExprAST import *
diff --git a/src/mem/slicc/parser.py b/src/mem/slicc/parser.py
--- a/src/mem/slicc/parser.py
+++ b/src/mem/slicc/parser.py
@@ -165,6 +165,8 @@
'check_stop_slots' : 'CHECK_STOP_SLOTS',
'static_cast' : 'STATIC_CAST',
'if' : 'IF',
+ 'is_valid' : 'IS_VALID',
+ 'is_invalid' : 'IS_INVALID',
'else' : 'ELSE',
'return' : 'RETURN',
'THIS' : 'THIS',
@@ -687,6 +689,14 @@
"aexpr : '(' expr ')'"
p[0] = p[2]
+ def p_expr__is_valid_ptr(self, p):
+ "aexpr : IS_VALID '(' var ')'"
+ p[0] = ast.IsValidPtrExprAST(self, p[3], True)
+
+ def p_expr__is_invalid_ptr(self, p):
+ "aexpr : IS_INVALID '(' var ')'"
+ p[0] = ast.IsValidPtrExprAST(self, p[3], False)
+
def p_literal__string(self, p):
"literal : STRING"
p[0] = ast.LiteralExprAST(self, p[1], "std::string")
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -46,6 +46,7 @@
super(StateMachine, self).__init__(symtab, ident, location, pairs)
self.table = None
self.config_parameters = config_parameters
+
for param in config_parameters:
if param.pointer:
var = Var(symtab, param.name, location, param.type_ast.type,
@@ -62,6 +63,8 @@
self.in_ports = []
self.functions = []
self.objects = []
+ self.TBEType = None
+ self.EntryType = None
self.message_buffer_names = []
@@ -107,6 +110,21 @@
def addObject(self, obj):
self.objects.append(obj)
+ def addType(self, type):
+ type_ident = '%s' % type.c_ident
+
+ if type_ident == "%s_TBE" %self.ident:
+ if self.TBEType != None:
+ self.error("Multiple Transaction Buffer types in a " \
+ "single machine.");
+ self.TBEType = type
+
+ elif "interface" in type and "AbstractCacheEntry" == type["interface"]:
+ if self.EntryType != None:
+ self.error("Multiple AbstractCacheEntry types in a " \
+ "single machine.");
+ self.EntryType = type
+
# Needs to be called before accessing the table
def buildTable(self):
assert self.table is None
@@ -264,12 +282,35 @@
int m_number_of_TBEs;
TransitionResult doTransition(${ident}_Event event,
- ${ident}_State state,
+''')
+
+ if self.TBEType != None:
+ code('''
+ ${{self.TBEType.c_ident}}* m_tbe_ptr,
+''')
+ if self.EntryType != None:
+ code('''
+ ${{self.EntryType.c_ident}}* m_cache_entry_ptr,
+''')
+
+ code('''
const Address& addr);
TransitionResult doTransitionWorker(${ident}_Event event,
${ident}_State state,
${ident}_State& next_state,
+''')
+
+ if self.TBEType != None:
+ code('''
+ ${{self.TBEType.c_ident}}*& m_tbe_ptr,
+''')
+ if self.EntryType != None:
+ code('''
+ ${{self.EntryType.c_ident}}*& m_cache_entry_ptr,
+''')
+
+ code('''
const Address& addr);
std::string m_name;
@@ -299,13 +340,43 @@
if proto:
code('$proto')
+ if self.EntryType != None:
+ code('''
+${{self.EntryType.c_ident}}* getCacheEntry(const Address& addr);
+
+// Set and Reset for cache_entry variable
+void set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry);
+void unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr);
+''')
+
+ if self.TBEType != None:
+ code('''
+
+// Set and Reset for tbe variable
+void set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${ident}_TBE* m_new_tbe);
+void unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr);
+''')
+
code('''
// Actions
''')
- for action in self.actions.itervalues():
- code('/** \\brief ${{action.desc}} */')
- code('void ${{action.ident}}(const Address& addr);')
+ if self.TBEType != None and self.EntryType != None:
+ for action in self.actions.itervalues():
+ code('/** \\brief ${{action.desc}} */')
+ code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);')
+ elif self.TBEType != None:
+ for action in self.actions.itervalues():
+ code('/** \\brief ${{action.desc}} */')
+ code('void ${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, const Address& addr);')
+ elif self.EntryType != None:
+ for action in self.actions.itervalues():
+ code('/** \\brief ${{action.desc}} */')
+ code('void ${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr);')
+ else:
+ for action in self.actions.itervalues():
+ code('/** \\brief ${{action.desc}} */')
+ code('void ${{action.ident}}(const Address& addr);')
# the controller internal variables
code('''
@@ -730,15 +801,112 @@
code('''
m_profiler.clearStats();
}
+''')
+
+ if self.EntryType != None:
+ code('''
+
+${{self.EntryType.c_ident}}*
+$c_ident::getCacheEntry(const Address& address)
+{
+ ${{self.EntryType.c_ident}}* m_cache_entry_ptr = NULL;
+''')
+ for param in self.config_parameters:
+ if str(param.type_ast.type) == "CacheMemory":
+ code('''
+ m_cache_entry_ptr = (${{self.EntryType.c_ident}}*)(*m_${{param.name}}_ptr).lookup(address);
+ if (m_cache_entry_ptr != NULL) return m_cache_entry_ptr;
+''')
+ code('''
+ return 0;
+}
+
+// Set and Reset for cache_entry variable
+void
+$c_ident::set_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, AbstractCacheEntry* m_new_cache_entry)
+{
+ m_cache_entry_ptr = (${{self.EntryType.c_ident}}*)m_new_cache_entry;
+}
+
+void
+$c_ident::unset_cache_entry(${{self.EntryType.c_ident}}*& m_cache_entry_ptr)
+{
+ m_cache_entry_ptr = 0;
+}
+''')
+
+ if self.TBEType != None:
+ code('''
+
+// Set and Reset for tbe variable
+void
+$c_ident::set_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.TBEType.c_ident}}* m_new_tbe)
+{
+ m_tbe_ptr = m_new_tbe;
+}
+
+void
+$c_ident::unset_tbe(${{self.TBEType.c_ident}}*& m_tbe_ptr)
+{
+ m_tbe_ptr = NULL;
+}
+''')
+
+ code('''
// Actions
''')
+ if self.TBEType != None and self.EntryType != None:
+ for action in self.actions.itervalues():
+ if "c_code" not in action:
+ continue
- for action in self.actions.itervalues():
- if "c_code" not in action:
- continue
+ code('''
+/** \\brief ${{action.desc}} */
+void
+$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, ${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr)
+{
+ DPRINTF(RubyGenerated, "executing\\n");
+ ${{action["c_code"]}}
+}
- code('''
+''')
+ elif self.TBEType != None:
+ for action in self.actions.itervalues():
+ if "c_code" not in action:
+ continue
+
+ code('''
+/** \\brief ${{action.desc}} */
+void
+$c_ident::${{action.ident}}(${{self.TBEType.c_ident}}*& m_tbe_ptr, const Address& addr)
+{
+ DPRINTF(RubyGenerated, "executing\\n");
+ ${{action["c_code"]}}
+}
+
+''')
+ elif self.EntryType != None:
+ for action in self.actions.itervalues():
+ if "c_code" not in action:
+ continue
+
+ code('''
+/** \\brief ${{action.desc}} */
+void
+$c_ident::${{action.ident}}(${{self.EntryType.c_ident}}*& m_cache_entry_ptr, const Address& addr)
+{
+ DPRINTF(RubyGenerated, "executing\\n");
+ ${{action["c_code"]}}
+}
+
+''')
+ else:
+ for action in self.actions.itervalues():
+ if "c_code" not in action:
+ continue
+
+ code('''
/** \\brief ${{action.desc}} */
void
$c_ident::${{action.ident}}(const Address& addr)
@@ -774,9 +942,6 @@
void
${ident}_Controller::wakeup()
{
- // DEBUG_EXPR(GENERATED_COMP, MedPrio, *this);
- // DEBUG_EXPR(GENERATED_COMP, MedPrio, g_eventQueue_ptr->getTime());
-
int counter = 0;
while (true) {
// Some cases will put us into an infinite loop without this limit
@@ -791,6 +956,18 @@
}
''')
+ if self.TBEType != None:
+ code('''
+
+ ${{self.TBEType.c_ident}}* m_tbe_ptr = NULL;
+''')
+ if self.EntryType != None:
+ code('''
+
+ ${{self.EntryType.c_ident}}* m_cache_entry_ptr = NULL;
+''')
+
+
code.indent()
code.indent()
@@ -844,9 +1021,29 @@
TransitionResult
${ident}_Controller::doTransition(${ident}_Event event,
- ${ident}_State state,
+''')
+ if self.TBEType != None:
+ code('''
+ ${{self.TBEType.c_ident}}* m_tbe_ptr,
+''')
+ if self.EntryType != None:
+ code('''
+ ${{self.EntryType.c_ident}}* m_cache_entry_ptr,
+''')
+ code('''
const Address &addr)
{
+''')
+ if self.TBEType != None and self.EntryType != None:
+ code('${ident}_State state = ${ident}_getState(m_tbe_ptr, m_cache_entry_ptr, addr);')
+ elif self.TBEType != None:
+ code('${ident}_State state = ${ident}_getState(m_tbe_ptr, addr);')
+ elif self.EntryType != None:
+ code('${ident}_State state = ${ident}_getState(m_cache_entry_ptr, addr);')
+ else:
+ code('${ident}_State state = ${ident}_getState(addr);')
+
+ code('''
${ident}_State next_state = state;
DPRINTF(RubyGenerated, "%s, Time: %lld, state: %s, event: %s, addr: %s\\n",
@@ -857,8 +1054,17 @@
addr);
TransitionResult result =
- doTransitionWorker(event, state, next_state, addr);
+''')
+ if self.TBEType != None and self.EntryType != None:
+ code('doTransitionWorker(event, state, next_state, m_tbe_ptr, m_cache_entry_ptr, addr);')
+ elif self.TBEType != None:
+ code('doTransitionWorker(event, state, next_state, m_tbe_ptr, addr);')
+ elif self.EntryType != None:
+ code('doTransitionWorker(event, state, next_state, m_cache_entry_ptr, addr);')
+ else:
+ code('doTransitionWorker(event, state, next_state, addr);')
+ code('''
if (result == TransitionResult_Valid) {
DPRINTF(RubyGenerated, "next_state: %s\\n",
${ident}_State_to_string(next_state));
@@ -872,8 +1078,18 @@
GET_TRANSITION_COMMENT());
}
CLEAR_TRANSITION_COMMENT();
- ${ident}_setState(addr, next_state);
+''')
+ if self.TBEType != None and self.EntryType != None:
+ code('${ident}_setState(m_tbe_ptr, m_cache_entry_ptr, addr, next_state);')
+ elif self.TBEType != None:
+ code('${ident}_setState(m_tbe_ptr, addr, next_state);')
+ elif self.EntryType != None:
+ code('${ident}_setState(m_cache_entry_ptr, addr, next_state);')
+ else:
+ code('${ident}_setState(addr, next_state);')
+
+ code('''
} else if (result == TransitionResult_ResourceStall) {
if (Debug::getProtocolTrace()) {
g_system_ptr->getProfiler()->profileTransition("${ident}",
@@ -902,6 +1118,17 @@
${ident}_Controller::doTransitionWorker(${ident}_Event event,
${ident}_State state,
${ident}_State& next_state,
+''')
+
+ if self.TBEType != None:
+ code('''
+ ${{self.TBEType.c_ident}}*& m_tbe_ptr,
+''')
+ if self.EntryType != None:
+ code('''
+ ${{self.EntryType.c_ident}}*& m_cache_entry_ptr,
+''')
+ code('''
const Address& addr)
{
switch(HASH_FUN(state, event)) {
@@ -950,8 +1177,18 @@
if stall:
case('return TransitionResult_ProtocolStall;')
else:
- for action in actions:
- case('${{action.ident}}(addr);')
+ if self.TBEType != None and self.EntryType != None:
+ for action in actions:
+ case('${{action.ident}}(m_tbe_ptr, m_cache_entry_ptr, addr);')
+ elif self.TBEType != None:
+ for action in actions:
+ case('${{action.ident}}(m_tbe_ptr, addr);')
+ elif self.EntryType != None:
+ for action in actions:
+ case('${{action.ident}}(m_cache_entry_ptr, addr);')
+ else:
+ for action in actions:
+ case('${{action.ident}}(addr);')
case('return TransitionResult_Valid;')
case = str(case)
diff --git a/src/mem/protocol/RubySlicc_Types.sm b/src/mem/protocol/RubySlicc_Types.sm
--- a/src/mem/protocol/RubySlicc_Types.sm
+++ b/src/mem/protocol/RubySlicc_Types.sm
@@ -117,15 +117,16 @@
void invalidateBlock(Address);
}
-external_type(AbstractCacheEntry, primitive="yes");
+external_type(AbstractCacheEntry, primitive="yes") {
+ void changePermission(AccessPermission);
+}
external_type(CacheMemory) {
bool cacheAvail(Address);
Address cacheProbe(Address);
- void allocate(Address, AbstractCacheEntry);
+ AbstractCacheEntry allocate(Address, AbstractCacheEntry);
void deallocate(Address);
AbstractCacheEntry lookup(Address);
- void changePermission(Address, AccessPermission);
bool isTagPresent(Address);
void profileMiss(CacheMsg);