Giacomo Travaglini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/57300 )
Change subject: mem-ruby: SLICC run_on_input_cycle_end functions
......................................................................
mem-ruby: SLICC run_on_input_cycle_end functions
Adds a function annotation 'run_on_input_cycle_end' for SLICC that
calls the function at the end of every input-receiving cycle.
This will be used in future misc-node work.
JIRA: https://gem5.atlassian.net/browse/GEM5-1097
Change-Id: I7a9e29f3ae8b8497c7e835d2df5b2f7374c92c29
---
M src/mem/slicc/ast/FuncDeclAST.py
M src/mem/slicc/symbols/Func.py
M src/mem/slicc/symbols/StateMachine.py
3 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/src/mem/slicc/ast/FuncDeclAST.py
b/src/mem/slicc/ast/FuncDeclAST.py
index ab2a1c6..f544d10 100644
--- a/src/mem/slicc/ast/FuncDeclAST.py
+++ b/src/mem/slicc/ast/FuncDeclAST.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2021 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.
@@ -66,6 +78,15 @@
types.append(formal.type)
params.append(None)
+ run_on_input_cycle_end = "run_on_input_cycle_end" in self.pairs
+ if (run_on_input_cycle_end):
+ if (len(params) > 0):
+ self.error(f"{self.ident}() marked
as 'run_on_input_cycle_end'"
+ " so cannot take arguments")
+ if (return_type.c_ident not in ["void", "bool"]):
+ self.error(f"{self.ident}() marked
as 'run_on_input_cycle_end'"
+ " so must return void or bool")
+
body = self.slicc.codeFormatter()
if self.statements is None:
self["external"] = "yes"
@@ -87,7 +108,8 @@
machine = self.state_machine
func = Func(self.symtab, func_name_args, self.ident, self.location,
- return_type, types, params, str(body), self.pairs)
+ return_type, types, params, str(body), self.pairs,
+ run_on_input_cycle_end=run_on_input_cycle_end)
if parent is not None:
if not parent.addFunc(func):
diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py
index 8a73a5c..4094ae9 100644
--- a/src/mem/slicc/symbols/Func.py
+++ b/src/mem/slicc/symbols/Func.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2021 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.
@@ -30,7 +42,7 @@
class Func(Symbol):
def __init__(self, table, ident, name, location, return_type,
param_types,
- param_strings, body, pairs):
+ param_strings, body, pairs, run_on_input_cycle_end=False):
super().__init__(table, ident, location, pairs)
self.return_type = return_type
self.param_types = param_types
@@ -40,6 +52,7 @@
self.c_ident = ident
self.c_name = name
self.class_name = ""
+ self.run_on_input_cycle_end = run_on_input_cycle_end
def __repr__(self):
return ""
diff --git a/src/mem/slicc/symbols/StateMachine.py
b/src/mem/slicc/symbols/StateMachine.py
index a9f7373..1e2ede2 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -1355,6 +1355,28 @@
code('''
break;
}
+''')
+ # We're outside the while(true), now execute "cycle-end" functions
+ code('''
+ // Run functions marked as run_on_input_cycle_end
+ bool shouldScheduleNextCycle = false;''')
+ code.indent()
+ for func in self.functions:
+ if func.run_on_input_cycle_end:
+ # If the function returns bool, it can return true
+ # to ensure the function is called again on the next cycle
+ if func.return_type.c_ident == "bool":
+ code('shouldScheduleNextCycle = '
+ 'shouldScheduleNextCycle || ${{func.c_ident}}();')
+ else:
+ code('${{func.c_ident}}();')
+ code.dedent()
+
+ # Now we can close the function
+ code('''
+ if (shouldScheduleNextCycle) {
+ scheduleEvent(Cycles(1));
+ }
}
} // namespace ruby
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/57300
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7a9e29f3ae8b8497c7e835d2df5b2f7374c92c29
Gerrit-Change-Number: 57300
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s