def __repr__(self):
return "[AssignStatementAST: %r := %r]" % (self.lvalue, self.rvalue)
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
lcode = self.slicc.codeFormatter()
rcode = self.slicc.codeFormatter()
def __repr__(self):
return "[CheckAllocateStatementAst: %r]" % self.variable
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
# FIXME - check the type of the variable
# Make sure the variable is valid
def __repr__(self):
return "[CheckNextCycleAST]"
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
code("scheduleEvent(Cycles(1));")
return "CheckNextCycle"
def __repr__(self):
return "[CheckProbeStatementAst: %r]" % self.in_port
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
self.in_port.assertType("InPort")
self.address.assertType("Addr")
return "[DeferEnqueueingStatementAst: %s %s %s]" % \
(self.queue_name, self.type_ast.ident, self.statements)
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
code("{")
code.indent()
self.symtab.pushFrame()
return "[EnqueueStatementAst: %s %s %s]" % \
(self.queue_name, self.type_ast.ident, self.statements)
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
code("{")
code.indent()
self.symtab.pushFrame()
def __repr__(self):
return "[EnumExpr: %s:%s]" % (self.type_ast, self.value)
- def generate(self, code):
+ def generate(self, code, **kwargs):
fix = code.nofix()
code('${{self.type_ast.type.c_ident}}_${{self.value}}')
code.fix(fix)
# The default is no resources
pass
- def inline(self, get_type=False):
+ def inline(self, get_type=False, **kwargs):
code = self.slicc.codeFormatter(fix_newlines=False)
- return_type = self.generate(code)
+ return_type = self.generate(code, **kwargs)
if get_type:
return return_type, code
else:
def __repr__(self):
return "[ExprStatementAST: %s]" % (self.expr)
- def generate(self, code, return_type):
- actual_type,rcode = self.expr.inline(True)
+ def generate(self, code, return_type, **kwargs):
+ actual_type,rcode = self.expr.inline(True, **kwargs)
code("$rcode;")
# The return type must be void, except for local var decls
+# Copyright (c) 2020 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder. You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
# Copyright (c) 2009 The Hewlett-Packard Development Company
# Copyright (c) 2013 Advanced Micro Devices, Inc.
def __repr__(self):
return "[FuncCallExpr: %s %s]" % (self.proc_name, self.exprs)
- def generate(self, code):
+ # When calling generate for statements in a in_port, the reference to
+ # the port must be provided as the in_port kwarg (see InPortDeclAST)
+ def generate(self, code, **kwargs):
machine = self.state_machine
if self.proc_name == "DPRINTF":
TransitionResult result = doTransition(${{cvec[0]}}, ${{cvec[1]}});
''')
+ assert('in_port' in kwargs)
+ in_port = kwargs['in_port']
+
code('''
if (result == TransitionResult_Valid) {
counter++;
continue; // Check the first port again
- }
-
- if (result == TransitionResult_ResourceStall ||
- result == TransitionResult_ProtocolStall) {
+ } else if (result == TransitionResult_ResourceStall) {
+''')
+ if 'rsc_stall_handler' in in_port.pairs:
+ stall_func_name = in_port.pairs['rsc_stall_handler']
+ code('''
+ if (${{stall_func_name}}()) {
+ counter++;
+ continue; // Check the first port again
+ } else {
+ scheduleEvent(Cycles(1));
+ // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
+ }
+''')
+ else:
+ code('''
scheduleEvent(Cycles(1));
-
// Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
+''')
+ code('''
+ } else if (result == TransitionResult_ProtocolStall) {
+''')
+ if 'prot_stall_handler' in in_port.pairs:
+ stall_func_name = in_port.pairs['prot_stall_handler']
+ code('''
+ if (${{stall_func_name}}()) {
+ counter++;
+ continue; // Check the first port again
+ } else {
+ scheduleEvent(Cycles(1));
+ // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
+ }
+''')
+ else:
+ code('''
+ scheduleEvent(Cycles(1));
+ // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
+''')
+ code('''
}
+
}
''')
elif self.proc_name == "error":
def files(self, parent=None):
return set()
- def generate(self, parent = None):
+ def generate(self, parent = None, **kwargs):
types = []
params = []
void_type = self.symtab.find("void", Type)
def __repr__(self):
return "[IfStatement: %r%r%r]" % (self.cond, self.then, self.else_)
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
cond_code = self.slicc.codeFormatter()
cond_type = self.cond.generate(cond_code)
# Then part
code.indent()
self.symtab.pushFrame()
- self.then.generate(code, return_type)
+ self.then.generate(code, return_type, **kwargs)
self.symtab.popFrame()
code.dedent()
# Else part
code('} else {')
code.indent()
self.symtab.pushFrame()
- self.else_.generate(code, return_type)
+ self.else_.generate(code, return_type, **kwargs)
self.symtab.popFrame()
code.dedent()
code('}') # End scope
+# Copyright (c) 2020 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder. You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
# Copyright (c) 2009 The Hewlett-Packard Development Company
# All rights reserved.
rcode = self.slicc.codeFormatter()
rcode.indent()
rcode.indent()
- self.statements.generate(rcode, None)
+ self.statements.generate(rcode, None, in_port=in_port)
in_port["c_code_in_port"] = str(rcode)
symtab.popFrame()
def __repr__(self):
return "[IsValidPtrExprAST: %r]" % self.variable
- def generate(self, code):
+ def generate(self, code, **kwargs):
# Make sure the variable is valid
fix = code.nofix()
code("(")
def __repr__(self):
return "[Literal: %s]" % self.literal
- def generate(self, code):
+ def generate(self, code, **kwargs):
fix = code.nofix()
if self.type == "std::string":
code('("${{self.literal}}")')
else:
return code
- def generate(self, code):
+ def generate(self, code, **kwargs):
type = self.type_ast.type;
ident = "%s" % self.ident;
self.proc_name = proc_name
self.expr_ast_vec = expr_ast_vec
- def generate(self, code):
+ def generate(self, code, **kwargs):
tmp = self.slicc.codeFormatter()
paramTypes = []
for expr_ast in self.expr_ast_vec:
def name(self):
return str(self.type_ast)
- def generate(self, code):
+ def generate(self, code, **kwargs):
type = self.type_ast.type
fix = code.nofix()
code("new ${{type.c_ident}}")
def __repr__(self):
return "[ObjDecl: %r]" % self.ident
- def generate(self, parent = None):
+ def generate(self, parent = None, **kwargs):
if "network" in self and not ("virtual_network" in self or
"physical_network" in self) :
self.error("Network queues require a 'virtual_network' attribute")
def __repr__(self):
return "[Ood:]"
- def generate(self, code):
+ def generate(self, code, **kwargs):
code += "NULL"
return "OOD"
def __repr__(self):
return "[InfixExpr: %r %s %r]" % (self.left, self.op, self.right)
- def generate(self, code):
+ def generate(self, code, **kwargs):
lcode = self.slicc.codeFormatter()
rcode = self.slicc.codeFormatter()
def __repr__(self):
return "[PrefixExpr: %s %r]" % (self.op, self.operand)
- def generate(self, code):
+ def generate(self, code, **kwargs):
opcode = self.slicc.codeFormatter()
optype = self.operand.generate(opcode)
return "[PeekStatementAST: %r queue_name: %r type: %r %r]" % \
(self.method, self.queue_name, self.type_ast, self.statements)
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
self.symtab.pushFrame()
msg_type = self.type_ast.type
''')
# The other statements
- self.statements.generate(code, return_type)
+ self.statements.generate(code, return_type, **kwargs)
self.symtab.popFrame()
code("}")
def __repr__(self):
return "[ReturnStatementAST: %r]" % self.expr_ast
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
actual_type, ecode = self.expr_ast.inline(True)
code('return $ecode;')
def __repr__(self):
return "[StallAndWaitStatementAst: %r]" % self.in_port
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
self.in_port.assertType("InPort")
self.address.assertType("Addr")
def __repr__(self):
return "[StatementListAST: %r]" % self.statements
- def generate(self, code, return_type):
+ def generate(self, code, return_type, **kwargs):
for statement in self.statements:
- statement.generate(code, return_type)
+ statement.generate(code, return_type, **kwargs)
def findResources(self, resources):
for statement in self.statements:
def __repr__(self):
return "[StaticCastAST: %r]" % self.expr_ast
- def generate(self, code):
+ def generate(self, code, **kwargs):
actual_type, ecode = self.expr_ast.inline(True)
if self.type_modifier == "pointer":
code('static_cast<${{self.type_ast.type.c_ident}} *>($ecode)')
def __repr__(self):
return "[TypeFieldEnum: %r]" % self.field_id
- def generate(self, type):
+ def generate(self, type, **kwargs):
if str(type) == "State":
self.error("States must in a State Declaration, not a normal enum.")
def __repr__(self):
return "[TypeFieldState: %r]" % self.field_id
- def generate(self, type):
+ def generate(self, type, **kwargs):
if not str(type) == "State":
self.error("State Declaration must be of type State.")
"'%s' is expected to be type '%s' not '%s'",
self.var.ident, expected_type, self.var.type)
- def generate(self, code):
+ def generate(self, code, **kwargs):
fix = code.nofix()
code("${{self.var.code}}")
code.fix(fix)