diff --git a/.clang-format b/.clang-format
index 0d03f70..a2683b8 100644
--- a/.clang-format
+++ b/.clang-format
@@ -1,4 +1,3 @@
----
Language: Cpp
# BasedOnStyle: LLVM
# should be in line with IndentWidth
@@ -13,8 +12,8 @@ AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
-AllowShortIfStatementsOnASingleLine: true
-AllowShortLoopsOnASingleLine: true
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
@@ -39,8 +38,8 @@ BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
-ColumnLimit: 120
-CommentPragmas: '^ IWYU pragma:'
+ColumnLimit: 140
+CommentPragmas: '^( IWYU pragma:| @suppress)'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 4
@@ -76,13 +75,13 @@ PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
+PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
-SpaceBeforeParens: ControlStatements
+SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
diff --git a/.gitignore b/.gitignore
index d687e5f..7724009 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.DS_Store
/*.il
+/.settings
/avr-instr.html
/blink.S
/flash.*
@@ -14,7 +15,6 @@
/*.ods
/build*/
/*.logs
-language.settings.xml
/*.gtkw
/Debug wo LLVM/
/*.txdb
@@ -30,6 +30,5 @@ language.settings.xml
/.gdbinit
/*.out
/dump.json
-/src-gen/
/*.yaml
/*.json
diff --git a/.project b/.project
index 84a8200..395ef36 100644
--- a/.project
+++ b/.project
@@ -23,6 +23,5 @@
org.eclipse.cdt.core.ccnature
org.eclipse.cdt.managedbuilder.core.managedBuildNature
org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
- org.eclipse.linuxtools.tmf.project.nature
diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs
deleted file mode 100644
index 067d6fd..0000000
--- a/.settings/org.eclipse.cdt.codan.core.prefs
+++ /dev/null
@@ -1,73 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.cdt.codan.checkers.errnoreturn=Warning
-org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
-org.eclipse.cdt.codan.checkers.errreturnvalue=Error
-org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
-org.eclipse.cdt.codan.checkers.nocommentinside=-Error
-org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
-org.eclipse.cdt.codan.checkers.nolinecomment=-Error
-org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
-org.eclipse.cdt.codan.checkers.noreturn=Error
-org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
-org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
-org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
-org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
-org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
-org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
-org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
-org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
-org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
-org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
-org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
-org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
-org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
-org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
-org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
-org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error
-org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"}
-org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
-org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
-org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
-org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
-org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
-org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
-org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
-org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
-org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
-org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
-org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
-org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
-org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
-org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
-org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
-org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
-org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
-org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
-org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
-org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
-org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
-org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
-org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
-org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
-org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
-org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
-org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
-org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
-org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
-org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
-org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs
deleted file mode 100644
index 7982989..0000000
--- a/.settings/org.eclipse.cdt.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-eclipse.preferences.version=1
-environment/project/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true
-environment/project/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/delimiter=\:
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/operation=append
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LLVM_HOME/value=/usr/lib/llvm-6.0
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/delimiter=\:
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/operation=append
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/LLVM_HOME/value=/usr/lib/llvm-6.0
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true
-environment/project/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true
diff --git a/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/.settings/org.eclipse.cdt.managedbuilder.core.prefs
deleted file mode 100644
index f299fce..0000000
--- a/.settings/org.eclipse.cdt.managedbuilder.core.prefs
+++ /dev/null
@@ -1,37 +0,0 @@
-eclipse.preferences.version=1
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPLUS_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/CPLUS_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/C_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/C_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPLUS_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/CPLUS_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/C_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/C_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPLUS_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/CPLUS_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/C_INCLUDE_PATH/delimiter=\:
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/C_INCLUDE_PATH/operation=remove
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true
-environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/LIBRARY_PATH/delimiter=\:
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/LIBRARY_PATH/operation=remove
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/append=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1751741082/appendContributed=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LIBRARY_PATH/delimiter=\:
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/LIBRARY_PATH/operation=remove
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/append=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171.1259602404/appendContributed=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/LIBRARY_PATH/delimiter=\:
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/LIBRARY_PATH/operation=remove
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/append=true
-environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1745230171/appendContributed=true
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28ba1da..3070844 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,92 +1,106 @@
cmake_minimum_required(VERSION 3.12)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
###############################################################################
#
###############################################################################
project(dbt-rise-tgc VERSION 1.0.0)
include(GNUInstallDirs)
+include(flink)
find_package(elfio QUIET)
-find_package(Boost COMPONENTS coroutine)
-
-if(WITH_LLVM)
- if(DEFINED ENV{LLVM_HOME})
- find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm)
- endif(DEFINED ENV{LLVM_HOME})
- find_package(LLVM REQUIRED CONFIG)
- message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
- message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
- llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser)
-endif()
-
-#Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH)
-#set(CMAKE_MACOSX_RPATH ON)
-#set(CMAKE_SKIP_BUILD_RPATH FALSE)
-#set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
-#set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
-#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+find_package(jsoncpp)
+find_package(Boost COMPONENTS coroutine REQUIRED)
add_subdirectory(softfloat)
-# library files
-FILE(GLOB TGC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/iss/*.cpp)
-FILE(GLOB TGC_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/interp/vm_*.cpp)
-
set(LIB_SOURCES
- src/vm/fp_functions.cpp
- src/plugin/instruction_count.cpp
-
- ${TGC_SOURCES}
- ${TGC_VM_SOURCES}
+ src/iss/plugin/instruction_count.cpp
+ src/iss/arch/tgc5c.cpp
+ src/vm/interp/vm_tgc5c.cpp
+ src/vm/fp_functions.cpp
)
-if(TARGET RapidJSON)
- list(APPEND LIB_SOURCES src/plugin/cycle_estimate.cpp src/plugin/pctrace.cpp)
+if(WITH_TCC)
+ list(APPEND LIB_SOURCES
+ src/vm/tcc/vm_tgc5c.cpp
+ )
endif()
+if(WITH_LLVM)
+ list(APPEND LIB_SOURCES
+ src/vm/llvm/vm_tgc5c.cpp
+ src/vm/llvm/fp_impl.cpp
+ )
+endif()
+if(WITH_ASMJIT)
+ list(APPEND LIB_SOURCES
+ src/vm/asmjit/vm_tgc5c.cpp
+ )
+endif()
+# library files
+FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp)
+FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp)
+FILE(GLOB GEN_YAML_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/contrib/instr/*.yaml)
+list(APPEND LIB_SOURCES ${GEN_ISS_SOURCES} ${GEN_VM_SOURCES})
+foreach(FILEPATH ${GEN_ISS_SOURCES})
+ get_filename_component(CORE ${FILEPATH} NAME_WE)
+ string(TOUPPER ${CORE} CORE)
+ list(APPEND LIB_DEFINES CORE_${CORE})
+endforeach()
+message(STATUS "Core defines are ${LIB_DEFINES}")
if(WITH_LLVM)
- FILE(GLOB TGC_LLVM_SOURCES
- ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/llvm/vm_*.cpp
- )
- list(APPEND LIB_SOURCES ${TGC_LLVM_SOURCES})
+ FILE(GLOB LLVM_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/llvm/vm_*.cpp)
+ list(APPEND LIB_SOURCES ${LLVM_GEN_SOURCES})
endif()
if(WITH_TCC)
- FILE(GLOB TGC_TCC_SOURCES
- ${CMAKE_CURRENT_SOURCE_DIR}/src/vm/tcc/vm_*.cpp
- )
- list(APPEND LIB_SOURCES ${TGC_TCC_SOURCES})
+ FILE(GLOB TCC_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/tcc/vm_*.cpp)
+ list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
+endif()
+if(WITH_ASMJIT)
+ FILE(GLOB TCC_GEN_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/asmjit/vm_*.cpp)
+ list(APPEND LIB_SOURCES ${TCC_GEN_SOURCES})
+endif()
+if(TARGET yaml-cpp::yaml-cpp)
+ list(APPEND LIB_SOURCES
+ src/iss/plugin/cycle_estimate.cpp
+ src/iss/plugin/instruction_count.cpp
+ )
endif()
-
# Define the library
-add_library(${PROJECT_NAME} ${LIB_SOURCES})
-# list code gen dependencies
-if(TARGET ${CORE_NAME}_cpp)
- add_dependencies(${PROJECT_NAME} ${CORE_NAME}_cpp)
-endif()
+add_library(${PROJECT_NAME} SHARED ${LIB_SOURCES})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
+ target_compile_options(${PROJECT_NAME} PRIVATE -Wno-shift-count-overflow)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /wd4293)
endif()
-target_include_directories(${PROJECT_NAME} PUBLIC incl)
-target_link_libraries(${PROJECT_NAME} PUBLIC softfloat scc-util jsoncpp Boost::coroutine)
-if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- target_link_libraries(${PROJECT_NAME} PUBLIC -Wl,--whole-archive dbt-rise-core -Wl,--no-whole-archive)
-else()
- target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-core)
-endif()
-if(TARGET CONAN_PKG::elfio)
- target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::elfio)
-elseif(TARGET elfio::elfio)
- target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio)
-else()
- message(FATAL_ERROR "No elfio library found, maybe a find_package() call is missing")
-endif()
-if(TARGET RapidJSON)
- target_link_libraries(${PROJECT_NAME} PUBLIC RapidJSON)
+target_include_directories(${PROJECT_NAME} PUBLIC src)
+target_include_directories(${PROJECT_NAME} PUBLIC src-gen)
+
+target_force_link_libraries(${PROJECT_NAME} PRIVATE dbt-rise-core)
+# only re-export the include paths
+get_target_property(DBT_CORE_INCL dbt-rise-core INTERFACE_INCLUDE_DIRECTORIES)
+target_include_directories(${PROJECT_NAME} INTERFACE ${DBT_CORE_INCL})
+get_target_property(DBT_CORE_DEFS dbt-rise-core INTERFACE_COMPILE_DEFINITIONS)
+if(NOT (DBT_CORE_DEFS STREQUAL DBT_CORE_DEFS-NOTFOUND))
+ target_compile_definitions(${PROJECT_NAME} INTERFACE ${DBT_CORE_DEFS})
endif()
+target_link_libraries(${PROJECT_NAME} PUBLIC elfio::elfio softfloat scc-util Boost::coroutine)
+if(TARGET yaml-cpp::yaml-cpp)
+ target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_PLUGINS)
+ target_link_libraries(${PROJECT_NAME} PUBLIC yaml-cpp::yaml-cpp)
+endif()
+
+if(WITH_LLVM)
+ find_package(LLVM)
+ target_compile_definitions(${PROJECT_NAME} PUBLIC ${LLVM_DEFINITIONS})
+ target_include_directories(${PROJECT_NAME} PUBLIC ${LLVM_INCLUDE_DIRS})
+ if(BUILD_SHARED_LIBS)
+ target_link_libraries( ${PROJECT_NAME} PUBLIC ${LLVM_LIBRARIES})
+ endif()
+endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
@@ -106,25 +120,43 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/incl/iss COMPONENT ${PROJECT_NAME}
FILES_MATCHING # install only matched files
PATTERN "*.h" # select header files
)
+install(FILES ${GEN_YAML_SOURCES} DESTINATION share/tgc-vp)
###############################################################################
#
###############################################################################
+set(CMAKE_INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR})
project(tgc-sim)
find_package(Boost COMPONENTS program_options thread REQUIRED)
add_executable(${PROJECT_NAME} src/main.cpp)
+if(TARGET ${CORE_NAME}_cpp)
+ list(APPEND TGC_SOURCES ${${CORE_NAME}_OUTPUT_FILES})
+else()
+ FILE(GLOB TGC_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp
+ )
+ list(APPEND TGC_SOURCES ${GEN_SOURCES})
+endif()
+
foreach(F IN LISTS TGC_SOURCES)
- string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
- string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
- target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
+ if (${F} MATCHES ".*/arch/([^/]*)\.cpp")
+ string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
+ string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
+ endif()
endforeach()
-if(WITH_LLVM)
- target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
- target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
-endif()
-# Links the target exe against the libraries
-target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc)
+#if(WITH_LLVM)
+# target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LLVM)
+# #target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
+#endif()
+#if(WITH_TCC)
+# target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_TCC)
+#endif()
+
+target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc fmt::fmt)
+
if(TARGET Boost::program_options)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options)
else()
@@ -144,27 +176,51 @@ install(TARGETS tgc-sim
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package)
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers
)
+
+if(BUILD_TESTING)
+ # ... CMake code to create tests ...
+ add_test(NAME tgc-sim-interp
+ COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend interp)
+ if(WITH_TCC)
+ add_test(NAME tgc-sim-tcc
+ COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend tcc)
+ endif()
+ if(WITH_LLVM)
+ add_test(NAME tgc-sim-llvm
+ COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend llvm)
+ endif()
+ if(WITH_ASMJIT)
+ add_test(NAME tgc-sim-asmjit
+ COMMAND tgc-sim -f ${CMAKE_BINARY_DIR}/../../Firmwares/hello-world/hello --backend asmjit)
+ endif()
+endif()
###############################################################################
#
###############################################################################
-project(dbt-rise-tgc_sc VERSION 1.0.0)
-
-include(SystemCPackage)
-if(SystemC_FOUND)
- add_library(${PROJECT_NAME} src/sysc/core_complex.cpp)
+if(TARGET scc-sysc)
+ project(dbt-rise-tgc_sc VERSION 1.0.0)
+ set(LIB_SOURCES
+ src/sysc/core_complex.cpp
+ src/sysc/register_tgc_c.cpp
+ )
+ FILE(GLOB GEN_SC_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/sysc/register_*.cpp)
+ list(APPEND LIB_SOURCES ${GEN_SC_SOURCES})
+ add_library(${PROJECT_NAME} ${LIB_SOURCES})
target_compile_definitions(${PROJECT_NAME} PUBLIC WITH_SYSTEMC)
target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
foreach(F IN LISTS TGC_SOURCES)
- string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
- string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
- target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
+ if (${F} MATCHES ".*/arch/([^/]*)\.cpp")
+ string(REGEX REPLACE ".*/([^/]*)\.cpp" "\\1" CORE_NAME_LC ${F})
+ string(TOUPPER ${CORE_NAME_LC} CORE_NAME)
+ target_compile_definitions(${PROJECT_NAME} PRIVATE CORE_${CORE_NAME})
+ endif()
endforeach()
- target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc scc)
- if(WITH_LLVM)
- target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
- endif()
+ target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc scc-sysc)
+# if(WITH_LLVM)
+# target_link_libraries(${PROJECT_NAME} PUBLIC ${llvm_libs})
+# endif()
- set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/core_complex.h)
+ set(LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/sysc/core_complex.h)
set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
FRAMEWORK FALSE
diff --git a/cmake/flink.cmake b/cmake/flink.cmake
new file mode 100644
index 0000000..69b5c9f
--- /dev/null
+++ b/cmake/flink.cmake
@@ -0,0 +1,35 @@
+# according to https://github.com/horance-liu/flink.cmake/tree/master
+# SPDX-License-Identifier: Apache-2.0
+
+include(CMakeParseArguments)
+
+function(target_do_force_link_libraries target visibility lib)
+ if(MSVC)
+ target_link_libraries(${target} ${visibility} "/WHOLEARCHIVE:${lib}")
+ elseif(APPLE)
+ target_link_libraries(${target} ${visibility} -Wl,-force_load ${lib})
+ else()
+ target_link_libraries(${target} ${visibility} -Wl,--whole-archive ${lib} -Wl,--no-whole-archive)
+ endif()
+endfunction()
+
+function(target_force_link_libraries target)
+ cmake_parse_arguments(FLINK
+ ""
+ ""
+ "PUBLIC;INTERFACE;PRIVATE"
+ ${ARGN}
+ )
+
+ foreach(lib IN LISTS FLINK_PUBLIC)
+ target_do_force_link_libraries(${target} PUBLIC ${lib})
+ endforeach()
+
+ foreach(lib IN LISTS FLINK_INTERFACE)
+ target_do_force_link_libraries(${target} INTERFACE ${lib})
+ endforeach()
+
+ foreach(lib IN LISTS FLINK_PRIVATE)
+ target_do_force_link_libraries(${target} PRIVATE ${lib})
+ endforeach()
+endfunction()
\ No newline at end of file
diff --git a/contrib/instr/.gitignore b/contrib/instr/.gitignore
new file mode 100644
index 0000000..88b59f2
--- /dev/null
+++ b/contrib/instr/.gitignore
@@ -0,0 +1 @@
+/*.yaml
\ No newline at end of file
diff --git a/contrib/instr/TGC5C_instr.yaml b/contrib/instr/TGC5C_instr.yaml
new file mode 100644
index 0000000..c1692e0
--- /dev/null
+++ b/contrib/instr/TGC5C_instr.yaml
@@ -0,0 +1,624 @@
+
+RVI:
+ LUI:
+ index: 0
+ encoding: 0b00000000000000000000000000110111
+ mask: 0b00000000000000000000000001111111
+ size: 32
+ branch: false
+ delay: 1
+ AUIPC:
+ index: 1
+ encoding: 0b00000000000000000000000000010111
+ mask: 0b00000000000000000000000001111111
+ size: 32
+ branch: false
+ delay: 1
+ JAL:
+ index: 2
+ encoding: 0b00000000000000000000000001101111
+ mask: 0b00000000000000000000000001111111
+ size: 32
+ branch: true
+ delay: 1
+ JALR:
+ index: 3
+ encoding: 0b00000000000000000000000001100111
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BEQ:
+ index: 4
+ encoding: 0b00000000000000000000000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BNE:
+ index: 5
+ encoding: 0b00000000000000000001000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BLT:
+ index: 6
+ encoding: 0b00000000000000000100000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BGE:
+ index: 7
+ encoding: 0b00000000000000000101000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BLTU:
+ index: 8
+ encoding: 0b00000000000000000110000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ BGEU:
+ index: 9
+ encoding: 0b00000000000000000111000001100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: true
+ delay: [1,1]
+ LB:
+ index: 10
+ encoding: 0b00000000000000000000000000000011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ LH:
+ index: 11
+ encoding: 0b00000000000000000001000000000011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ LW:
+ index: 12
+ encoding: 0b00000000000000000010000000000011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ LBU:
+ index: 13
+ encoding: 0b00000000000000000100000000000011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ LHU:
+ index: 14
+ encoding: 0b00000000000000000101000000000011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SB:
+ index: 15
+ encoding: 0b00000000000000000000000000100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SH:
+ index: 16
+ encoding: 0b00000000000000000001000000100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SW:
+ index: 17
+ encoding: 0b00000000000000000010000000100011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ ADDI:
+ index: 18
+ encoding: 0b00000000000000000000000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLTI:
+ index: 19
+ encoding: 0b00000000000000000010000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLTIU:
+ index: 20
+ encoding: 0b00000000000000000011000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ XORI:
+ index: 21
+ encoding: 0b00000000000000000100000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ ORI:
+ index: 22
+ encoding: 0b00000000000000000110000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ ANDI:
+ index: 23
+ encoding: 0b00000000000000000111000000010011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLLI:
+ index: 24
+ encoding: 0b00000000000000000001000000010011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SRLI:
+ index: 25
+ encoding: 0b00000000000000000101000000010011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SRAI:
+ index: 26
+ encoding: 0b01000000000000000101000000010011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ ADD:
+ index: 27
+ encoding: 0b00000000000000000000000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SUB:
+ index: 28
+ encoding: 0b01000000000000000000000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLL:
+ index: 29
+ encoding: 0b00000000000000000001000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLT:
+ index: 30
+ encoding: 0b00000000000000000010000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SLTU:
+ index: 31
+ encoding: 0b00000000000000000011000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ XOR:
+ index: 32
+ encoding: 0b00000000000000000100000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SRL:
+ index: 33
+ encoding: 0b00000000000000000101000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ SRA:
+ index: 34
+ encoding: 0b01000000000000000101000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ OR:
+ index: 35
+ encoding: 0b00000000000000000110000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ AND:
+ index: 36
+ encoding: 0b00000000000000000111000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ FENCE:
+ index: 37
+ encoding: 0b00000000000000000000000000001111
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ ECALL:
+ index: 38
+ encoding: 0b00000000000000000000000001110011
+ mask: 0b11111111111111111111111111111111
+ attributes: [[name:no_cont]]
+ size: 32
+ branch: false
+ delay: 1
+ EBREAK:
+ index: 39
+ encoding: 0b00000000000100000000000001110011
+ mask: 0b11111111111111111111111111111111
+ attributes: [[name:no_cont]]
+ size: 32
+ branch: false
+ delay: 1
+ MRET:
+ index: 40
+ encoding: 0b00110000001000000000000001110011
+ mask: 0b11111111111111111111111111111111
+ attributes: [[name:no_cont]]
+ size: 32
+ branch: false
+ delay: 1
+ WFI:
+ index: 41
+ encoding: 0b00010000010100000000000001110011
+ mask: 0b11111111111111111111111111111111
+ size: 32
+ branch: false
+ delay: 1
+Zicsr:
+ CSRRW:
+ index: 42
+ encoding: 0b00000000000000000001000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ CSRRS:
+ index: 43
+ encoding: 0b00000000000000000010000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ CSRRC:
+ index: 44
+ encoding: 0b00000000000000000011000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ CSRRWI:
+ index: 45
+ encoding: 0b00000000000000000101000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ CSRRSI:
+ index: 46
+ encoding: 0b00000000000000000110000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ CSRRCI:
+ index: 47
+ encoding: 0b00000000000000000111000001110011
+ mask: 0b00000000000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+Zifencei:
+ FENCE_I:
+ index: 48
+ encoding: 0b00000000000000000001000000001111
+ mask: 0b00000000000000000111000001111111
+ attributes: [[name:flush]]
+ size: 32
+ branch: false
+ delay: 1
+RV32M:
+ MUL:
+ index: 49
+ encoding: 0b00000010000000000000000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ MULH:
+ index: 50
+ encoding: 0b00000010000000000001000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ MULHSU:
+ index: 51
+ encoding: 0b00000010000000000010000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ MULHU:
+ index: 52
+ encoding: 0b00000010000000000011000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ DIV:
+ index: 53
+ encoding: 0b00000010000000000100000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ DIVU:
+ index: 54
+ encoding: 0b00000010000000000101000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ REM:
+ index: 55
+ encoding: 0b00000010000000000110000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+ REMU:
+ index: 56
+ encoding: 0b00000010000000000111000000110011
+ mask: 0b11111110000000000111000001111111
+ size: 32
+ branch: false
+ delay: 1
+Zca:
+ C__ADDI4SPN:
+ index: 57
+ encoding: 0b0000000000000000
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__LW:
+ index: 58
+ encoding: 0b0100000000000000
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__SW:
+ index: 59
+ encoding: 0b1100000000000000
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__ADDI:
+ index: 60
+ encoding: 0b0000000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__NOP:
+ index: 61
+ encoding: 0b0000000000000001
+ mask: 0b1110111110000011
+ size: 16
+ branch: false
+ delay: 1
+ C__JAL:
+ index: 62
+ encoding: 0b0010000000000001
+ mask: 0b1110000000000011
+ attributes: [[name:enable, value:1]]
+ size: 16
+ branch: true
+ delay: 1
+ C__LI:
+ index: 63
+ encoding: 0b0100000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__LUI:
+ index: 64
+ encoding: 0b0110000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__ADDI16SP:
+ index: 65
+ encoding: 0b0110000100000001
+ mask: 0b1110111110000011
+ size: 16
+ branch: false
+ delay: 1
+ __reserved_clui:
+ index: 66
+ encoding: 0b0110000000000001
+ mask: 0b1111000001111111
+ size: 16
+ branch: false
+ delay: 1
+ C__SRLI:
+ index: 67
+ encoding: 0b1000000000000001
+ mask: 0b1111110000000011
+ attributes: [[name:enable, value:1]]
+ size: 16
+ branch: false
+ delay: 1
+ C__SRAI:
+ index: 68
+ encoding: 0b1000010000000001
+ mask: 0b1111110000000011
+ attributes: [[name:enable, value:1]]
+ size: 16
+ branch: false
+ delay: 1
+ C__ANDI:
+ index: 69
+ encoding: 0b1000100000000001
+ mask: 0b1110110000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__SUB:
+ index: 70
+ encoding: 0b1000110000000001
+ mask: 0b1111110001100011
+ size: 16
+ branch: false
+ delay: 1
+ C__XOR:
+ index: 71
+ encoding: 0b1000110000100001
+ mask: 0b1111110001100011
+ size: 16
+ branch: false
+ delay: 1
+ C__OR:
+ index: 72
+ encoding: 0b1000110001000001
+ mask: 0b1111110001100011
+ size: 16
+ branch: false
+ delay: 1
+ C__AND:
+ index: 73
+ encoding: 0b1000110001100001
+ mask: 0b1111110001100011
+ size: 16
+ branch: false
+ delay: 1
+ C__J:
+ index: 74
+ encoding: 0b1010000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: true
+ delay: 1
+ C__BEQZ:
+ index: 75
+ encoding: 0b1100000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: true
+ delay: [1,1]
+ C__BNEZ:
+ index: 76
+ encoding: 0b1110000000000001
+ mask: 0b1110000000000011
+ size: 16
+ branch: true
+ delay: [1,1]
+ C__SLLI:
+ index: 77
+ encoding: 0b0000000000000010
+ mask: 0b1111000000000011
+ attributes: [[name:enable, value:1]]
+ size: 16
+ branch: false
+ delay: 1
+ C__LWSP:
+ index: 78
+ encoding: 0b0100000000000010
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__MV:
+ index: 79
+ encoding: 0b1000000000000010
+ mask: 0b1111000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__JR:
+ index: 80
+ encoding: 0b1000000000000010
+ mask: 0b1111000001111111
+ size: 16
+ branch: true
+ delay: 1
+ __reserved_cmv:
+ index: 81
+ encoding: 0b1000000000000010
+ mask: 0b1111111111111111
+ size: 16
+ branch: false
+ delay: 1
+ C__ADD:
+ index: 82
+ encoding: 0b1001000000000010
+ mask: 0b1111000000000011
+ size: 16
+ branch: false
+ delay: 1
+ C__JALR:
+ index: 83
+ encoding: 0b1001000000000010
+ mask: 0b1111000001111111
+ size: 16
+ branch: true
+ delay: 1
+ C__EBREAK:
+ index: 84
+ encoding: 0b1001000000000010
+ mask: 0b1111111111111111
+ size: 16
+ branch: false
+ delay: 1
+ C__SWSP:
+ index: 85
+ encoding: 0b1100000000000010
+ mask: 0b1110000000000011
+ size: 16
+ branch: false
+ delay: 1
+ DII:
+ index: 86
+ encoding: 0b0000000000000000
+ mask: 0b1111111111111111
+ size: 16
+ branch: false
+ delay: 1
+
diff --git a/contrib/instr/TGC5C_slow.yaml b/contrib/instr/TGC5C_slow.yaml
new file mode 100644
index 0000000..2aa7cac
--- /dev/null
+++ b/contrib/instr/TGC5C_slow.yaml
@@ -0,0 +1,650 @@
+RV32I:
+ ADD:
+ branch: false
+ delay: 1
+ encoding: 51
+ index: 27
+ mask: 4261441663
+ size: 32
+ ADDI:
+ branch: false
+ delay: 1
+ encoding: 19
+ index: 18
+ mask: 28799
+ size: 32
+ AND:
+ branch: false
+ delay: 1
+ encoding: 28723
+ index: 36
+ mask: 4261441663
+ size: 32
+ ANDI:
+ branch: false
+ delay: 1
+ encoding: 28691
+ index: 23
+ mask: 28799
+ size: 32
+ AUIPC:
+ branch: false
+ delay: 1
+ encoding: 23
+ index: 1
+ mask: 127
+ size: 32
+ BEQ:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 99
+ index: 4
+ mask: 28799
+ size: 32
+ BGE:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 20579
+ index: 7
+ mask: 28799
+ size: 32
+ BGEU:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 28771
+ index: 9
+ mask: 28799
+ size: 32
+ BLT:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 16483
+ index: 6
+ mask: 28799
+ size: 32
+ BLTU:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 24675
+ index: 8
+ mask: 28799
+ size: 32
+ BNE:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 4195
+ index: 5
+ mask: 28799
+ size: 32
+ EBREAK:
+ attributes:
+ - - name:no_cont
+ branch: false
+ delay: 3
+ encoding: 1048691
+ index: 39
+ mask: 4294967295
+ size: 32
+ ECALL:
+ attributes:
+ - - name:no_cont
+ branch: false
+ delay: 1
+ encoding: 115
+ index: 38
+ mask: 4294967295
+ size: 32
+ FENCE:
+ branch: false
+ delay: 1
+ encoding: 15
+ index: 37
+ mask: 28799
+ size: 32
+ JAL:
+ branch: true
+ delay: 2
+ encoding: 111
+ index: 2
+ mask: 127
+ size: 32
+ JALR:
+ branch: true
+ delay: 2
+ encoding: 103
+ index: 3
+ mask: 28799
+ size: 32
+ LB:
+ branch: false
+ delay: 2
+ encoding: 3
+ index: 10
+ mask: 28799
+ size: 32
+ LBU:
+ branch: false
+ delay: 2
+ encoding: 16387
+ index: 13
+ mask: 28799
+ size: 32
+ LH:
+ branch: false
+ delay: 2
+ encoding: 4099
+ index: 11
+ mask: 28799
+ size: 32
+ LHU:
+ branch: false
+ delay: 2
+ encoding: 20483
+ index: 14
+ mask: 28799
+ size: 32
+ LUI:
+ branch: false
+ delay: 1
+ encoding: 55
+ index: 0
+ mask: 127
+ size: 32
+ LW:
+ branch: false
+ delay: 2
+ encoding: 8195
+ index: 12
+ mask: 28799
+ size: 32
+ MRET:
+ attributes:
+ - - name:no_cont
+ branch: false
+ delay: 2
+ encoding: 807403635
+ index: 40
+ mask: 4294967295
+ size: 32
+ OR:
+ branch: false
+ delay: 1
+ encoding: 24627
+ index: 35
+ mask: 4261441663
+ size: 32
+ ORI:
+ branch: false
+ delay: 1
+ encoding: 24595
+ index: 22
+ mask: 28799
+ size: 32
+ SB:
+ branch: false
+ delay: 1
+ encoding: 35
+ index: 15
+ mask: 28799
+ size: 32
+ SH:
+ branch: false
+ delay: 1
+ encoding: 4131
+ index: 16
+ mask: 28799
+ size: 32
+ SLL:
+ branch: false
+ delay: X_24:20
+ encoding: 4147
+ index: 29
+ mask: 4261441663
+ size: 32
+ SLLI:
+ branch: false
+ delay: u_24:20
+ encoding: 4115
+ index: 24
+ mask: 4261441663
+ size: 32
+ SLT:
+ branch: false
+ delay: 1
+ encoding: 8243
+ index: 30
+ mask: 4261441663
+ size: 32
+ SLTI:
+ branch: false
+ delay: 1
+ encoding: 8211
+ index: 19
+ mask: 28799
+ size: 32
+ SLTIU:
+ branch: false
+ delay: 1
+ encoding: 12307
+ index: 20
+ mask: 28799
+ size: 32
+ SLTU:
+ branch: false
+ delay: 1
+ encoding: 12339
+ index: 31
+ mask: 4261441663
+ size: 32
+ SRA:
+ branch: false
+ delay: X_24:20
+ encoding: 1073762355
+ index: 34
+ mask: 4261441663
+ size: 32
+ SRAI:
+ branch: false
+ delay: u_24:20
+ encoding: 1073762323
+ index: 26
+ mask: 4261441663
+ size: 32
+ SRL:
+ branch: false
+ delay: X_24:20
+ encoding: 20531
+ index: 33
+ mask: 4261441663
+ size: 32
+ SRLI:
+ branch: false
+ delay: u_24:20
+ encoding: 20499
+ index: 25
+ mask: 4261441663
+ size: 32
+ SUB:
+ branch: false
+ delay: 1
+ encoding: 1073741875
+ index: 28
+ mask: 4261441663
+ size: 32
+ SW:
+ branch: false
+ delay: 1
+ encoding: 8227
+ index: 17
+ mask: 28799
+ size: 32
+ WFI:
+ branch: false
+ delay: 1
+ encoding: 273678451
+ index: 41
+ mask: 4294967295
+ size: 32
+ XOR:
+ branch: false
+ delay: 1
+ encoding: 16435
+ index: 32
+ mask: 4261441663
+ size: 32
+ XORI:
+ branch: false
+ delay: 1
+ encoding: 16403
+ index: 21
+ mask: 28799
+ size: 32
+RV32M:
+ DIV:
+ branch: false
+ delay: 33
+ encoding: 33570867
+ index: 53
+ mask: 4261441663
+ size: 32
+ DIVU:
+ branch: false
+ delay: 33
+ encoding: 33574963
+ index: 54
+ mask: 4261441663
+ size: 32
+ MUL:
+ branch: false
+ delay: 32
+ encoding: 33554483
+ index: 49
+ mask: 4261441663
+ size: 32
+ MULH:
+ branch: false
+ delay: 32
+ encoding: 33558579
+ index: 50
+ mask: 4261441663
+ size: 32
+ MULHSU:
+ branch: false
+ delay: 32
+ encoding: 33562675
+ index: 51
+ mask: 4261441663
+ size: 32
+ MULHU:
+ branch: false
+ delay: 32
+ encoding: 33566771
+ index: 52
+ mask: 4261441663
+ size: 32
+ REM:
+ branch: false
+ delay: 33
+ encoding: 33579059
+ index: 55
+ mask: 4261441663
+ size: 32
+ REMU:
+ branch: false
+ delay: 33
+ encoding: 33583155
+ index: 56
+ mask: 4261441663
+ size: 32
+Zca:
+ C__ADD:
+ branch: false
+ delay: 1
+ encoding: 36866
+ index: 82
+ mask: 61443
+ size: 16
+ C__ADDI:
+ branch: false
+ delay: 1
+ encoding: 1
+ index: 60
+ mask: 57347
+ size: 16
+ C__ADDI16SP:
+ branch: false
+ delay: 1
+ encoding: 24833
+ index: 65
+ mask: 61315
+ size: 16
+ C__ADDI4SPN:
+ branch: false
+ delay: 1
+ encoding: 0
+ index: 57
+ mask: 57347
+ size: 16
+ C__AND:
+ branch: false
+ delay: 1
+ encoding: 35937
+ index: 73
+ mask: 64611
+ size: 16
+ C__ANDI:
+ branch: false
+ delay: 1
+ encoding: 34817
+ index: 69
+ mask: 60419
+ size: 16
+ C__BEQZ:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 49153
+ index: 75
+ mask: 57347
+ size: 16
+ C__BNEZ:
+ branch: true
+ delay:
+ - 1
+ - 2
+ encoding: 57345
+ index: 76
+ mask: 57347
+ size: 16
+ C__EBREAK:
+ branch: false
+ delay: 3
+ encoding: 36866
+ index: 84
+ mask: 65535
+ size: 16
+ C__J:
+ branch: true
+ delay: 1
+ encoding: 40961
+ index: 74
+ mask: 57347
+ size: 16
+ C__JAL:
+ attributes:
+ - - name:enable
+ - value:1
+ branch: true
+ delay: 1
+ encoding: 8193
+ index: 62
+ mask: 57347
+ size: 16
+ C__JALR:
+ branch: true
+ delay: 1
+ encoding: 36866
+ index: 83
+ mask: 61567
+ size: 16
+ C__JR:
+ branch: true
+ delay: 1
+ encoding: 32770
+ index: 80
+ mask: 61567
+ size: 16
+ C__LI:
+ branch: false
+ delay: 1
+ encoding: 16385
+ index: 63
+ mask: 57347
+ size: 16
+ C__LUI:
+ branch: false
+ delay: 1
+ encoding: 24577
+ index: 64
+ mask: 57347
+ size: 16
+ C__LW:
+ branch: false
+ delay: 2
+ encoding: 16384
+ index: 58
+ mask: 57347
+ size: 16
+ C__LWSP:
+ branch: false
+ delay: 2
+ encoding: 16386
+ index: 78
+ mask: 57347
+ size: 16
+ C__MV:
+ branch: false
+ delay: 1
+ encoding: 32770
+ index: 79
+ mask: 61443
+ size: 16
+ C__NOP:
+ branch: false
+ delay: 1
+ encoding: 1
+ index: 61
+ mask: 61315
+ size: 16
+ C__OR:
+ branch: false
+ delay: 1
+ encoding: 35905
+ index: 72
+ mask: 64611
+ size: 16
+ C__SLLI:
+ attributes:
+ - - name:enable
+ - value:1
+ branch: false
+ delay: u_12:12*16+u_6:2
+ encoding: 2
+ index: 77
+ mask: 61443
+ size: 16
+ C__SRAI:
+ attributes:
+ - - name:enable
+ - value:1
+ branch: false
+ delay: u_12:12*16+u_6:2
+ encoding: 33793
+ index: 68
+ mask: 64515
+ size: 16
+ C__SRLI:
+ attributes:
+ - - name:enable
+ - value:1
+ branch: false
+ delay: u_12:12*16+u_6:2
+ encoding: 32769
+ index: 67
+ mask: 64515
+ size: 16
+ C__SUB:
+ branch: false
+ delay: 1
+ encoding: 35841
+ index: 70
+ mask: 64611
+ size: 16
+ C__SW:
+ branch: false
+ delay: 1
+ encoding: 49152
+ index: 59
+ mask: 57347
+ size: 16
+ C__SWSP:
+ branch: false
+ delay: 1
+ encoding: 49154
+ index: 85
+ mask: 57347
+ size: 16
+ C__XOR:
+ branch: false
+ delay: 1
+ encoding: 35873
+ index: 71
+ mask: 64611
+ size: 16
+ DII:
+ branch: false
+ delay: 1
+ encoding: 0
+ index: 86
+ mask: 65535
+ size: 16
+ __reserved_clui:
+ branch: false
+ delay: 1
+ encoding: 24577
+ index: 66
+ mask: 61567
+ size: 16
+ __reserved_cmv:
+ branch: false
+ delay: 1
+ encoding: 32770
+ index: 81
+ mask: 65535
+ size: 16
+Zicsr:
+ CSRRC:
+ branch: false
+ delay: 1
+ encoding: 12403
+ index: 44
+ mask: 28799
+ size: 32
+ CSRRCI:
+ branch: false
+ delay: 1
+ encoding: 28787
+ index: 47
+ mask: 28799
+ size: 32
+ CSRRS:
+ branch: false
+ delay: 1
+ encoding: 8307
+ index: 43
+ mask: 28799
+ size: 32
+ CSRRSI:
+ branch: false
+ delay: 1
+ encoding: 24691
+ index: 46
+ mask: 28799
+ size: 32
+ CSRRW:
+ branch: false
+ delay: 1
+ encoding: 4211
+ index: 42
+ mask: 28799
+ size: 32
+ CSRRWI:
+ branch: false
+ delay: 1
+ encoding: 20595
+ index: 45
+ mask: 28799
+ size: 32
+Zifencei:
+ FENCE_I:
+ attributes:
+ - - name:flush
+ branch: false
+ delay: 1
+ encoding: 4111
+ index: 48
+ mask: 28799
+ size: 32
diff --git a/contrib/pa/.gitignore b/contrib/pa/.gitignore
new file mode 100644
index 0000000..d534727
--- /dev/null
+++ b/contrib/pa/.gitignore
@@ -0,0 +1,3 @@
+/results
+/cwr
+/*.xml
diff --git a/contrib/pa/README.md b/contrib/pa/README.md
new file mode 100644
index 0000000..3c1c287
--- /dev/null
+++ b/contrib/pa/README.md
@@ -0,0 +1,43 @@
+# Notes
+
+* requires conan version 1.59
+* requires decent cmake version 3.23
+
+Setup for tcsh:
+
+```
+git clone --recursive -b develop https://git.minres.com/TGFS/TGC-ISS.git
+cd TGC-ISS/
+setenv TGFS_INSTALL_ROOT `pwd`/install
+setenv COWAREHOME
+setenv SNPSLMD_LICENSE_FILE
+source $COWAREHOME/SLS/linux/setup.csh pae
+setenv SNPS_ENABLE_MEM_ON_DEMAND_IN_GENERIC_MEM 1
+setenv PATH $COWAREHOME/common/bin/:${PATH}
+setenv CC $COWAREHOME/SLS/linux/common/bin/gcc
+setenv CXX $COWAREHOME/SLS/linux/common/bin/g++
+cmake -S . -B build/PA -DCMAKE_BUILD_TYPE=Debug -DUSE_CWR_SYSTEMC=ON -DBUILD_SHARED_LIBS=ON \
+ -DCODEGEN=OFF -DCMAKE_INSTALL_PREFIX=${TGFS_INSTALL_ROOT}
+cmake --build build/PA --target install -j16
+cd dbt-rise-tgc/contrib/pa
+# import the TGC core itself
+pct tgc_import_tb.tcl
+```
+
+Setup for bash:
+
+```
+git clone --recursive -b develop https://git.minres.com/TGFS/TGC-ISS.git
+cd TGC-ISS/
+export TGFS_INSTALL_ROOT `pwd`/install
+module load tools/pa/T-2022.06
+export SNPS_ENABLE_MEM_ON_DEMAND_IN_GENERIC_MEM=1
+export CC=$COWAREHOME/SLS/linux/common/bin/gcc
+export CXX=$COWAREHOME/SLS/linux/common/bin/g++
+cmake -S . -B build/PA -DCMAKE_BUILD_TYPE=Debug -DUSE_CWR_SYSTEMC=ON -DBUILD_SHARED_LIBS=ON \
+ -DCODEGEN=OFF -DCMAKE_INSTALL_PREFIX=${TGFS_INSTALL_ROOT}
+cmake --build build/PA --target install -j16
+cd dbt-rise-tgc/contrib/pa
+# import the TGC core itself
+pct tgc_import_tb.tcl
+```
\ No newline at end of file
diff --git a/contrib/build.tcl b/contrib/pa/build.tcl
similarity index 95%
rename from contrib/build.tcl
rename to contrib/pa/build.tcl
index 023815b..e4da561 100644
--- a/contrib/build.tcl
+++ b/contrib/pa/build.tcl
@@ -16,7 +16,7 @@ namespace eval Specification {
set libdir "${install_dir}/lib64"
set preprocessorOptions [concat $preprocessorOptions "-I${incldir}"]
# Set the Linker paths.
- set linkerOptions [concat $linkerOptions "-Wl,-rpath,${libdir} -L${libdir} -ldbt-rise-tgc_sc"]
+ set linkerOptions [concat $linkerOptions "-Wl,-rpath,${libdir} -L${libdir} -ldbt-rise-tgc_sc -lscc-sysc"]
}
default {
puts stderr "ERROR: \"$target\" is not supported, [::scsh::version]"
diff --git a/contrib/pa/hello.dis b/contrib/pa/hello.dis
new file mode 100644
index 0000000..ff86ca8
--- /dev/null
+++ b/contrib/pa/hello.dis
@@ -0,0 +1,2092 @@
+
+hello: file format elf32-littleriscv
+
+
+Disassembly of section .init:
+
+00000020 <_start>:
+ .section .init
+ .globl _start
+ .type _start,@function
+
+_start:
+ la gp, _gp
+ 20: 10000197 auipc gp,0x10000
+ 24: 7e018193 addi gp,gp,2016 # 10000800 <_gp>
+ la sp, _sp
+ 28: 10004117 auipc sp,0x10004
+ 2c: fd810113 addi sp,sp,-40 # 10004000 <_sp>
+
+ /* Load data section */
+ la a0, _data_lma
+ 30: 00001517 auipc a0,0x1
+ 34: 72850513 addi a0,a0,1832 # 1758 <_data_lma>
+ la a1, _data
+ 38: 10000597 auipc a1,0x10000
+ 3c: fc858593 addi a1,a1,-56 # 10000000 <_data>
+ la a2, _edata
+ 40: 10000617 auipc a2,0x10000
+ 44: fc860613 addi a2,a2,-56 # 10000008 <__bss_start>
+ bgeu a1, a2, 2f
+ 48: 00c5fc63 bgeu a1,a2,60 <_start+0x40>
+1:
+ lw t0, (a0)
+ 4c: 00052283 lw t0,0(a0)
+ sw t0, (a1)
+ 50: 0055a023 sw t0,0(a1)
+ addi a0, a0, 4
+ 54: 00450513 addi a0,a0,4
+ addi a1, a1, 4
+ 58: 00458593 addi a1,a1,4
+ bltu a1, a2, 1b
+ 5c: fec5e8e3 bltu a1,a2,4c <_start+0x2c>
+2:
+
+ /* Clear bss section */
+ la a0, __bss_start
+ 60: 10000517 auipc a0,0x10000
+ 64: fa850513 addi a0,a0,-88 # 10000008 <__bss_start>
+ la a1, _end
+ 68: 10000597 auipc a1,0x10000
+ 6c: fa058593 addi a1,a1,-96 # 10000008 <__bss_start>
+ bgeu a0, a1, 2f
+ 70: 00b57863 bgeu a0,a1,80 <_start+0x60>
+1:
+ sw zero, (a0)
+ 74: 00052023 sw zero,0(a0)
+ addi a0, a0, 4
+ 78: 00450513 addi a0,a0,4
+ bltu a0, a1, 1b
+ 7c: feb56ce3 bltu a0,a1,74 <_start+0x54>
+ fssr x0
+1:
+#endif
+
+ /* argc = argv = 0 */
+ li a0, 0
+ 80: 00000513 li a0,0
+ li a1, 0
+ 84: 00000593 li a1,0
+ call main
+ 88: 008000ef jal ra,90
+ tail _exit
+ 8c: 3300006f j 3bc <__wrap__exit>
+
+Disassembly of section .text:
+
+00000090 :
+ return result;
+
+}
+
+int main()
+{
+ 90: fe010113 addi sp,sp,-32
+ volatile int result = 1;
+ 94: 00100793 li a5,1
+{
+ 98: 00812c23 sw s0,24(sp)
+ 9c: 00912a23 sw s1,20(sp)
+ a0: 00112e23 sw ra,28(sp)
+ volatile int result = 1;
+ a4: 00f12623 sw a5,12(sp)
+ for (int ii = 1; ii <= i; ii++) {
+ a8: 00100413 li s0,1
+ ac: 00b00493 li s1,11
+ result = result * ii;
+ b0: 00c12503 lw a0,12(sp)
+ b4: 00040593 mv a1,s0
+ for (int ii = 1; ii <= i; ii++) {
+ b8: 00140413 addi s0,s0,1
+ result = result * ii;
+ bc: 2b0010ef jal ra,136c <__mulsi3>
+ c0: 00a12623 sw a0,12(sp)
+ for (int ii = 1; ii <= i; ii++) {
+ c4: fe9416e3 bne s0,s1,b0
+ return result;
+ c8: 00c12783 lw a5,12(sp)
+// *(uint32_t*)(GPIO_CTRL_ADDR+GPIO_IOF_SEL) &= ~IOF0_UART0_MASK;
+// *(uint32_t*)(GPIO_CTRL_ADDR+GPIO_IOF_EN) |= IOF0_UART0_MASK;
+ volatile int result = factorial (10);
+ printf("Factorial is %d\n", result);
+ cc: 00001517 auipc a0,0x1
+ d0: 3c450513 addi a0,a0,964 # 1490 <__clzsi2+0x4c>
+ volatile int result = factorial (10);
+ d4: 00f12423 sw a5,8(sp)
+ printf("Factorial is %d\n", result);
+ d8: 00812583 lw a1,8(sp)
+ dc: 285000ef jal ra,b60 <__wrap_printf>
+ printf("End of execution");
+ e0: 00001517 auipc a0,0x1
+ e4: 3c450513 addi a0,a0,964 # 14a4 <__clzsi2+0x60>
+ e8: 279000ef jal ra,b60 <__wrap_printf>
+ return 0;
+}
+ ec: 01c12083 lw ra,28(sp)
+ f0: 01812403 lw s0,24(sp)
+ f4: 01412483 lw s1,20(sp)
+ f8: 00000513 li a0,0
+ fc: 02010113 addi sp,sp,32
+ 100: 00008067 ret
+
+00000104 :
+
+ .section .text.entry
+ .align 2
+ .global trap_entry
+trap_entry:
+ addi sp, sp, -32*REGBYTES
+ 104: f8010113 addi sp,sp,-128
+
+ STORE x1, 1*REGBYTES(sp)
+ 108: 00112223 sw ra,4(sp)
+ STORE x2, 2*REGBYTES(sp)
+ 10c: 00212423 sw sp,8(sp)
+ STORE x3, 3*REGBYTES(sp)
+ 110: 00312623 sw gp,12(sp)
+ STORE x4, 4*REGBYTES(sp)
+ 114: 00412823 sw tp,16(sp)
+ STORE x5, 5*REGBYTES(sp)
+ 118: 00512a23 sw t0,20(sp)
+ STORE x6, 6*REGBYTES(sp)
+ 11c: 00612c23 sw t1,24(sp)
+ STORE x7, 7*REGBYTES(sp)
+ 120: 00712e23 sw t2,28(sp)
+ STORE x8, 8*REGBYTES(sp)
+ 124: 02812023 sw s0,32(sp)
+ STORE x9, 9*REGBYTES(sp)
+ 128: 02912223 sw s1,36(sp)
+ STORE x10, 10*REGBYTES(sp)
+ 12c: 02a12423 sw a0,40(sp)
+ STORE x11, 11*REGBYTES(sp)
+ 130: 02b12623 sw a1,44(sp)
+ STORE x12, 12*REGBYTES(sp)
+ 134: 02c12823 sw a2,48(sp)
+ STORE x13, 13*REGBYTES(sp)
+ 138: 02d12a23 sw a3,52(sp)
+ STORE x14, 14*REGBYTES(sp)
+ 13c: 02e12c23 sw a4,56(sp)
+ STORE x15, 15*REGBYTES(sp)
+ 140: 02f12e23 sw a5,60(sp)
+#ifndef __riscv_abi_rve
+ STORE x16, 16*REGBYTES(sp)
+ 144: 05012023 sw a6,64(sp)
+ STORE x17, 17*REGBYTES(sp)
+ 148: 05112223 sw a7,68(sp)
+ STORE x18, 18*REGBYTES(sp)
+ 14c: 05212423 sw s2,72(sp)
+ STORE x19, 19*REGBYTES(sp)
+ 150: 05312623 sw s3,76(sp)
+ STORE x20, 20*REGBYTES(sp)
+ 154: 05412823 sw s4,80(sp)
+ STORE x21, 21*REGBYTES(sp)
+ 158: 05512a23 sw s5,84(sp)
+ STORE x22, 22*REGBYTES(sp)
+ 15c: 05612c23 sw s6,88(sp)
+ STORE x23, 23*REGBYTES(sp)
+ 160: 05712e23 sw s7,92(sp)
+ STORE x24, 24*REGBYTES(sp)
+ 164: 07812023 sw s8,96(sp)
+ STORE x25, 25*REGBYTES(sp)
+ 168: 07912223 sw s9,100(sp)
+ STORE x26, 26*REGBYTES(sp)
+ 16c: 07a12423 sw s10,104(sp)
+ STORE x27, 27*REGBYTES(sp)
+ 170: 07b12623 sw s11,108(sp)
+ STORE x28, 28*REGBYTES(sp)
+ 174: 07c12823 sw t3,112(sp)
+ STORE x29, 29*REGBYTES(sp)
+ 178: 07d12a23 sw t4,116(sp)
+ STORE x30, 30*REGBYTES(sp)
+ 17c: 07e12c23 sw t5,120(sp)
+ STORE x31, 31*REGBYTES(sp)
+ 180: 07f12e23 sw t6,124(sp)
+#endif
+ csrr a0, mcause
+ 184: 34202573 csrr a0,mcause
+ csrr a1, mepc
+ 188: 341025f3 csrr a1,mepc
+ mv a2, sp
+ 18c: 00010613 mv a2,sp
+ call handle_trap
+ 190: 11c000ef jal ra,2ac
+ csrw mepc, a0
+ 194: 34151073 csrw mepc,a0
+
+ # Remain in M-mode after mret
+ li t0, MSTATUS_MPP
+ 198: 000022b7 lui t0,0x2
+ 19c: 80028293 addi t0,t0,-2048 # 1800 <_data_lma+0xa8>
+ csrs mstatus, t0
+ 1a0: 3002a073 csrs mstatus,t0
+
+ LOAD x1, 1*REGBYTES(sp)
+ 1a4: 00412083 lw ra,4(sp)
+ LOAD x2, 2*REGBYTES(sp)
+ 1a8: 00812103 lw sp,8(sp)
+ LOAD x3, 3*REGBYTES(sp)
+ 1ac: 00c12183 lw gp,12(sp)
+ LOAD x4, 4*REGBYTES(sp)
+ 1b0: 01012203 lw tp,16(sp)
+ LOAD x5, 5*REGBYTES(sp)
+ 1b4: 01412283 lw t0,20(sp)
+ LOAD x6, 6*REGBYTES(sp)
+ 1b8: 01812303 lw t1,24(sp)
+ LOAD x7, 7*REGBYTES(sp)
+ 1bc: 01c12383 lw t2,28(sp)
+ LOAD x8, 8*REGBYTES(sp)
+ 1c0: 02012403 lw s0,32(sp)
+ LOAD x9, 9*REGBYTES(sp)
+ 1c4: 02412483 lw s1,36(sp)
+ LOAD x10, 10*REGBYTES(sp)
+ 1c8: 02812503 lw a0,40(sp)
+ LOAD x11, 11*REGBYTES(sp)
+ 1cc: 02c12583 lw a1,44(sp)
+ LOAD x12, 12*REGBYTES(sp)
+ 1d0: 03012603 lw a2,48(sp)
+ LOAD x13, 13*REGBYTES(sp)
+ 1d4: 03412683 lw a3,52(sp)
+ LOAD x14, 14*REGBYTES(sp)
+ 1d8: 03812703 lw a4,56(sp)
+ LOAD x15, 15*REGBYTES(sp)
+ 1dc: 03c12783 lw a5,60(sp)
+#ifndef __riscv_abi_rve
+ LOAD x16, 16*REGBYTES(sp)
+ 1e0: 04012803 lw a6,64(sp)
+ LOAD x17, 17*REGBYTES(sp)
+ 1e4: 04412883 lw a7,68(sp)
+ LOAD x18, 18*REGBYTES(sp)
+ 1e8: 04812903 lw s2,72(sp)
+ LOAD x19, 19*REGBYTES(sp)
+ 1ec: 04c12983 lw s3,76(sp)
+ LOAD x20, 20*REGBYTES(sp)
+ 1f0: 05012a03 lw s4,80(sp)
+ LOAD x21, 21*REGBYTES(sp)
+ 1f4: 05412a83 lw s5,84(sp)
+ LOAD x22, 22*REGBYTES(sp)
+ 1f8: 05812b03 lw s6,88(sp)
+ LOAD x23, 23*REGBYTES(sp)
+ 1fc: 05c12b83 lw s7,92(sp)
+ LOAD x24, 24*REGBYTES(sp)
+ 200: 06012c03 lw s8,96(sp)
+ LOAD x25, 25*REGBYTES(sp)
+ 204: 06412c83 lw s9,100(sp)
+ LOAD x26, 26*REGBYTES(sp)
+ 208: 06812d03 lw s10,104(sp)
+ LOAD x27, 27*REGBYTES(sp)
+ 20c: 06c12d83 lw s11,108(sp)
+ LOAD x28, 28*REGBYTES(sp)
+ 210: 07012e03 lw t3,112(sp)
+ LOAD x29, 29*REGBYTES(sp)
+ 214: 07412e83 lw t4,116(sp)
+ LOAD x30, 30*REGBYTES(sp)
+ 218: 07812f03 lw t5,120(sp)
+ LOAD x31, 31*REGBYTES(sp)
+ 21c: 07c12f83 lw t6,124(sp)
+#endif
+ addi sp, sp, 32*REGBYTES
+ 220: 08010113 addi sp,sp,128
+ mret
+ 224: 30200073 mret
+
+.weak handle_trap
+handle_trap:
+1:
+ j 1b
+ 228: 0000006f j 228
+
+0000022c :
+int factorial(int i){
+ 22c: fe010113 addi sp,sp,-32
+ volatile int result = 1;
+ 230: 00100793 li a5,1
+int factorial(int i){
+ 234: 00112e23 sw ra,28(sp)
+ 238: 00812c23 sw s0,24(sp)
+ 23c: 00912a23 sw s1,20(sp)
+ volatile int result = 1;
+ 240: 00f12623 sw a5,12(sp)
+ for (int ii = 1; ii <= i; ii++) {
+ 244: 02a05263 blez a0,268
+ 248: 00150493 addi s1,a0,1
+ 24c: 00100413 li s0,1
+ result = result * ii;
+ 250: 00c12503 lw a0,12(sp)
+ 254: 00040593 mv a1,s0
+ for (int ii = 1; ii <= i; ii++) {
+ 258: 00140413 addi s0,s0,1
+ result = result * ii;
+ 25c: 110010ef jal ra,136c <__mulsi3>
+ 260: 00a12623 sw a0,12(sp)
+ for (int ii = 1; ii <= i; ii++) {
+ 264: fe9416e3 bne s0,s1,250
+}
+ 268: 01c12083 lw ra,28(sp)
+ 26c: 01812403 lw s0,24(sp)
+ return result;
+ 270: 00c12503 lw a0,12(sp)
+}
+ 274: 01412483 lw s1,20(sp)
+ 278: 02010113 addi sp,sp,32
+ 27c: 00008067 ret
+
+00000280 :
+#if __riscv_xlen==32
+
+static uint32_t mtime_hi(void)
+{
+ unsigned long ret;
+ __asm volatile("rdtimeh %0":"=r"(ret));
+ 280: c81027f3 rdtimeh a5
+ __asm volatile("rdtime %0":"=r"(ret));
+ 284: c0102573 rdtime a0
+ __asm volatile("rdtimeh %0":"=r"(ret));
+ 288: c81025f3 rdtimeh a1
+uint64_t get_timer_value()
+{
+ while (1) {
+ uint32_t hi = mtime_hi();
+ uint32_t lo = mtime_lo();
+ if (hi == mtime_hi())
+ 28c: fef59ae3 bne a1,a5,280
+ return ((uint64_t)hi << 32) | lo;
+ }
+}
+ 290: 00008067 ret
+
+00000294 :
+#endif
+
+unsigned long get_timer_freq()
+{
+ return 32768;
+}
+ 294: 00008537 lui a0,0x8
+ 298: 00008067 ret
+
+0000029c :
+
+unsigned long get_cpu_freq()
+{
+ return 10000000;
+ 29c: 00989537 lui a0,0x989
+}
+ 2a0: 68050513 addi a0,a0,1664 # 989680 <_data_lma+0x987f28>
+ 2a4: 00008067 ret
+
+000002a8 :
+
+void init_pll(void){
+
+}
+ 2a8: 00008067 ret
+
+000002ac :
+#ifdef USE_M_TIME
+extern void handle_m_time_interrupt();
+#endif
+
+uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc)
+{
+ 2ac: ff010113 addi sp,sp,-16
+ 2b0: 00812423 sw s0,8(sp)
+ } else if ((mcause & MCAUSE_INT) && ((mcause & MCAUSE_CAUSE) == IRQ_M_TIMER)){
+ handle_m_time_interrupt();
+#endif
+ }
+ else {
+ write(1, "trap\n", 5);
+ 2b4: 00500613 li a2,5
+{
+ 2b8: 00050413 mv s0,a0
+ write(1, "trap\n", 5);
+ 2bc: 00001597 auipc a1,0x1
+ 2c0: 1fc58593 addi a1,a1,508 # 14b8 <__clzsi2+0x74>
+ 2c4: 00100513 li a0,1
+{
+ 2c8: 00112623 sw ra,12(sp)
+ write(1, "trap\n", 5);
+ 2cc: 05c000ef jal ra,328 <__wrap_write>
+ _exit(1 + mcause);
+ 2d0: 00140513 addi a0,s0,1
+ 2d4: 0e8000ef jal ra,3bc <__wrap__exit>
+
+000002d8 <_init>:
+void _init()
+{
+
+#ifndef NO_INIT
+ init_pll();
+ printf("core freq at %d Hz\n", get_cpu_freq());
+ 2d8: 009895b7 lui a1,0x989
+{
+ 2dc: ff010113 addi sp,sp,-16
+ printf("core freq at %d Hz\n", get_cpu_freq());
+ 2e0: 68058593 addi a1,a1,1664 # 989680 <_data_lma+0x987f28>
+ 2e4: 00001517 auipc a0,0x1
+ 2e8: 1dc50513 addi a0,a0,476 # 14c0 <__clzsi2+0x7c>
+{
+ 2ec: 00112623 sw ra,12(sp)
+ printf("core freq at %d Hz\n", get_cpu_freq());
+ 2f0: 071000ef jal ra,b60 <__wrap_printf>
+ write_csr(mtvec, &trap_entry);
+ 2f4: 00000797 auipc a5,0x0
+ 2f8: e1078793 addi a5,a5,-496 # 104
+ 2fc: 30579073 csrw mtvec,a5
+ if (read_csr(misa) & (1 << ('F' - 'A'))) { // if F extension is present
+ 300: 301027f3 csrr a5,misa
+ 304: 0207f793 andi a5,a5,32
+ 308: 00078863 beqz a5,318 <_init+0x40>
+ write_csr(mstatus, MSTATUS_FS); // allow FPU instructions without trapping
+ 30c: 000067b7 lui a5,0x6
+ 310: 30079073 csrw mstatus,a5
+ write_csr(fcsr, 0); // initialize rounding mode, undefined at reset
+ 314: 00305073 csrwi fcsr,0
+ }
+#endif
+
+}
+ 318: 00c12083 lw ra,12(sp)
+ 31c: 01010113 addi sp,sp,16
+ 320: 00008067 ret
+
+00000324 <_fini>:
+
+void _fini()
+{
+}
+ 324: 00008067 ret
+
+00000328 <__wrap_write>:
+
+#include "platform.h"
+#include "stub.h"
+
+ssize_t __wrap_write(int fd, const void* ptr, size_t len)
+{
+ 328: ff010113 addi sp,sp,-16
+ 32c: 00812423 sw s0,8(sp)
+ 330: 00912223 sw s1,4(sp)
+ 334: 00112623 sw ra,12(sp)
+ 338: 00058413 mv s0,a1
+ 33c: 00060493 mv s1,a2
+ const uint8_t * current = (const char *)ptr;
+
+ if (isatty(fd)) {
+ 340: 070000ef jal ra,3b0 <__wrap_isatty>
+ 344: 06050263 beqz a0,3a8 <__wrap_write+0x80>
+ for (size_t jj = 0; jj < len; jj++) {
+ 348: 02048c63 beqz s1,380 <__wrap_write+0x58>
+ 34c: 00040593 mv a1,s0
+ 350: 00940833 add a6,s0,s1
+ while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
+ 354: ffff0737 lui a4,0xffff0
+ UART0_REG(UART_REG_TXFIFO) = current[jj];
+
+ if (current[jj] == '\n') {
+ 358: 00a00693 li a3,10
+ while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
+ UART0_REG(UART_REG_TXFIFO) = '\r';
+ 35c: 00d00613 li a2,13
+ while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
+ 360: 00072783 lw a5,0(a4) # ffff0000
+ 364: fe07cee3 bltz a5,360 <__wrap_write+0x38>
+ UART0_REG(UART_REG_TXFIFO) = current[jj];
+ 368: 0005c783 lbu a5,0(a1)
+ 36c: 00f72023 sw a5,0(a4)
+ if (current[jj] == '\n') {
+ 370: 0005c783 lbu a5,0(a1)
+ 374: 02d78263 beq a5,a3,398 <__wrap_write+0x70>
+ for (size_t jj = 0; jj < len; jj++) {
+ 378: 00158593 addi a1,a1,1
+ 37c: ff0592e3 bne a1,a6,360 <__wrap_write+0x38>
+ }
+ }
+ return len;
+ 380: 00048513 mv a0,s1
+ }
+
+ return _stub(EBADF);
+}
+ 384: 00c12083 lw ra,12(sp)
+ 388: 00812403 lw s0,8(sp)
+ 38c: 00412483 lw s1,4(sp)
+ 390: 01010113 addi sp,sp,16
+ 394: 00008067 ret
+ while (UART0_REG(UART_REG_TXFIFO) & 0x80000000) ;
+ 398: 00072783 lw a5,0(a4)
+ 39c: fe07cee3 bltz a5,398 <__wrap_write+0x70>
+ UART0_REG(UART_REG_TXFIFO) = '\r';
+ 3a0: 00c72023 sw a2,0(a4)
+ 3a4: fd5ff06f j 378 <__wrap_write+0x50>
+ return _stub(EBADF);
+ 3a8: fff00513 li a0,-1
+ 3ac: fd9ff06f j 384 <__wrap_write+0x5c>
+
+000003b0 <__wrap_isatty>:
+
+#include
+
+int __wrap_isatty(int fd)
+{
+ if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
+ 3b0: fff50513 addi a0,a0,-1
+ return 1;
+
+ return 0;
+}
+ 3b4: 00253513 sltiu a0,a0,2
+ 3b8: 00008067 ret
+
+000003bc <__wrap__exit>:
+extern volatile uint32_t fromhost;
+
+void __wrap__exit(int code)
+{
+//volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET);
+ const char message[] = "\nProgam has exited with code:";
+ 3bc: 00001797 auipc a5,0x1
+ 3c0: 11878793 addi a5,a5,280 # 14d4 <__clzsi2+0x90>
+ 3c4: 0007ae83 lw t4,0(a5)
+ 3c8: 0047ae03 lw t3,4(a5)
+ 3cc: 0087a303 lw t1,8(a5)
+ 3d0: 00c7a883 lw a7,12(a5)
+ 3d4: 0107a803 lw a6,16(a5)
+ 3d8: 0147a683 lw a3,20(a5)
+ 3dc: 0187a703 lw a4,24(a5)
+ 3e0: 01c7d783 lhu a5,28(a5)
+{
+ 3e4: fd010113 addi sp,sp,-48
+//*leds = (~(code));
+
+ write(STDERR_FILENO, message, sizeof(message) - 1);
+ 3e8: 01d00613 li a2,29
+{
+ 3ec: 02812423 sw s0,40(sp)
+ write(STDERR_FILENO, message, sizeof(message) - 1);
+ 3f0: 00010593 mv a1,sp
+{
+ 3f4: 00050413 mv s0,a0
+ write(STDERR_FILENO, message, sizeof(message) - 1);
+ 3f8: 00200513 li a0,2
+ const char message[] = "\nProgam has exited with code:";
+ 3fc: 00f11e23 sh a5,28(sp)
+{
+ 400: 02112623 sw ra,44(sp)
+ const char message[] = "\nProgam has exited with code:";
+ 404: 01d12023 sw t4,0(sp)
+ 408: 01c12223 sw t3,4(sp)
+ 40c: 00612423 sw t1,8(sp)
+ 410: 01112623 sw a7,12(sp)
+ 414: 01012823 sw a6,16(sp)
+ 418: 00d12a23 sw a3,20(sp)
+ 41c: 00e12c23 sw a4,24(sp)
+ write(STDERR_FILENO, message, sizeof(message) - 1);
+ 420: f09ff0ef jal ra,328 <__wrap_write>
+ write_hex(STDERR_FILENO, code);
+ 424: 00040593 mv a1,s0
+ 428: 00200513 li a0,2
+ 42c: 028000ef jal ra,454
+ write(STDERR_FILENO, "\n", 1);
+ 430: 00100613 li a2,1
+ 434: 00001597 auipc a1,0x1
+ 438: 08858593 addi a1,a1,136 # 14bc <__clzsi2+0x78>
+ 43c: 00200513 li a0,2
+ tohost = code+1;
+ 440: 00140413 addi s0,s0,1
+ write(STDERR_FILENO, "\n", 1);
+ 444: ee5ff0ef jal ra,328 <__wrap_write>
+ tohost = code+1;
+ 448: 00000797 auipc a5,0x0
+ 44c: ba87a423 sw s0,-1112(a5) # fffffff0
+ for (;;);
+ 450: 0000006f j 450 <__wrap__exit+0x94>
+
+00000454 :
+#include
+#include
+#include "platform.h"
+
+void write_hex(int fd, uint32_t hex)
+{
+ 454: fd010113 addi sp,sp,-48
+ 458: 02912223 sw s1,36(sp)
+ uint8_t ii;
+ uint8_t jj;
+ char towrite;
+ write(fd , "0x", 2);
+ 45c: 00200613 li a2,2
+{
+ 460: 00058493 mv s1,a1
+ write(fd , "0x", 2);
+ 464: 00001597 auipc a1,0x1
+ 468: 09058593 addi a1,a1,144 # 14f4 <__clzsi2+0xb0>
+{
+ 46c: 02812423 sw s0,40(sp)
+ 470: 03212023 sw s2,32(sp)
+ 474: 01312e23 sw s3,28(sp)
+ 478: 01412c23 sw s4,24(sp)
+ 47c: 01512a23 sw s5,20(sp)
+ 480: 02112623 sw ra,44(sp)
+ 484: 00050913 mv s2,a0
+ write(fd , "0x", 2);
+ 488: 01c00413 li s0,28
+ 48c: e9dff0ef jal ra,328 <__wrap_write>
+ for (ii = 8 ; ii > 0; ii--) {
+ jj = ii - 1;
+ uint8_t digit = ((hex & (0xF << (jj*4))) >> (jj*4));
+ 490: 00f00a93 li s5,15
+ towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
+ 494: 00900a13 li s4,9
+ for (ii = 8 ; ii > 0; ii--) {
+ 498: ffc00993 li s3,-4
+ 49c: 0240006f j 4c0
+ towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
+ 4a0: 0ff6f793 zext.b a5,a3
+ for (ii = 8 ; ii > 0; ii--) {
+ 4a4: ffc40413 addi s0,s0,-4
+ write(fd, &towrite, 1);
+ 4a8: 00100613 li a2,1
+ 4ac: 00f10593 addi a1,sp,15
+ 4b0: 00090513 mv a0,s2
+ towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
+ 4b4: 00f107a3 sb a5,15(sp)
+ write(fd, &towrite, 1);
+ 4b8: e71ff0ef jal ra,328 <__wrap_write>
+ for (ii = 8 ; ii > 0; ii--) {
+ 4bc: 05340063 beq s0,s3,4fc
+ uint8_t digit = ((hex & (0xF << (jj*4))) >> (jj*4));
+ 4c0: 008a97b3 sll a5,s5,s0
+ 4c4: 0097f7b3 and a5,a5,s1
+ 4c8: 0087d7b3 srl a5,a5,s0
+ 4cc: 0ff7f793 zext.b a5,a5
+ towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
+ 4d0: 03078693 addi a3,a5,48
+ 4d4: 03778713 addi a4,a5,55
+ 4d8: fcfa74e3 bgeu s4,a5,4a0
+ 4dc: 0ff77793 zext.b a5,a4
+ for (ii = 8 ; ii > 0; ii--) {
+ 4e0: ffc40413 addi s0,s0,-4
+ write(fd, &towrite, 1);
+ 4e4: 00100613 li a2,1
+ 4e8: 00f10593 addi a1,sp,15
+ 4ec: 00090513 mv a0,s2
+ towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA));
+ 4f0: 00f107a3 sb a5,15(sp)
+ write(fd, &towrite, 1);
+ 4f4: e35ff0ef jal ra,328 <__wrap_write>
+ for (ii = 8 ; ii > 0; ii--) {
+ 4f8: fd3414e3 bne s0,s3,4c0
+ }
+}
+ 4fc: 02c12083 lw ra,44(sp)
+ 500: 02812403 lw s0,40(sp)
+ 504: 02412483 lw s1,36(sp)
+ 508: 02012903 lw s2,32(sp)
+ 50c: 01c12983 lw s3,28(sp)
+ 510: 01812a03 lw s4,24(sp)
+ 514: 01412a83 lw s5,20(sp)
+ 518: 03010113 addi sp,sp,48
+ 51c: 00008067 ret
+
+00000520 :
+}
+
+static void sprintf_putch(int ch, void** data)
+{
+ char** pstr = (char**)data;
+ **pstr = ch;
+ 520: 0005a783 lw a5,0(a1)
+ 524: 00a78023 sb a0,0(a5)
+ (*pstr)++;
+ 528: 0005a783 lw a5,0(a1)
+ 52c: 00178793 addi a5,a5,1
+ 530: 00f5a023 sw a5,0(a1)
+}
+ 534: 00008067 ret
+
+00000538 :
+{
+ 538: fe010113 addi sp,sp,-32
+ 53c: 00a12623 sw a0,12(sp)
+ return write(STDOUT_FILENO, &ch, 1) == 1 ? ch : -1;
+ 540: 00100613 li a2,1
+ 544: 00c10593 addi a1,sp,12
+ 548: 00100513 li a0,1
+{
+ 54c: 00112e23 sw ra,28(sp)
+ return write(STDOUT_FILENO, &ch, 1) == 1 ? ch : -1;
+ 550: dd9ff0ef jal ra,328 <__wrap_write>
+ 554: 00100793 li a5,1
+ 558: 00f51a63 bne a0,a5,56c
+ 55c: 00c12503 lw a0,12(sp)
+}
+ 560: 01c12083 lw ra,28(sp)
+ 564: 02010113 addi sp,sp,32
+ 568: 00008067 ret
+ return write(STDOUT_FILENO, &ch, 1) == 1 ? ch : -1;
+ 56c: fff00513 li a0,-1
+ 570: ff1ff06f j 560
+
+00000574 :
+ for (char* p = buf; p < pbuf; p++)
+ putch(*p, putdat);
+}
+
+static void vprintfmt(void (*putch)(int, void**), void **putdat, const char *fmt, va_list ap)
+{
+ 574: f1010113 addi sp,sp,-240
+ 578: 0d512a23 sw s5,212(sp)
+ 57c: 40000ab7 lui s5,0x40000
+ 580: fffa8793 addi a5,s5,-1 # 3fffffff <_sp+0x2fffbfff>
+ 584: 0d912223 sw s9,196(sp)
+ u.u &= ~(1ULL << 63);
+ 588: 80000cb7 lui s9,0x80000
+ 58c: 00f12223 sw a5,4(sp)
+ 590: fffcc793 not a5,s9
+{
+ 594: 0e812423 sw s0,232(sp)
+ 598: 0e912223 sw s1,228(sp)
+ 59c: 0f212023 sw s2,224(sp)
+ 5a0: 0d312e23 sw s3,220(sp)
+ 5a4: 0e112623 sw ra,236(sp)
+ 5a8: 0d412c23 sw s4,216(sp)
+ 5ac: 0d612823 sw s6,208(sp)
+ 5b0: 0d712623 sw s7,204(sp)
+ 5b4: 0d812423 sw s8,200(sp)
+ 5b8: 0da12023 sw s10,192(sp)
+ 5bc: 0bb12e23 sw s11,188(sp)
+ 5c0: 00050913 mv s2,a0
+ 5c4: 00058493 mv s1,a1
+ 5c8: 00060413 mv s0,a2
+ 5cc: 00d12023 sw a3,0(sp)
+ unsigned long num;
+ int base, lflag, width, precision, altflag;
+ char padc;
+
+ while (1) {
+ while ((ch = *(unsigned char *) fmt) != '%') {
+ 5d0: 02500993 li s3,37
+ u.u &= ~(1ULL << 63);
+ 5d4: 00f12423 sw a5,8(sp)
+ while ((ch = *(unsigned char *) fmt) != '%') {
+ 5d8: 0140006f j 5ec
+ if (ch == '\0')
+ 5dc: 06050263 beqz a0,640
+ return;
+ fmt++;
+ putch(ch, putdat);
+ 5e0: 00048593 mv a1,s1
+ fmt++;
+ 5e4: 00140413 addi s0,s0,1
+ putch(ch, putdat);
+ 5e8: 000900e7 jalr s2
+ while ((ch = *(unsigned char *) fmt) != '%') {
+ 5ec: 00044503 lbu a0,0(s0)
+ 5f0: ff3516e3 bne a0,s3,5dc
+ width = -1;
+ precision = -1;
+ lflag = 0;
+ altflag = 0;
+ reswitch:
+ switch (ch = *(unsigned char *) fmt++) {
+ 5f4: 00144683 lbu a3,1(s0)
+ fmt++;
+ 5f8: 00140d93 addi s11,s0,1
+ 5fc: 000d8713 mv a4,s11
+ padc = ' ';
+ 600: 02000b93 li s7,32
+ precision = -1;
+ 604: fff00d13 li s10,-1
+ width = -1;
+ 608: fff00b13 li s6,-1
+ switch (ch = *(unsigned char *) fmt++) {
+ 60c: 05500593 li a1,85
+ case '8':
+ case '9':
+ for (precision = 0; ; ++fmt) {
+ precision = precision * 10 + ch - '0';
+ ch = *fmt;
+ if (ch < '0' || ch > '9')
+ 610: 00900513 li a0,9
+ switch (ch = *(unsigned char *) fmt++) {
+ 614: fdd68793 addi a5,a3,-35
+ 618: 0ff7f793 zext.b a5,a5
+ 61c: 00170413 addi s0,a4,1
+ 620: 06f5ec63 bltu a1,a5,698
+ 624: 00001617 auipc a2,0x1
+ 628: edc60613 addi a2,a2,-292 # 1500 <__clzsi2+0xbc>
+ 62c: 00279793 slli a5,a5,0x2
+ 630: 00c787b3 add a5,a5,a2
+ 634: 0007a783 lw a5,0(a5)
+ 638: 00c787b3 add a5,a5,a2
+ 63c: 00078067 jr a5
+ putch('%', putdat);
+ fmt = last_fmt;
+ break;
+ }
+ }
+}
+ 640: 0ec12083 lw ra,236(sp)
+ 644: 0e812403 lw s0,232(sp)
+ 648: 0e412483 lw s1,228(sp)
+ 64c: 0e012903 lw s2,224(sp)
+ 650: 0dc12983 lw s3,220(sp)
+ 654: 0d812a03 lw s4,216(sp)
+ 658: 0d412a83 lw s5,212(sp)
+ 65c: 0d012b03 lw s6,208(sp)
+ 660: 0cc12b83 lw s7,204(sp)
+ 664: 0c812c03 lw s8,200(sp)
+ 668: 0c412c83 lw s9,196(sp)
+ 66c: 0c012d03 lw s10,192(sp)
+ 670: 0bc12d83 lw s11,188(sp)
+ 674: 0f010113 addi sp,sp,240
+ 678: 00008067 ret
+ padc = '0';
+ 67c: 00068b93 mv s7,a3
+ goto reswitch;
+ 680: 00174683 lbu a3,1(a4)
+ switch (ch = *(unsigned char *) fmt++) {
+ 684: 00040713 mv a4,s0
+ 688: 00170413 addi s0,a4,1
+ 68c: fdd68793 addi a5,a3,-35
+ 690: 0ff7f793 zext.b a5,a5
+ 694: f8f5f8e3 bgeu a1,a5,624
+ putch('%', putdat);
+ 698: 00048593 mv a1,s1
+ 69c: 02500513 li a0,37
+ 6a0: 000900e7 jalr s2
+ fmt = last_fmt;
+ 6a4: 000d8413 mv s0,s11
+ break;
+ 6a8: f45ff06f j 5ec
+ ch = *fmt;
+ 6ac: 00174683 lbu a3,1(a4)
+ switch (ch = *(unsigned char *) fmt++) {
+ 6b0: 00040713 mv a4,s0
+ goto reswitch;
+ 6b4: f61ff06f j 614
+ ch = *fmt;
+ 6b8: 00174603 lbu a2,1(a4)
+ precision = precision * 10 + ch - '0';
+ 6bc: fd068d13 addi s10,a3,-48
+ switch (ch = *(unsigned char *) fmt++) {
+ 6c0: 00040713 mv a4,s0
+ if (ch < '0' || ch > '9')
+ 6c4: fd060793 addi a5,a2,-48
+ ch = *fmt;
+ 6c8: 00060693 mv a3,a2
+ if (ch < '0' || ch > '9')
+ 6cc: 02f56663 bltu a0,a5,6f8
+ precision = precision * 10 + ch - '0';
+ 6d0: 002d1793 slli a5,s10,0x2
+ 6d4: 01a787b3 add a5,a5,s10
+ for (precision = 0; ; ++fmt) {
+ 6d8: 00170713 addi a4,a4,1
+ precision = precision * 10 + ch - '0';
+ 6dc: 00179793 slli a5,a5,0x1
+ 6e0: 00c787b3 add a5,a5,a2
+ ch = *fmt;
+ 6e4: 00074603 lbu a2,0(a4)
+ precision = precision * 10 + ch - '0';
+ 6e8: fd078d13 addi s10,a5,-48
+ if (ch < '0' || ch > '9')
+ 6ec: fd060793 addi a5,a2,-48
+ ch = *fmt;
+ 6f0: 00060693 mv a3,a2
+ if (ch < '0' || ch > '9')
+ 6f4: fcf57ee3 bgeu a0,a5,6d0
+ if (width < 0)
+ 6f8: f00b5ee3 bgez s6,614
+ width = precision, precision = -1;
+ 6fc: 000d0b13 mv s6,s10
+ 700: fff00d13 li s10,-1
+ 704: f11ff06f j 614
+ putch(ch, putdat);
+ 708: 00048593 mv a1,s1
+ 70c: 02500513 li a0,37
+ 710: 000900e7 jalr s2
+ break;
+ 714: ed9ff06f j 5ec
+ precision = va_arg(ap, int);
+ 718: 00012783 lw a5,0(sp)
+ ch = *fmt;
+ 71c: 00174683 lbu a3,1(a4)
+ switch (ch = *(unsigned char *) fmt++) {
+ 720: 00040713 mv a4,s0
+ precision = va_arg(ap, int);
+ 724: 0007ad03 lw s10,0(a5)
+ 728: 00478793 addi a5,a5,4
+ 72c: 00f12023 sw a5,0(sp)
+ goto process_precision;
+ 730: fc9ff06f j 6f8
+ switch (ch = *(unsigned char *) fmt++) {
+ 734: 01000a93 li s5,16
+ return va_arg(*ap, unsigned int);
+ 738: 00012783 lw a5,0(sp)
+ 73c: 0007ac03 lw s8,0(a5)
+ 740: 00478793 addi a5,a5,4
+ 744: 00f12023 sw a5,0(sp)
+ digs[pos++] = num % base;
+ 748: 000a8593 mv a1,s5
+ 74c: 000c0513 mv a0,s8
+ 750: 491000ef jal ra,13e0 <__umodsi3>
+ 754: 02a12823 sw a0,48(sp)
+ 758: 00050d13 mv s10,a0
+ 75c: 03410a13 addi s4,sp,52
+ 760: 00100c93 li s9,1
+ if (num < base)
+ 764: 355c6e63 bltu s8,s5,ac0 <__stack_size+0x2c0>
+ num /= base;
+ 768: 000a8593 mv a1,s5
+ 76c: 000c0513 mv a0,s8
+ 770: 429000ef jal ra,1398 <__udivsi3>
+ digs[pos++] = num % base;
+ 774: 000a8593 mv a1,s5
+ num /= base;
+ 778: 00050c13 mv s8,a0
+ digs[pos++] = num % base;
+ 77c: 465000ef jal ra,13e0 <__umodsi3>
+ 780: 00aa2023 sw a0,0(s4)
+ 784: 000c8d93 mv s11,s9
+ 788: 00050d13 mv s10,a0
+ if (num < base)
+ 78c: 004a0a13 addi s4,s4,4
+ digs[pos++] = num % base;
+ 790: 001c8c93 addi s9,s9,1 # 80000001
+ if (num < base)
+ 794: fd5c7ae3 bgeu s8,s5,768
+ while (width-- > pos)
+ 798: 016cdc63 bge s9,s6,7b0
+ 79c: fffb0b13 addi s6,s6,-1
+ putch(padc, putdat);
+ 7a0: 00048593 mv a1,s1
+ 7a4: 000b8513 mv a0,s7
+ 7a8: 000900e7 jalr s2
+ while (width-- > pos)
+ 7ac: ff6cc8e3 blt s9,s6,79c
+ 7b0: 00412783 lw a5,4(sp)
+ 7b4: 02c10b93 addi s7,sp,44
+ putch(digs[pos] + (digs[pos] >= 10 ? 'a' - 10 : '0'), putdat);
+ 7b8: 00900b13 li s6,9
+ 7bc: 00fd8db3 add s11,s11,a5
+ 7c0: 002d9d93 slli s11,s11,0x2
+ 7c4: 03010793 addi a5,sp,48
+ 7c8: 01b78db3 add s11,a5,s11
+ 7cc: 00c0006f j 7d8
+ 7d0: 000dad03 lw s10,0(s11)
+ 7d4: ffcd8d93 addi s11,s11,-4
+ 7d8: 01ab37b3 sltu a5,s6,s10
+ 7dc: 40f007b3 neg a5,a5
+ 7e0: 0277f793 andi a5,a5,39
+ 7e4: 03078793 addi a5,a5,48
+ 7e8: 00048593 mv a1,s1
+ 7ec: 01a78533 add a0,a5,s10
+ 7f0: 000900e7 jalr s2
+ while (pos-- > 0)
+ 7f4: fdbb9ee3 bne s7,s11,7d0
+ 7f8: df5ff06f j 5ec
+ if ((p = va_arg(ap, char *)) == NULL)
+ 7fc: 00012783 lw a5,0(sp)
+ 800: 0007ad83 lw s11,0(a5)
+ 804: 00478a13 addi s4,a5,4
+ 808: 2e0d8c63 beqz s11,b00 <__stack_size+0x300>
+ if (width > 0 && padc != '-')
+ 80c: 0b605263 blez s6,8b0 <__stack_size+0xb0>
+ 810: 02d00793 li a5,45
+ 814: 04fb9e63 bne s7,a5,870 <__stack_size+0x70>
+ for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
+ 818: 000dc503 lbu a0,0(s11)
+ 81c: 02050863 beqz a0,84c <__stack_size+0x4c>
+ 820: fff00b93 li s7,-1
+ 824: 000d4663 bltz s10,830 <__stack_size+0x30>
+ 828: fffd0d13 addi s10,s10,-1
+ 82c: 017d0e63 beq s10,s7,848 <__stack_size+0x48>
+ putch(ch, putdat);
+ 830: 00048593 mv a1,s1
+ p++;
+ 834: 001d8d93 addi s11,s11,1
+ putch(ch, putdat);
+ 838: 000900e7 jalr s2
+ for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
+ 83c: 000dc503 lbu a0,0(s11)
+ 840: fffb0b13 addi s6,s6,-1
+ 844: fe0510e3 bnez a0,824 <__stack_size+0x24>
+ for (; width > 0; width--)
+ 848: 01605c63 blez s6,860 <__stack_size+0x60>
+ 84c: fffb0b13 addi s6,s6,-1
+ putch(' ', putdat);
+ 850: 00048593 mv a1,s1
+ 854: 02000513 li a0,32
+ 858: 000900e7 jalr s2
+ for (; width > 0; width--)
+ 85c: fe0b18e3 bnez s6,84c <__stack_size+0x4c>
+ if ((p = va_arg(ap, char *)) == NULL)
+ 860: 01412023 sw s4,0(sp)
+ 864: d89ff06f j 5ec
+ p = "(null)";
+ 868: 00001d97 auipc s11,0x1
+ 86c: c90d8d93 addi s11,s11,-880 # 14f8 <__clzsi2+0xb4>
+ while (n-- > 0 && *str) str++;
+ 870: 000d8793 mv a5,s11
+ 874: 01ad86b3 add a3,s11,s10
+ 878: 000d1863 bnez s10,888 <__stack_size+0x88>
+ 87c: 0200006f j 89c <__stack_size+0x9c>
+ 880: 00178793 addi a5,a5,1
+ 884: 00d78663 beq a5,a3,890 <__stack_size+0x90>
+ 888: 0007c703 lbu a4,0(a5)
+ 88c: fe071ae3 bnez a4,880 <__stack_size+0x80>
+ return str - start;
+ 890: 41b787b3 sub a5,a5,s11
+ for (width -= strnlen(p, precision); width > 0; width--)
+ 894: 40fb0b33 sub s6,s6,a5
+ 898: 01605c63 blez s6,8b0 <__stack_size+0xb0>
+ 89c: fffb0b13 addi s6,s6,-1
+ putch(padc, putdat);
+ 8a0: 00048593 mv a1,s1
+ 8a4: 000b8513 mv a0,s7
+ 8a8: 000900e7 jalr s2
+ for (width -= strnlen(p, precision); width > 0; width--)
+ 8ac: fe0b18e3 bnez s6,89c <__stack_size+0x9c>
+ for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
+ 8b0: 000dc503 lbu a0,0(s11)
+ 8b4: fa0506e3 beqz a0,860 <__stack_size+0x60>
+ 8b8: fff00b93 li s7,-1
+ 8bc: f69ff06f j 824 <__stack_size+0x24>
+ putch(va_arg(ap, int), putdat);
+ 8c0: 00012783 lw a5,0(sp)
+ 8c4: 00048593 mv a1,s1
+ 8c8: 0007a503 lw a0,0(a5)
+ 8cc: 00478a13 addi s4,a5,4
+ 8d0: 000900e7 jalr s2
+ 8d4: 01412023 sw s4,0(sp)
+ break;
+ 8d8: d15ff06f j 5ec
+ return va_arg(*ap, int);
+ 8dc: 00012783 lw a5,0(sp)
+ 8e0: 0007ac03 lw s8,0(a5)
+ 8e4: 00478a13 addi s4,a5,4
+ if ((long) num < 0) {
+ 8e8: 000c5a63 bgez s8,8fc <__stack_size+0xfc>
+ putch('-', putdat);
+ 8ec: 00048593 mv a1,s1
+ 8f0: 02d00513 li a0,45
+ 8f4: 000900e7 jalr s2
+ num = -(long) num;
+ 8f8: 41800c33 neg s8,s8
+ return va_arg(*ap, int);
+ 8fc: 01412023 sw s4,0(sp)
+ num = -(long) num;
+ 900: 00a00a93 li s5,10
+ 904: e45ff06f j 748
+ print_double(putch, putdat, va_arg(ap, double), width, precision);
+ 908: 00012783 lw a5,0(sp)
+ 90c: 00778a13 addi s4,a5,7
+ 910: ff8a7a13 andi s4,s4,-8
+ 914: 004a2d83 lw s11,4(s4)
+ 918: 000a2a83 lw s5,0(s4)
+ 91c: 008a0793 addi a5,s4,8
+ 920: 00f12023 sw a5,0(sp)
+ u.d = num;
+ 924: 000d8713 mv a4,s11
+ 928: 000a8693 mv a3,s5
+ if (u.u & (1ULL << 63)) {
+ 92c: 1a0dc063 bltz s11,acc <__stack_size+0x2cc>
+ for (int i = 0; i < prec; i++)
+ 930: 05a05263 blez s10,974 <__stack_size+0x174>
+ 934: 0ffff797 auipc a5,0xffff
+ 938: 6cc78793 addi a5,a5,1740 # 10000000 <_data>
+ u.d *= 10;
+ 93c: 0007ab03 lw s6,0(a5)
+ 940: 0047ab83 lw s7,4(a5)
+ for (int i = 0; i < prec; i++)
+ 944: 00000a13 li s4,0
+ u.d *= 10;
+ 948: 00068513 mv a0,a3
+ 94c: 00070593 mv a1,a4
+ 950: 000b8693 mv a3,s7
+ 954: 000b0613 mv a2,s6
+ 958: 2cc000ef jal ra,c24 <__muldf3>
+ for (int i = 0; i < prec; i++)
+ 95c: 001a0a13 addi s4,s4,1
+ u.d *= 10;
+ 960: 00050a93 mv s5,a0
+ 964: 00058d93 mv s11,a1
+ 968: 00050693 mv a3,a0
+ 96c: 00058713 mv a4,a1
+ for (int i = 0; i < prec; i++)
+ 970: fd4d1ce3 bne s10,s4,948 <__stack_size+0x148>
+ printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
+ 974: 000d8593 mv a1,s11
+ 978: 000a8513 mv a0,s5
+ 97c: 175000ef jal ra,12f0 <__fixunsdfsi>
+ digs[pos++] = num % base;
+ 980: 00a00593 li a1,10
+ printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
+ 984: 00050b13 mv s6,a0
+ digs[pos++] = num % base;
+ 988: 259000ef jal ra,13e0 <__umodsi3>
+ 98c: 02a12823 sw a0,48(sp)
+ if (num < base)
+ 990: 00900793 li a5,9
+ 994: 1967f663 bgeu a5,s6,b20 <__stack_size+0x320>
+ 998: 03410a13 addi s4,sp,52
+ digs[pos++] = num % base;
+ 99c: 00100d93 li s11,1
+ if (num < base)
+ 9a0: 06300b93 li s7,99
+ num /= base;
+ 9a4: 00a00593 li a1,10
+ 9a8: 000b0513 mv a0,s6
+ 9ac: 1ed000ef jal ra,1398 <__udivsi3>
+ digs[pos++] = num % base;
+ 9b0: 00a00593 li a1,10
+ 9b4: 000b0a93 mv s5,s6
+ num /= base;
+ 9b8: 00050b13 mv s6,a0
+ digs[pos++] = num % base;
+ 9bc: 225000ef jal ra,13e0 <__umodsi3>
+ 9c0: 00aa2023 sw a0,0(s4)
+ 9c4: 000d8613 mv a2,s11
+ if (num < base)
+ 9c8: 004a0a13 addi s4,s4,4
+ digs[pos++] = num % base;
+ 9cc: 001d8d93 addi s11,s11,1
+ if (num < base)
+ 9d0: fd5beae3 bltu s7,s5,9a4 <__stack_size+0x1a4>
+ 9d4: 03010813 addi a6,sp,48
+ 9d8: 00261713 slli a4,a2,0x2
+ 9dc: 00e80733 add a4,a6,a4
+ putch(digs[pos] + (digs[pos] >= 10 ? 'a' - 10 : '0'), putdat);
+ 9e0: 01010693 addi a3,sp,16
+ 9e4: 00900893 li a7,9
+ 9e8: 00c0006f j 9f4 <__stack_size+0x1f4>
+ 9ec: ffc72503 lw a0,-4(a4)
+ 9f0: 00058713 mv a4,a1
+ 9f4: 00a8b7b3 sltu a5,a7,a0
+ 9f8: 40f007b3 neg a5,a5
+ 9fc: 0277f793 andi a5,a5,39
+ a00: 03078793 addi a5,a5,48
+ a04: 00a787b3 add a5,a5,a0
+ **pstr = ch;
+ a08: 0ff7f793 zext.b a5,a5
+ a0c: 00f68023 sb a5,0(a3)
+ while (pos-- > 0)
+ a10: ffc70593 addi a1,a4,-4
+ (*pstr)++;
+ a14: 00168693 addi a3,a3,1
+ while (pos-- > 0)
+ a18: fce81ae3 bne a6,a4,9ec <__stack_size+0x1ec>
+ (*pstr)++;
+ a1c: 01160713 addi a4,a2,17
+ a20: 00270bb3 add s7,a4,sp
+ if (prec > 0) {
+ a24: 03a05a63 blez s10,a58 <__stack_size+0x258>
+ a28: 000b8713 mv a4,s7
+ a2c: 41ab86b3 sub a3,s7,s10
+ a30: 0080006f j a38 <__stack_size+0x238>
+ pbuf[-i] = pbuf[-i-1];
+ a34: fff74783 lbu a5,-1(a4)
+ a38: 00f70023 sb a5,0(a4)
+ for (int i = 0; i < prec; i++) {
+ a3c: fff70713 addi a4,a4,-1
+ a40: fed71ae3 bne a4,a3,a34 <__stack_size+0x234>
+ pbuf[-prec] = '.';
+ a44: 41ab8bb3 sub s7,s7,s10
+ a48: 02e00793 li a5,46
+ a4c: 00fb8023 sb a5,0(s7)
+ pbuf++;
+ a50: 01260793 addi a5,a2,18
+ a54: 00278bb3 add s7,a5,sp
+ for (char* p = buf; p < pbuf; p++)
+ a58: 01010b13 addi s6,sp,16
+ a5c: b97b78e3 bgeu s6,s7,5ec
+ putch(*p, putdat);
+ a60: 000b4503 lbu a0,0(s6)
+ a64: 00048593 mv a1,s1
+ for (char* p = buf; p < pbuf; p++)
+ a68: 001b0b13 addi s6,s6,1
+ putch(*p, putdat);
+ a6c: 000900e7 jalr s2
+ for (char* p = buf; p < pbuf; p++)
+ a70: ff7b18e3 bne s6,s7,a60 <__stack_size+0x260>
+ a74: b79ff06f j 5ec
+ putch('0', putdat);
+ a78: 03000513 li a0,48
+ a7c: 00048593 mv a1,s1
+ a80: 000900e7 jalr s2
+ putch('x', putdat);
+ a84: 00048593 mv a1,s1
+ a88: 07800513 li a0,120
+ a8c: 000900e7 jalr s2
+ return va_arg(*ap, unsigned long);
+ a90: 00012783 lw a5,0(sp)
+ a94: 01000a93 li s5,16
+ a98: 00478793 addi a5,a5,4
+ a9c: 00f12023 sw a5,0(sp)
+ aa0: ffc7ac03 lw s8,-4(a5)
+ aa4: ca5ff06f j 748
+ if (width < 0)
+ aa8: fffb4793 not a5,s6
+ aac: 41f7d793 srai a5,a5,0x1f
+ ch = *fmt;
+ ab0: 00174683 lbu a3,1(a4)
+ ab4: 00fb7b33 and s6,s6,a5
+ switch (ch = *(unsigned char *) fmt++) {
+ ab8: 00040713 mv a4,s0
+ goto reswitch;
+ abc: b59ff06f j 614
+ while (width-- > pos)
+ ac0: 00000d93 li s11,0
+ ac4: cd6ccce3 blt s9,s6,79c
+ ac8: ce9ff06f j 7b0
+ putch('-', putdat);
+ acc: 00048593 mv a1,s1
+ ad0: 02d00513 li a0,45
+ ad4: 01512623 sw s5,12(sp)
+ ad8: 000900e7 jalr s2
+ u.u &= ~(1ULL << 63);
+ adc: 00812783 lw a5,8(sp)
+ printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
+ ae0: 00c12683 lw a3,12(sp)
+ u.u &= ~(1ULL << 63);
+ ae4: 01b7f733 and a4,a5,s11
+ printnum(sprintf_putch, (void**)&pbuf, (unsigned long)u.d, 10, 0, 0);
+ ae8: 00070d93 mv s11,a4
+ aec: e45ff06f j 930 <__stack_size+0x130>
+ switch (ch = *(unsigned char *) fmt++) {
+ af0: 00800a93 li s5,8
+ af4: c45ff06f j 738
+ af8: 00a00a93 li s5,10
+ afc: c3dff06f j 738
+ if (width > 0 && padc != '-')
+ b00: 01605663 blez s6,b0c <__stack_size+0x30c>
+ b04: 02d00793 li a5,45
+ b08: d6fb90e3 bne s7,a5,868 <__stack_size+0x68>
+ b0c: 00001d97 auipc s11,0x1
+ b10: 9ecd8d93 addi s11,s11,-1556 # 14f8 <__clzsi2+0xb4>
+ for (; (ch = *p) != '\0' && (precision < 0 || --precision >= 0); width--) {
+ b14: 02800513 li a0,40
+ b18: fff00b93 li s7,-1
+ b1c: d09ff06f j 824 <__stack_size+0x24>
+ while (pos-- > 0)
+ b20: 00000613 li a2,0
+ b24: eb1ff06f j 9d4 <__stack_size+0x1d4>
+
+00000b28 :
+ while (n-- > 0 && *str) str++;
+ b28: 00b506b3 add a3,a0,a1
+ b2c: 00050793 mv a5,a0
+ b30: 00059863 bnez a1,b40
+ b34: 0240006f j b58
+ b38: 00178793 addi a5,a5,1
+ b3c: 00f68a63 beq a3,a5,b50
+ b40: 0007c703 lbu a4,0(a5)
+ b44: fe071ae3 bnez a4,b38
+ return str - start;
+ b48: 40a78533 sub a0,a5,a0
+}
+ b4c: 00008067 ret
+ return str - start;
+ b50: 40a68533 sub a0,a3,a0
+ b54: 00008067 ret
+ while (n-- > 0 && *str) str++;
+ b58: 00000513 li a0,0
+ b5c: 00008067 ret
+
+00000b60 <__wrap_printf>:
+
+int __wrap_printf(const char* fmt, ...)
+{
+ b60: fc010113 addi sp,sp,-64
+ va_list ap;
+ va_start(ap, fmt);
+ b64: 02410313 addi t1,sp,36
+{
+ b68: 00050e13 mv t3,a0
+ b6c: 02b12223 sw a1,36(sp)
+ b70: 02c12423 sw a2,40(sp)
+ b74: 02d12623 sw a3,44(sp)
+
+ vprintfmt((void*)putchar, 0, fmt, ap);
+ b78: 00000517 auipc a0,0x0
+ b7c: 9c050513 addi a0,a0,-1600 # 538
+ b80: 00030693 mv a3,t1
+ b84: 000e0613 mv a2,t3
+ b88: 00000593 li a1,0
+{
+ b8c: 00112e23 sw ra,28(sp)
+ b90: 02e12823 sw a4,48(sp)
+ b94: 02f12a23 sw a5,52(sp)
+ b98: 03012c23 sw a6,56(sp)
+ b9c: 03112e23 sw a7,60(sp)
+ va_start(ap, fmt);
+ ba0: 00612623 sw t1,12(sp)
+ vprintfmt((void*)putchar, 0, fmt, ap);
+ ba4: 9d1ff0ef jal ra,574
+
+ va_end(ap);
+ return 0; // incorrect return value, but who cares, anyway?
+}
+ ba8: 01c12083 lw ra,28(sp)
+ bac: 00000513 li a0,0
+ bb0: 04010113 addi sp,sp,64
+ bb4: 00008067 ret
+
+00000bb8 <__wrap_sprintf>:
+
+int __wrap_sprintf(char* str, const char* fmt, ...)
+{
+ bb8: fb010113 addi sp,sp,-80
+ va_list ap;
+ char* str0 = str;
+ va_start(ap, fmt);
+ bbc: 03810313 addi t1,sp,56
+{
+ bc0: 02812423 sw s0,40(sp)
+ bc4: 00a12623 sw a0,12(sp)
+ bc8: 02c12c23 sw a2,56(sp)
+ bcc: 02d12e23 sw a3,60(sp)
+ char* str0 = str;
+ bd0: 00050413 mv s0,a0
+
+ vprintfmt(sprintf_putch, (void**)&str, fmt, ap);
+ bd4: 00058613 mv a2,a1
+ bd8: 00000517 auipc a0,0x0
+ bdc: 94850513 addi a0,a0,-1720 # 520
+ be0: 00c10593 addi a1,sp,12
+ be4: 00030693 mv a3,t1
+{
+ be8: 02112623 sw ra,44(sp)
+ bec: 04f12223 sw a5,68(sp)
+ bf0: 04e12023 sw a4,64(sp)
+ bf4: 05012423 sw a6,72(sp)
+ bf8: 05112623 sw a7,76(sp)
+ va_start(ap, fmt);
+ bfc: 00612e23 sw t1,28(sp)
+ vprintfmt(sprintf_putch, (void**)&str, fmt, ap);
+ c00: 975ff0ef jal ra,574
+ *str = 0;
+ c04: 00c12783 lw a5,12(sp)
+ c08: 00078023 sb zero,0(a5)
+
+ va_end(ap);
+ return str - str0;
+ c0c: 00c12503 lw a0,12(sp)
+}
+ c10: 02c12083 lw ra,44(sp)
+ c14: 40850533 sub a0,a0,s0
+ c18: 02812403 lw s0,40(sp)
+ c1c: 05010113 addi sp,sp,80
+ c20: 00008067 ret
+
+00000c24 <__muldf3>:
+#include "soft-fp.h"
+#include "double.h"
+
+DFtype
+__muldf3 (DFtype a, DFtype b)
+{
+ c24: fd010113 addi sp,sp,-48
+ c28: 01312e23 sw s3,28(sp)
+ FP_DECL_D (B);
+ FP_DECL_D (R);
+ DFtype r;
+
+ FP_INIT_ROUNDMODE;
+ FP_UNPACK_D (A, a);
+ c2c: 0145d993 srli s3,a1,0x14
+{
+ c30: 02812423 sw s0,40(sp)
+ c34: 02912223 sw s1,36(sp)
+ c38: 01412c23 sw s4,24(sp)
+ c3c: 01512a23 sw s5,20(sp)
+ c40: 01712623 sw s7,12(sp)
+ FP_UNPACK_D (A, a);
+ c44: 00c59493 slli s1,a1,0xc
+{
+ c48: 02112623 sw ra,44(sp)
+ c4c: 03212023 sw s2,32(sp)
+ c50: 01612823 sw s6,16(sp)
+ FP_UNPACK_D (A, a);
+ c54: 7ff9f993 andi s3,s3,2047
+{
+ c58: 00050413 mv s0,a0
+ c5c: 00060b93 mv s7,a2
+ c60: 00068a13 mv s4,a3
+ FP_UNPACK_D (A, a);
+ c64: 00c4d493 srli s1,s1,0xc
+ c68: 01f5da93 srli s5,a1,0x1f
+ c6c: 3c098863 beqz s3,103c <__muldf3+0x418>
+ c70: 7ff00793 li a5,2047
+ c74: 42f98663 beq s3,a5,10a0 <__muldf3+0x47c>
+ c78: 00349493 slli s1,s1,0x3
+ c7c: 01d55793 srli a5,a0,0x1d
+ c80: 0097e7b3 or a5,a5,s1
+ c84: 008004b7 lui s1,0x800
+ c88: 0097e4b3 or s1,a5,s1
+ c8c: 00351913 slli s2,a0,0x3
+ c90: c0198993 addi s3,s3,-1023
+ c94: 00000b13 li s6,0
+ FP_UNPACK_D (B, b);
+ c98: 014a5713 srli a4,s4,0x14
+ c9c: 00ca1413 slli s0,s4,0xc
+ ca0: 7ff77713 andi a4,a4,2047
+ ca4: 00c45413 srli s0,s0,0xc
+ ca8: 01fa5a13 srli s4,s4,0x1f
+ cac: 42070663 beqz a4,10d8 <__muldf3+0x4b4>
+ cb0: 7ff00793 li a5,2047
+ cb4: 48f70663 beq a4,a5,1140 <__muldf3+0x51c>
+ cb8: 00341413 slli s0,s0,0x3
+ cbc: 01dbd793 srli a5,s7,0x1d
+ cc0: 0087e7b3 or a5,a5,s0
+ cc4: 00800437 lui s0,0x800
+ cc8: 0087e433 or s0,a5,s0
+ ccc: c0170713 addi a4,a4,-1023
+ cd0: 003b9793 slli a5,s7,0x3
+ cd4: 00000613 li a2,0
+ FP_MUL_D (R, A, B);
+ cd8: 00e989b3 add s3,s3,a4
+ cdc: 002b1713 slli a4,s6,0x2
+ ce0: 00c76733 or a4,a4,a2
+ ce4: 00a00693 li a3,10
+ ce8: 014ac833 xor a6,s5,s4
+ cec: 00198893 addi a7,s3,1
+ cf0: 4ce6c863 blt a3,a4,11c0 <__muldf3+0x59c>
+ cf4: 00200693 li a3,2
+ cf8: 48e6c063 blt a3,a4,1178 <__muldf3+0x554>
+ cfc: fff70713 addi a4,a4,-1
+ d00: 00100693 li a3,1
+ d04: 48e6fc63 bgeu a3,a4,119c <__muldf3+0x578>
+ d08: 00010a37 lui s4,0x10
+ d0c: fffa0393 addi t2,s4,-1 # ffff <_data_lma+0xe8a7>
+ d10: 0107d293 srli t0,a5,0x10
+ d14: 00797e33 and t3,s2,t2
+ d18: 0077f7b3 and a5,a5,t2
+ d1c: 01095f93 srli t6,s2,0x10
+ d20: 000e0513 mv a0,t3
+ d24: 00078593 mv a1,a5
+ d28: 644000ef jal ra,136c <__mulsi3>
+ d2c: 00050e93 mv t4,a0
+ d30: 00028593 mv a1,t0
+ d34: 000e0513 mv a0,t3
+ d38: 634000ef jal ra,136c <__mulsi3>
+ d3c: 00050713 mv a4,a0
+ d40: 00078593 mv a1,a5
+ d44: 000f8513 mv a0,t6
+ d48: 624000ef jal ra,136c <__mulsi3>
+ d4c: 00050913 mv s2,a0
+ d50: 00028593 mv a1,t0
+ d54: 000f8513 mv a0,t6
+ d58: 614000ef jal ra,136c <__mulsi3>
+ d5c: 010ed313 srli t1,t4,0x10
+ d60: 01270733 add a4,a4,s2
+ d64: 00e30333 add t1,t1,a4
+ d68: 00050f13 mv t5,a0
+ d6c: 01237463 bgeu t1,s2,d74 <__muldf3+0x150>
+ d70: 01450f33 add t5,a0,s4
+ d74: 01035913 srli s2,t1,0x10
+ d78: 00737333 and t1,t1,t2
+ d7c: 007efeb3 and t4,t4,t2
+ d80: 01031313 slli t1,t1,0x10
+ d84: 007473b3 and t2,s0,t2
+ d88: 01d30333 add t1,t1,t4
+ d8c: 01045a13 srli s4,s0,0x10
+ d90: 000e0513 mv a0,t3
+ d94: 00038593 mv a1,t2
+ d98: 5d4000ef jal ra,136c <__mulsi3>
+ d9c: 00050e93 mv t4,a0
+ da0: 000a0593 mv a1,s4
+ da4: 000e0513 mv a0,t3
+ da8: 5c4000ef jal ra,136c <__mulsi3>
+ dac: 00050e13 mv t3,a0
+ db0: 00038593 mv a1,t2
+ db4: 000f8513 mv a0,t6
+ db8: 5b4000ef jal ra,136c <__mulsi3>
+ dbc: 00050413 mv s0,a0
+ dc0: 000a0593 mv a1,s4
+ dc4: 000f8513 mv a0,t6
+ dc8: 5a4000ef jal ra,136c <__mulsi3>
+ dcc: 010ed713 srli a4,t4,0x10
+ dd0: 008e0e33 add t3,t3,s0
+ dd4: 01c70733 add a4,a4,t3
+ dd8: 00050693 mv a3,a0
+ ddc: 00877663 bgeu a4,s0,de8 <__muldf3+0x1c4>
+ de0: 00010637 lui a2,0x10
+ de4: 00c506b3 add a3,a0,a2
+ de8: 00010b37 lui s6,0x10
+ dec: fffb0e13 addi t3,s6,-1 # ffff <_data_lma+0xe8a7>
+ df0: 01075f93 srli t6,a4,0x10
+ df4: 01c77733 and a4,a4,t3
+ df8: 01071713 slli a4,a4,0x10
+ dfc: 01cefeb3 and t4,t4,t3
+ e00: 01d70eb3 add t4,a4,t4
+ e04: 01c4fe33 and t3,s1,t3
+ e08: 00df8fb3 add t6,t6,a3
+ e0c: 01d90933 add s2,s2,t4
+ e10: 0104da93 srli s5,s1,0x10
+ e14: 000e0513 mv a0,t3
+ e18: 00078593 mv a1,a5
+ e1c: 550000ef jal ra,136c <__mulsi3>
+ e20: 00050413 mv s0,a0
+ e24: 00028593 mv a1,t0
+ e28: 000e0513 mv a0,t3
+ e2c: 540000ef jal ra,136c <__mulsi3>
+ e30: 00050493 mv s1,a0
+ e34: 00078593 mv a1,a5
+ e38: 000a8513 mv a0,s5
+ e3c: 530000ef jal ra,136c <__mulsi3>
+ e40: 00050b93 mv s7,a0
+ e44: 00028593 mv a1,t0
+ e48: 000a8513 mv a0,s5
+ e4c: 520000ef jal ra,136c <__mulsi3>
+ e50: 01045793 srli a5,s0,0x10
+ e54: 017484b3 add s1,s1,s7
+ e58: 009787b3 add a5,a5,s1
+ e5c: 00050713 mv a4,a0
+ e60: 0177f463 bgeu a5,s7,e68 <__muldf3+0x244>
+ e64: 01650733 add a4,a0,s6
+ e68: 000104b7 lui s1,0x10
+ e6c: fff48693 addi a3,s1,-1 # ffff <_data_lma+0xe8a7>
+ e70: 0107d293 srli t0,a5,0x10
+ e74: 00e282b3 add t0,t0,a4
+ e78: 00d7f733 and a4,a5,a3
+ e7c: 00d47433 and s0,s0,a3
+ e80: 01071713 slli a4,a4,0x10
+ e84: 00870733 add a4,a4,s0
+ e88: 000e0513 mv a0,t3
+ e8c: 00038593 mv a1,t2
+ e90: 4dc000ef jal ra,136c <__mulsi3>
+ e94: 00050413 mv s0,a0
+ e98: 000a0593 mv a1,s4
+ e9c: 000e0513 mv a0,t3
+ ea0: 4cc000ef jal ra,136c <__mulsi3>
+ ea4: 00050e13 mv t3,a0
+ ea8: 00038593 mv a1,t2
+ eac: 000a8513 mv a0,s5
+ eb0: 4bc000ef jal ra,136c <__mulsi3>
+ eb4: 00050393 mv t2,a0
+ eb8: 000a0593 mv a1,s4
+ ebc: 000a8513 mv a0,s5
+ ec0: 4ac000ef jal ra,136c <__mulsi3>
+ ec4: 01045793 srli a5,s0,0x10
+ ec8: 007e0e33 add t3,t3,t2
+ ecc: 01c78e33 add t3,a5,t3
+ ed0: 00050593 mv a1,a0
+ ed4: 007e7463 bgeu t3,t2,edc <__muldf3+0x2b8>
+ ed8: 009505b3 add a1,a0,s1
+ edc: 000106b7 lui a3,0x10
+ ee0: fff68693 addi a3,a3,-1 # ffff <_data_lma+0xe8a7>
+ ee4: 00de77b3 and a5,t3,a3
+ ee8: 00d47433 and s0,s0,a3
+ eec: 01079793 slli a5,a5,0x10
+ ef0: 012f0f33 add t5,t5,s2
+ ef4: 008787b3 add a5,a5,s0
+ ef8: 01df3eb3 sltu t4,t5,t4
+ efc: 01f787b3 add a5,a5,t6
+ f00: 01d78533 add a0,a5,t4
+ f04: 00ef0f33 add t5,t5,a4
+ f08: 00ef3733 sltu a4,t5,a4
+ f0c: 005506b3 add a3,a0,t0
+ f10: 00e68633 add a2,a3,a4
+ f14: 01f7b433 sltu s0,a5,t6
+ f18: 01d53533 sltu a0,a0,t4
+ f1c: 010e5793 srli a5,t3,0x10
+ f20: 00e63733 sltu a4,a2,a4
+ f24: 00a46433 or s0,s0,a0
+ f28: 0056b6b3 sltu a3,a3,t0
+ f2c: 00f40433 add s0,s0,a5
+ f30: 00e6e6b3 or a3,a3,a4
+ f34: 00d40433 add s0,s0,a3
+ f38: 00b40433 add s0,s0,a1
+ f3c: 01765793 srli a5,a2,0x17
+ f40: 00941413 slli s0,s0,0x9
+ f44: 00f46433 or s0,s0,a5
+ f48: 009f1793 slli a5,t5,0x9
+ f4c: 0067e7b3 or a5,a5,t1
+ f50: 00f037b3 snez a5,a5
+ f54: 017f5f13 srli t5,t5,0x17
+ f58: 00961713 slli a4,a2,0x9
+ f5c: 01e7e7b3 or a5,a5,t5
+ f60: 00e7e7b3 or a5,a5,a4
+ f64: 01000737 lui a4,0x1000
+ f68: 00e47733 and a4,s0,a4
+ f6c: 28070663 beqz a4,11f8 <__muldf3+0x5d4>
+ f70: 0017d713 srli a4,a5,0x1
+ f74: 0017f793 andi a5,a5,1
+ f78: 00f76733 or a4,a4,a5
+ f7c: 01f41793 slli a5,s0,0x1f
+ f80: 00f767b3 or a5,a4,a5
+ f84: 00145413 srli s0,s0,0x1
+ FP_PACK_D (r, R);
+ f88: 3ff88693 addi a3,a7,1023
+ f8c: 26d05a63 blez a3,1200 <__muldf3+0x5dc>
+ f90: 0077f713 andi a4,a5,7
+ f94: 02070063 beqz a4,fb4 <__muldf3+0x390>
+ f98: 00f7f713 andi a4,a5,15
+ f9c: 00400613 li a2,4
+ fa0: 00c70a63 beq a4,a2,fb4 <__muldf3+0x390>
+ fa4: 00478713 addi a4,a5,4
+ fa8: 00f737b3 sltu a5,a4,a5
+ fac: 00f40433 add s0,s0,a5
+ fb0: 00070793 mv a5,a4
+ fb4: 01000737 lui a4,0x1000
+ fb8: 00e47733 and a4,s0,a4
+ fbc: 00070a63 beqz a4,fd0 <__muldf3+0x3ac>
+ fc0: ff000737 lui a4,0xff000
+ fc4: fff70713 addi a4,a4,-1 # feffffff
+ fc8: 00e47433 and s0,s0,a4
+ fcc: 40088693 addi a3,a7,1024
+ fd0: 7fe00713 li a4,2046
+ fd4: 2ed74e63 blt a4,a3,12d0 <__muldf3+0x6ac>
+ fd8: 01d41713 slli a4,s0,0x1d
+ fdc: 0037d793 srli a5,a5,0x3
+ fe0: 00f76733 or a4,a4,a5
+ fe4: 00345413 srli s0,s0,0x3
+ fe8: 7ff007b7 lui a5,0x7ff00
+ fec: 01469693 slli a3,a3,0x14
+ ff0: 00c41413 slli s0,s0,0xc
+ ff4: 00f6f6b3 and a3,a3,a5
+ ff8: 00c45413 srli s0,s0,0xc
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
+ ffc: 02c12083 lw ra,44(sp)
+ FP_PACK_D (r, R);
+ 1000: 0086e6b3 or a3,a3,s0
+}
+ 1004: 02812403 lw s0,40(sp)
+ FP_PACK_D (r, R);
+ 1008: 01f81813 slli a6,a6,0x1f
+ 100c: 0106e7b3 or a5,a3,a6
+}
+ 1010: 02412483 lw s1,36(sp)
+ 1014: 02012903 lw s2,32(sp)
+ 1018: 01c12983 lw s3,28(sp)
+ 101c: 01812a03 lw s4,24(sp)
+ 1020: 01412a83 lw s5,20(sp)
+ 1024: 01012b03 lw s6,16(sp)
+ 1028: 00c12b83 lw s7,12(sp)
+ 102c: 00070513 mv a0,a4
+ 1030: 00078593 mv a1,a5
+ 1034: 03010113 addi sp,sp,48
+ 1038: 00008067 ret
+ FP_UNPACK_D (A, a);
+ 103c: 00a4e933 or s2,s1,a0
+ 1040: 06090c63 beqz s2,10b8 <__muldf3+0x494>
+ 1044: 04048063 beqz s1,1084 <__muldf3+0x460>
+ 1048: 00048513 mv a0,s1
+ 104c: 3f8000ef jal ra,1444 <__clzsi2>
+ 1050: ff550713 addi a4,a0,-11
+ 1054: 01c00793 li a5,28
+ 1058: 02e7cc63 blt a5,a4,1090 <__muldf3+0x46c>
+ 105c: 01d00793 li a5,29
+ 1060: ff850913 addi s2,a0,-8
+ 1064: 40e787b3 sub a5,a5,a4
+ 1068: 012494b3 sll s1,s1,s2
+ 106c: 00f457b3 srl a5,s0,a5
+ 1070: 0097e4b3 or s1,a5,s1
+ 1074: 01241933 sll s2,s0,s2
+ 1078: c0d00993 li s3,-1011
+ 107c: 40a989b3 sub s3,s3,a0
+ 1080: c15ff06f j c94 <__muldf3+0x70>
+ 1084: 3c0000ef jal ra,1444 <__clzsi2>
+ 1088: 02050513 addi a0,a0,32
+ 108c: fc5ff06f j 1050 <__muldf3+0x42c>
+ 1090: fd850493 addi s1,a0,-40
+ 1094: 009414b3 sll s1,s0,s1
+ 1098: 00000913 li s2,0
+ 109c: fddff06f j 1078 <__muldf3+0x454>
+ 10a0: 00a4e933 or s2,s1,a0
+ 10a4: 02090263 beqz s2,10c8 <__muldf3+0x4a4>
+ 10a8: 00050913 mv s2,a0
+ 10ac: 7ff00993 li s3,2047
+ 10b0: 00300b13 li s6,3
+ 10b4: be5ff06f j c98 <__muldf3+0x74>
+ 10b8: 00000493 li s1,0
+ 10bc: 00000993 li s3,0
+ 10c0: 00100b13 li s6,1
+ 10c4: bd5ff06f j c98 <__muldf3+0x74>
+ 10c8: 00000493 li s1,0
+ 10cc: 7ff00993 li s3,2047
+ 10d0: 00200b13 li s6,2
+ 10d4: bc5ff06f j c98 <__muldf3+0x74>
+ FP_UNPACK_D (B, b);
+ 10d8: 017467b3 or a5,s0,s7
+ 10dc: 06078e63 beqz a5,1158 <__muldf3+0x534>
+ 10e0: 04040063 beqz s0,1120 <__muldf3+0x4fc>
+ 10e4: 00040513 mv a0,s0
+ 10e8: 35c000ef jal ra,1444 <__clzsi2>
+ 10ec: ff550693 addi a3,a0,-11
+ 10f0: 01c00793 li a5,28
+ 10f4: 02d7ce63 blt a5,a3,1130 <__muldf3+0x50c>
+ 10f8: 01d00713 li a4,29
+ 10fc: ff850793 addi a5,a0,-8
+ 1100: 40d70733 sub a4,a4,a3
+ 1104: 00f41433 sll s0,s0,a5
+ 1108: 00ebd733 srl a4,s7,a4
+ 110c: 00876433 or s0,a4,s0
+ 1110: 00fb97b3 sll a5,s7,a5
+ 1114: c0d00713 li a4,-1011
+ 1118: 40a70733 sub a4,a4,a0
+ 111c: bb9ff06f j cd4 <__muldf3+0xb0>
+ 1120: 000b8513 mv a0,s7
+ 1124: 320000ef jal ra,1444 <__clzsi2>
+ 1128: 02050513 addi a0,a0,32
+ 112c: fc1ff06f j 10ec <__muldf3+0x4c8>
+ 1130: fd850413 addi s0,a0,-40
+ 1134: 008b9433 sll s0,s7,s0
+ 1138: 00000793 li a5,0
+ 113c: fd9ff06f j 1114 <__muldf3+0x4f0>
+ 1140: 017467b3 or a5,s0,s7
+ 1144: 02078263 beqz a5,1168 <__muldf3+0x544>
+ 1148: 000b8793 mv a5,s7
+ 114c: 7ff00713 li a4,2047
+ 1150: 00300613 li a2,3
+ 1154: b85ff06f j cd8 <__muldf3+0xb4>
+ 1158: 00000413 li s0,0
+ 115c: 00000713 li a4,0
+ 1160: 00100613 li a2,1
+ 1164: b75ff06f j cd8 <__muldf3+0xb4>
+ 1168: 00000413 li s0,0
+ 116c: 7ff00713 li a4,2047
+ 1170: 00200613 li a2,2
+ 1174: b65ff06f j cd8 <__muldf3+0xb4>
+ 1178: 00100693 li a3,1
+ 117c: 00e696b3 sll a3,a3,a4
+ 1180: 5306f713 andi a4,a3,1328
+ 1184: 04071863 bnez a4,11d4 <__muldf3+0x5b0>
+ 1188: 2406f593 andi a1,a3,576
+ 118c: 12059463 bnez a1,12b4 <__muldf3+0x690>
+ 1190: 0886f693 andi a3,a3,136
+ 1194: b6068ae3 beqz a3,d08 <__muldf3+0xe4>
+ 1198: 000a0813 mv a6,s4
+ FP_PACK_D (r, R);
+ 119c: 00200713 li a4,2
+ 11a0: 12e60863 beq a2,a4,12d0 <__muldf3+0x6ac>
+ 11a4: 00300713 li a4,3
+ 11a8: 10e60e63 beq a2,a4,12c4 <__muldf3+0x6a0>
+ 11ac: 00100713 li a4,1
+ 11b0: dce61ce3 bne a2,a4,f88 <__muldf3+0x364>
+ 11b4: 00000413 li s0,0
+ 11b8: 00000713 li a4,0
+ 11bc: 0bc0006f j 1278 <__muldf3+0x654>
+ FP_MUL_D (R, A, B);
+ 11c0: 00f00693 li a3,15
+ 11c4: 02d70063 beq a4,a3,11e4 <__muldf3+0x5c0>
+ 11c8: 00b00693 li a3,11
+ 11cc: fcd706e3 beq a4,a3,1198 <__muldf3+0x574>
+ FP_UNPACK_D (A, a);
+ 11d0: 000a8813 mv a6,s5
+ FP_MUL_D (R, A, B);
+ 11d4: 00048413 mv s0,s1
+ 11d8: 00090793 mv a5,s2
+ 11dc: 000b0613 mv a2,s6
+ 11e0: fbdff06f j 119c <__muldf3+0x578>
+ 11e4: 00080437 lui s0,0x80
+ 11e8: 00000793 li a5,0
+ 11ec: 00000813 li a6,0
+ 11f0: 00300613 li a2,3
+ 11f4: fb1ff06f j 11a4 <__muldf3+0x580>
+ 11f8: 00098893 mv a7,s3
+ 11fc: d8dff06f j f88 <__muldf3+0x364>
+ FP_PACK_D (r, R);
+ 1200: 00100613 li a2,1
+ 1204: 40d60633 sub a2,a2,a3
+ 1208: 03800713 li a4,56
+ 120c: fac744e3 blt a4,a2,11b4 <__muldf3+0x590>
+ 1210: 01f00713 li a4,31
+ 1214: 06c74663 blt a4,a2,1280 <__muldf3+0x65c>
+ 1218: 41e88893 addi a7,a7,1054
+ 121c: 01141733 sll a4,s0,a7
+ 1220: 00c7d6b3 srl a3,a5,a2
+ 1224: 011798b3 sll a7,a5,a7
+ 1228: 00d76733 or a4,a4,a3
+ 122c: 011038b3 snez a7,a7
+ 1230: 011767b3 or a5,a4,a7
+ 1234: 00c45433 srl s0,s0,a2
+ 1238: 0077f713 andi a4,a5,7
+ 123c: 02070063 beqz a4,125c <__muldf3+0x638>
+ 1240: 00f7f713 andi a4,a5,15
+ 1244: 00400693 li a3,4
+ 1248: 00d70a63 beq a4,a3,125c <__muldf3+0x638>
+ 124c: 00478713 addi a4,a5,4 # 7ff00004 <_sp+0x6fefc004>
+ 1250: 00f737b3 sltu a5,a4,a5
+ 1254: 00f40433 add s0,s0,a5
+ 1258: 00070793 mv a5,a4
+ 125c: 00800737 lui a4,0x800
+ 1260: 00e47733 and a4,s0,a4
+ 1264: 06071e63 bnez a4,12e0 <__muldf3+0x6bc>
+ 1268: 01d41713 slli a4,s0,0x1d
+ 126c: 0037d793 srli a5,a5,0x3
+ 1270: 00f76733 or a4,a4,a5
+ 1274: 00345413 srli s0,s0,0x3
+ 1278: 00000693 li a3,0
+ 127c: d6dff06f j fe8 <__muldf3+0x3c4>
+ 1280: fe100713 li a4,-31
+ 1284: 40d70733 sub a4,a4,a3
+ 1288: 02000593 li a1,32
+ 128c: 00e45733 srl a4,s0,a4
+ 1290: 00000693 li a3,0
+ 1294: 00b60663 beq a2,a1,12a0 <__muldf3+0x67c>
+ 1298: 43e88893 addi a7,a7,1086
+ 129c: 011416b3 sll a3,s0,a7
+ 12a0: 00f6e6b3 or a3,a3,a5
+ 12a4: 00d036b3 snez a3,a3
+ 12a8: 00d767b3 or a5,a4,a3
+ 12ac: 00000413 li s0,0
+ 12b0: f89ff06f j 1238 <__muldf3+0x614>
+ FP_MUL_D (R, A, B);
+ 12b4: 00080437 lui s0,0x80
+ FP_PACK_D (r, R);
+ 12b8: 7ff00693 li a3,2047
+ 12bc: 00000813 li a6,0
+ 12c0: d29ff06f j fe8 <__muldf3+0x3c4>
+ 12c4: 00080437 lui s0,0x80
+ 12c8: 00000713 li a4,0
+ 12cc: fedff06f j 12b8 <__muldf3+0x694>
+ 12d0: 00000413 li s0,0
+ 12d4: 00000713 li a4,0
+ 12d8: 7ff00693 li a3,2047
+ 12dc: d0dff06f j fe8 <__muldf3+0x3c4>
+ 12e0: 00000413 li s0,0
+ 12e4: 00000713 li a4,0
+ 12e8: 00100693 li a3,1
+ 12ec: cfdff06f j fe8 <__muldf3+0x3c4>
+
+000012f0 <__fixunsdfsi>:
+ FP_DECL_EX;
+ FP_DECL_D (A);
+ USItype r;
+
+ FP_INIT_EXCEPTIONS;
+ FP_UNPACK_RAW_D (A, a);
+ 12f0: 0145d713 srli a4,a1,0x14
+ 12f4: 00100637 lui a2,0x100
+{
+ 12f8: 00050693 mv a3,a0
+ FP_UNPACK_RAW_D (A, a);
+ 12fc: fff60793 addi a5,a2,-1 # fffff <_data_lma+0xfe8a7>
+ 1300: 7ff77713 andi a4,a4,2047
+ FP_TO_INT_D (r, A, SI_BITS, 0);
+ 1304: 3fe00513 li a0,1022
+ FP_UNPACK_RAW_D (A, a);
+ 1308: 00b7f7b3 and a5,a5,a1
+ 130c: 01f5d593 srli a1,a1,0x1f
+ FP_TO_INT_D (r, A, SI_BITS, 0);
+ 1310: 04e55a63 bge a0,a4,1364 <__fixunsdfsi+0x74>
+ 1314: 00000513 li a0,0
+ 1318: 00059863 bnez a1,1328 <__fixunsdfsi+0x38>
+ 131c: 41e00593 li a1,1054
+ 1320: fff00513 li a0,-1
+ 1324: 00e5d463 bge a1,a4,132c <__fixunsdfsi+0x3c>
+ FP_HANDLE_EXCEPTIONS;
+
+ return r;
+}
+ 1328: 00008067 ret
+ FP_TO_INT_D (r, A, SI_BITS, 0);
+ 132c: 00c7e7b3 or a5,a5,a2
+ 1330: 43300613 li a2,1075
+ 1334: 40e60633 sub a2,a2,a4
+ 1338: 01f00593 li a1,31
+ 133c: 00c5cc63 blt a1,a2,1354 <__fixunsdfsi+0x64>
+ 1340: bed70713 addi a4,a4,-1043 # 7ffbed <_data_lma+0x7fe495>
+ 1344: 00e797b3 sll a5,a5,a4
+ 1348: 00c6d533 srl a0,a3,a2
+ 134c: 00a7e533 or a0,a5,a0
+ 1350: 00008067 ret
+ 1354: 41300693 li a3,1043
+ 1358: 40e68733 sub a4,a3,a4
+ 135c: 00e7d533 srl a0,a5,a4
+ 1360: 00008067 ret
+ 1364: 00000513 li a0,0
+ 1368: 00008067 ret
+
+0000136c <__mulsi3>:
+/* Our RV64 64-bit routine is equivalent to our RV32 32-bit routine. */
+# define __muldi3 __mulsi3
+#endif
+
+FUNC_BEGIN (__muldi3)
+ mv a2, a0
+ 136c: 00050613 mv a2,a0
+ li a0, 0
+ 1370: 00000513 li a0,0
+.L1:
+ andi a3, a1, 1
+ 1374: 0015f693 andi a3,a1,1
+ beqz a3, .L2
+ 1378: 00068463 beqz a3,1380 <__mulsi3+0x14>
+ add a0, a0, a2
+ 137c: 00c50533 add a0,a0,a2
+.L2:
+ srli a1, a1, 1
+ 1380: 0015d593 srli a1,a1,0x1
+ slli a2, a2, 1
+ 1384: 00161613 slli a2,a2,0x1
+ bnez a1, .L1
+ 1388: fe0596e3 bnez a1,1374 <__mulsi3+0x8>
+ ret
+ 138c: 00008067 ret
+
+00001390 <__divsi3>:
+ li t0, -1
+ beq a1, t0, .L20
+#endif
+
+FUNC_BEGIN (__divdi3)
+ bltz a0, .L10
+ 1390: 06054063 bltz a0,13f0 <__umodsi3+0x10>
+ bltz a1, .L11
+ 1394: 0605c663 bltz a1,1400 <__umodsi3+0x20>
+
+00001398 <__udivsi3>:
+ /* Since the quotient is positive, fall into __udivdi3. */
+
+FUNC_BEGIN (__udivdi3)
+ mv a2, a1
+ 1398: 00058613 mv a2,a1
+ mv a1, a0
+ 139c: 00050593 mv a1,a0
+ li a0, -1
+ 13a0: fff00513 li a0,-1
+ beqz a2, .L5
+ 13a4: 02060c63 beqz a2,13dc <__udivsi3+0x44>
+ li a3, 1
+ 13a8: 00100693 li a3,1
+ bgeu a2, a1, .L2
+ 13ac: 00b67a63 bgeu a2,a1,13c0 <__udivsi3+0x28>
+.L1:
+ blez a2, .L2
+ 13b0: 00c05863 blez a2,13c0 <__udivsi3+0x28>
+ slli a2, a2, 1
+ 13b4: 00161613 slli a2,a2,0x1
+ slli a3, a3, 1
+ 13b8: 00169693 slli a3,a3,0x1
+ bgtu a1, a2, .L1
+ 13bc: feb66ae3 bltu a2,a1,13b0 <__udivsi3+0x18>
+.L2:
+ li a0, 0
+ 13c0: 00000513 li a0,0
+.L3:
+ bltu a1, a2, .L4
+ 13c4: 00c5e663 bltu a1,a2,13d0 <__udivsi3+0x38>
+ sub a1, a1, a2
+ 13c8: 40c585b3 sub a1,a1,a2
+ or a0, a0, a3
+ 13cc: 00d56533 or a0,a0,a3
+.L4:
+ srli a3, a3, 1
+ 13d0: 0016d693 srli a3,a3,0x1
+ srli a2, a2, 1
+ 13d4: 00165613 srli a2,a2,0x1
+ bnez a3, .L3
+ 13d8: fe0696e3 bnez a3,13c4 <__udivsi3+0x2c>
+.L5:
+ ret
+ 13dc: 00008067 ret
+
+000013e0 <__umodsi3>:
+FUNC_END (__udivdi3)
+
+FUNC_BEGIN (__umoddi3)
+ /* Call __udivdi3(a0, a1), then return the remainder, which is in a1. */
+ move t0, ra
+ 13e0: 00008293 mv t0,ra
+ jal __udivdi3
+ 13e4: fb5ff0ef jal ra,1398 <__udivsi3>
+ move a0, a1
+ 13e8: 00058513 mv a0,a1
+ jr t0
+ 13ec: 00028067 jr t0
+FUNC_END (__umoddi3)
+
+ /* Handle negative arguments to __divdi3. */
+.L10:
+ neg a0, a0
+ 13f0: 40a00533 neg a0,a0
+ /* Zero is handled as a negative so that the result will not be inverted. */
+ bgtz a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */
+ 13f4: 00b04863 bgtz a1,1404 <__umodsi3+0x24>
+
+ neg a1, a1
+ 13f8: 40b005b3 neg a1,a1
+ j __udivdi3 /* Compute __udivdi3(-a0, -a1). */
+ 13fc: f9dff06f j 1398 <__udivsi3>
+.L11: /* Compute __udivdi3(a0, -a1), then negate the result. */
+ neg a1, a1
+ 1400: 40b005b3 neg a1,a1
+.L12:
+ move t0, ra
+ 1404: 00008293 mv t0,ra
+ jal __udivdi3
+ 1408: f91ff0ef jal ra,1398 <__udivsi3>
+ neg a0, a0
+ 140c: 40a00533 neg a0,a0
+ jr t0
+ 1410: 00028067 jr t0
+
+00001414 <__modsi3>:
+FUNC_END (__divdi3)
+
+FUNC_BEGIN (__moddi3)
+ move t0, ra
+ 1414: 00008293 mv t0,ra
+ bltz a1, .L31
+ 1418: 0005ca63 bltz a1,142c <__modsi3+0x18>
+ bltz a0, .L32
+ 141c: 00054c63 bltz a0,1434 <__modsi3+0x20>
+.L30:
+ jal __udivdi3 /* The dividend is not negative. */
+ 1420: f79ff0ef jal ra,1398 <__udivsi3>
+ move a0, a1
+ 1424: 00058513 mv a0,a1
+ jr t0
+ 1428: 00028067 jr t0
+.L31:
+ neg a1, a1
+ 142c: 40b005b3 neg a1,a1
+ bgez a0, .L30
+ 1430: fe0558e3 bgez a0,1420 <__modsi3+0xc>
+.L32:
+ neg a0, a0
+ 1434: 40a00533 neg a0,a0
+ jal __udivdi3 /* The dividend is hella negative. */
+ 1438: f61ff0ef jal ra,1398 <__udivsi3>
+ neg a0, a1
+ 143c: 40b00533 neg a0,a1
+ jr t0
+ 1440: 00028067 jr t0
+
+00001444 <__clzsi2>:
+int
+__clzSI2 (UWtype x)
+{
+ Wtype ret;
+
+ count_leading_zeros (ret, x);
+ 1444: 000107b7 lui a5,0x10
+ 1448: 02f57a63 bgeu a0,a5,147c <__clzsi2+0x38>
+ 144c: 10053793 sltiu a5,a0,256
+ 1450: 0017c793 xori a5,a5,1
+ 1454: 00379793 slli a5,a5,0x3
+ 1458: 00001737 lui a4,0x1
+ 145c: 02000693 li a3,32
+ 1460: 40f686b3 sub a3,a3,a5
+ 1464: 00f55533 srl a0,a0,a5
+ 1468: 65870793 addi a5,a4,1624 # 1658 <__clz_tab>
+ 146c: 00a787b3 add a5,a5,a0
+ 1470: 0007c503 lbu a0,0(a5) # 10000 <_data_lma+0xe8a8>
+
+ return ret;
+}
+ 1474: 40a68533 sub a0,a3,a0
+ 1478: 00008067 ret
+ count_leading_zeros (ret, x);
+ 147c: 01000737 lui a4,0x1000
+ 1480: 01000793 li a5,16
+ 1484: fce56ae3 bltu a0,a4,1458 <__clzsi2+0x14>
+ 1488: 01800793 li a5,24
+ 148c: fcdff06f j 1458 <__clzsi2+0x14>
diff --git a/contrib/pa/hello.elf b/contrib/pa/hello.elf
new file mode 100755
index 0000000..49c1315
Binary files /dev/null and b/contrib/pa/hello.elf differ
diff --git a/contrib/pa/minres.png b/contrib/pa/minres.png
new file mode 100755
index 0000000..babf0e1
Binary files /dev/null and b/contrib/pa/minres.png differ
diff --git a/contrib/tgc_import.cc b/contrib/pa/tgc_import.cc
similarity index 100%
rename from contrib/tgc_import.cc
rename to contrib/pa/tgc_import.cc
diff --git a/contrib/tgc_import.tcl b/contrib/pa/tgc_import.tcl
similarity index 73%
rename from contrib/tgc_import.tcl
rename to contrib/pa/tgc_import.tcl
index 9726408..4372e3b 100644
--- a/contrib/tgc_import.tcl
+++ b/contrib/pa/tgc_import.tcl
@@ -6,14 +6,11 @@ proc getScriptDirectory {} {
set scriptFolder [file dirname $dispScriptFile]
return $scriptFolder
}
-if { $::env(SNPS_VP_PRODUCT) == "PAULTRA" } {
set hardware /HARDWARE/HW/HW
-} else {
- set hardware /HARDWARE
-}
set scriptDir [getScriptDirectory]
set top_design_name core_complex
+set encap_name sysc::tgfs::${top_design_name}
set clocks clk_i
set resets rst_i
set model_prefix "i_"
@@ -28,7 +25,8 @@ set model_postfix ""
::pct::set_update_existing_encaps_flag true
::pct::set_dynamic_port_arrays_flag true
::pct::set_import_scml_properties_flag true
-::pct::load_modules --set-category modules tgc_import.cc
+::pct::set_import_encap_prop_as_extra_prop_flag true
+::pct::load_modules --set-category modules ${scriptDir}/tgc_import.cc
# Set Port Protocols correctly
set block ${top_design_name}
@@ -38,13 +36,15 @@ foreach clock ${clocks} {
foreach reset ${resets} {
::pct::set_block_port_protocol --set-category SYSTEM_LIBRARY:$block/${reset} SYSTEM_LIBRARY:RESET
}
-::pct::set_encap_port_array_size SYSTEM_LIBRARY:$block/local_irq_i 16
+#::pct::set_encap_port_array_size SYSTEM_LIBRARY:$block/local_irq_i 16
# Set compile settings and look
set block SYSTEM_LIBRARY:${top_design_name}
-::pct::set_encap_build_script $block/${top_design_name} $scriptDir/build.tcl
+::pct::set_encap_build_script $block/${encap_name} $scriptDir/build.tcl
::pct::set_background_color_rgb $block 255 255 255 255
-::pct::create_instance SYSTEM_LIBRARY:${top_design_name} ${hardware} ${model_prefix}${top_design_name}${model_postfix} ${top_design_name}
+::pct::create_instance SYSTEM_LIBRARY:${top_design_name} ${hardware} ${model_prefix}${top_design_name}${model_postfix} ${encap_name} ${encap_name}()
+::pct::set_bounds i_${top_design_name} 200 300 100 400
+::pct::set_image i_${top_design_name} "$scriptDir/minres.png" center center false true
# export the result as component
::pct::export_system_library ${top_design_name} ${top_design_name}.xml
diff --git a/contrib/pa/tgc_import_tb.tcl b/contrib/pa/tgc_import_tb.tcl
new file mode 100644
index 0000000..3150eb8
--- /dev/null
+++ b/contrib/pa/tgc_import_tb.tcl
@@ -0,0 +1,71 @@
+source tgc_import.tcl
+set hardware /HARDWARE/HW/HW
+set FW_name ${scriptDir}/hello.elf
+
+puts "instantiate testbench elements"
+::paultra::add_hw_instance GenericIPlib:Memory_Generic -inst_name i_Memory_Generic
+::pct::set_param_value i_Memory_Generic/MEM:protocol {Protocol Common Parameters} address_width 30
+::pct::set_param_value i_Memory_Generic {Scml Properties} /timing/LT/clock_period_in_ns 1
+::pct::set_param_value i_Memory_Generic {Scml Properties} /timing/read/cmd_accept_cycles 1
+::pct::set_param_value i_Memory_Generic {Scml Properties} /timing/write/cmd_accept_cycles 1
+::pct::set_bounds i_Memory_Generic 1000 300 100 100
+
+::paultra::add_hw_instance Bus:Bus -inst_name i_Bus
+::BLWizard::generateFramework i_Bus SBLTLM2FT * {} \
+ { common_configuration:BackBone:/advanced/num_resources_per_target:1 }
+::pct::set_bounds i_Bus 700 300 100 400
+::pct::create_connection C_ibus i_core_complex/ibus i_Bus/i_core_complex_ibus
+::pct::set_location_on_owner i_Bus/i_core_complex_ibus 10
+::pct::create_connection C_dbus i_core_complex/dbus i_Bus/i_core_complex_dbus
+::pct::set_location_on_owner i_Bus/i_core_complex_dbus 10
+::pct::create_connection C_mem i_Bus/i_Memory_Generic_MEM i_Memory_Generic/MEM
+
+puts "instantiating clock manager"
+set clock "Clk"
+::hw::create_hw_instance "" GenericIPlib:ClockGenerator ${clock}_clock
+::pct::set_bounds ${clock}_clock 100 100 100 100
+::pct::set_param_value $hardware/${clock}_clock {Constructor Arguments} period 1000
+::pct::set_param_value $hardware/${clock}_clock {Constructor Arguments} period_unit sc_core::SC_PS
+
+puts "instantiating reset manager"
+set reset "Rst"
+ ::hw::create_hw_instance "" GenericIPlib:ResetGenerator ${reset}_reset
+ ::pct::set_param_value $hardware/${reset}_reset {Constructor Arguments} start_time 0
+ ::pct::set_param_value $hardware/${reset}_reset {Constructor Arguments} start_time_unit sc_core::SC_PS
+ ::pct::set_param_value $hardware/${reset}_reset {Constructor Arguments} duration 10000
+ ::pct::set_param_value $hardware/${reset}_reset {Constructor Arguments} duration_unit sc_core::SC_PS
+ ::pct::set_param_value $hardware/${reset}_reset {Constructor Arguments} active_level true
+::pct::set_bounds ${reset}_reset 300 100 100 100
+
+puts "connecting reset/clock"
+::pct::create_connection C_clk . Clk_clock/CLK i_core_complex/clk_i
+::pct::add_ports_to_connection C_clk i_Bus/Clk
+::pct::add_ports_to_connection C_clk i_Memory_Generic/CLK
+::pct::create_connection C_rst . Rst_reset/RST i_core_complex/rst_i
+::pct::add_ports_to_connection C_rst i_Bus/Rst
+
+puts "setting parameters for DBT-RISE-TGC/Bus and memory components"
+::pct::set_param_value $hardware/i_${top_design_name} {Extra properties} elf_file ${FW_name}
+::pct::set_address $hardware/i_${top_design_name}/ibus:i_Memory_Generic/MEM 0x0
+::pct::set_address $hardware/i_${top_design_name}/dbus:i_Memory_Generic/MEM 0x0
+::BLWizard::updateFramework i_Bus {} { common_configuration:BackBone:/advanced/num_resources_per_target:1 }
+
+::pct::set_main_configuration Default {{#include } {::scc::init_logging(::scc::LogConfig().logLevel(::scc::log::INFO).coloredOutput(false).logAsync(false));} {} {} {}}
+::pct::set_main_configuration Debug {{#include } {::scc::init_logging(::scc::LogConfig().logLevel(::scc::log::DEBUG).coloredOutput(false).logAsync(false));} {} {} {}}
+::pct::create_simulation_build_config Debug
+::pct::set_simulation_build_project_setting Debug "Main Configuration" Default
+# add build settings and save design for next steps
+#::pct::set_simulation_build_project_setting "Debug" "Linker Flags" "-Wl,-z,muldefs $::env(VERILATOR_ROOT)/include/verilated.cpp $::env(VERILATOR_ROOT)/include/verilated_vcd_sc.cpp $::env(VERILATOR_ROOT)/include/verilated_vcd_c.cpp"
+#::pct::set_simulation_build_project_setting "Debug" "Include Paths" $::env(VERILATOR_ROOT)/include/
+
+#::simulation::set_simulation_property Simulation [list run_for_duration:200ns results_dir:results/test_0 "TLM Port Trace:true"]
+#::simulation::run_simulation Simulation
+
+#::pct::set_simulation_build_project_setting Debug {Export Type} {STATIC NETLIST}
+#::pct::set_simulation_build_project_setting Debug {Encapsulated Netlist} false
+#::pct::export_system "export"
+#::cd "export"
+#::scsh::open-project
+#::scsh::build
+#::scsh::elab sim
+::pct::save_system testbench.xml
diff --git a/gen_input/TGC5C.core_desc b/gen_input/TGC5C.core_desc
new file mode 100644
index 0000000..f57a6c4
--- /dev/null
+++ b/gen_input/TGC5C.core_desc
@@ -0,0 +1,13 @@
+import "ISA/RVI.core_desc"
+import "ISA/RVM.core_desc"
+import "ISA/RVC.core_desc"
+
+Core TGC5C provides RV32I, Zicsr, Zifencei, RV32M, RV32IC {
+ architectural_state {
+ XLEN=32;
+ // definitions for the architecture wrapper
+ // XL ZYXWVUTSRQPONMLKJIHGFEDCBA
+ unsigned int MISA_VAL = 0b01000000000000000001000100000100;
+ unsigned int MARCHID_VAL = 0x80000003;
+ }
+}
diff --git a/gen_input/TGC_C.core_desc b/gen_input/TGC_C.core_desc
deleted file mode 100644
index d3a529e..0000000
--- a/gen_input/TGC_C.core_desc
+++ /dev/null
@@ -1,13 +0,0 @@
-import "CoreDSL-Instruction-Set-Description/RV32I.core_desc"
-import "CoreDSL-Instruction-Set-Description/RVM.core_desc"
-import "CoreDSL-Instruction-Set-Description/RVC.core_desc"
-
-Core TGC_C provides RV32I, Zicsr, Zifencei, RV32M, RV32IC {
- architectural_state {
- XLEN=32;
- // definitions for the architecture wrapper
- // XL ZYXWVUTSRQPONMLKJIHGFEDCBA
- unsigned MISA_VAL = 0b01000000000000000001000100000100;
- unsigned MARCHID_VAL = 0x80000003;
- }
-}
diff --git a/gen_input/templates/CORENAME.cpp.gtl b/gen_input/templates/CORENAME.cpp.gtl
index 6bb5c4e..7925e90 100644
--- a/gen_input/templates/CORENAME.cpp.gtl
+++ b/gen_input/templates/CORENAME.cpp.gtl
@@ -33,13 +33,14 @@
def getRegisterSizes(){
def regs = registers.collect{it.size}
regs[-1]=64 // correct for NEXT_PC
- regs+=[32, 32, 64, 64, 64] // append TRAP_STATE, PENDING_TRAP, ICOUNT, CYCLE, INSTRET
+ regs+=[32,32, 64, 64, 64, 32, 32] // append TRAP_STATE, PENDING_TRAP, ICOUNT, CYCLE, INSTRET, INSTRUCTION, LAST_BRANCH
return regs
}
%>
+// clang-format off
+#include "${coreDef.name.toLowerCase()}.h"
#include "util/ities.h"
#include
-#include
#include
#include
#include
@@ -51,9 +52,7 @@ constexpr std::array iss::arch::traits iss::arch::traits::reg_bit_widths;
constexpr std::array iss::arch::traits::reg_byte_offsets;
-${coreDef.name.toLowerCase()}::${coreDef.name.toLowerCase()}() {
- reg.icount = 0;
-}
+${coreDef.name.toLowerCase()}::${coreDef.name.toLowerCase()}() = default;
${coreDef.name.toLowerCase()}::~${coreDef.name.toLowerCase()}() = default;
@@ -72,7 +71,7 @@ uint8_t *${coreDef.name.toLowerCase()}::get_regs_base_ptr() {
return reinterpret_cast(®);
}
-${coreDef.name.toLowerCase()}::phys_addr_t ${coreDef.name.toLowerCase()}::virt2phys(const iss::addr_t &pc) {
- return phys_addr_t(pc); // change logical address to physical address
+${coreDef.name.toLowerCase()}::phys_addr_t ${coreDef.name.toLowerCase()}::virt2phys(const iss::addr_t &addr) {
+ return phys_addr_t(addr.access, addr.space, addr.val&traits<${coreDef.name.toLowerCase()}>::addr_mask);
}
-
+// clang-format on
diff --git a/gen_input/templates/CORENAME.h.gtl b/gen_input/templates/CORENAME.h.gtl
index dbe4c82..d5ba6c4 100644
--- a/gen_input/templates/CORENAME.h.gtl
+++ b/gen_input/templates/CORENAME.h.gtl
@@ -30,14 +30,12 @@
*
*******************************************************************************/
<%
-import com.minres.coredsl.util.BigIntegerWithRadix
-
def nativeTypeSize(int size){
if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64;
}
def getRegisterSizes(){
def regs = registers.collect{nativeTypeSize(it.size)}
- regs+=[32,32, 64, 64, 64] // append TRAP_STATE, PENDING_TRAP, ICOUNT, CYCLE, INSTRET
+ regs+=[32,32, 64, 64, 64, 32, 32] // append TRAP_STATE, PENDING_TRAP, ICOUNT, CYCLE, INSTRET, INSTRUCTION, LAST_BRANCH
return regs
}
def getRegisterOffsets(){
@@ -57,15 +55,12 @@ def byteSize(int size){
return 128;
}
def getCString(def val){
- if(val instanceof BigIntegerWithRadix)
- return ((BigIntegerWithRadix)val).toCString()
- else
- return val.toString()
+ return val.toString()+'ULL'
}
%>
#ifndef _${coreDef.name.toUpperCase()}_H_
#define _${coreDef.name.toUpperCase()}_H_
-
+// clang-format off
#include
#include
#include
@@ -81,22 +76,17 @@ template <> struct traits<${coreDef.name.toLowerCase()}> {
constexpr static char const* const core_type = "${coreDef.name}";
static constexpr std::array reg_names{
- {"${registers.collect{it.name}.join('", "')}"}};
+ {"${registers.collect{it.name.toLowerCase()}.join('", "')}"}};
static constexpr std::array reg_aliases{
- {"${registers.collect{it.alias}.join('", "')}"}};
+ {"${registers.collect{it.alias.toLowerCase()}.join('", "')}"}};
enum constants {${constants.collect{c -> c.name+"="+getCString(c.value)}.join(', ')}};
constexpr static unsigned FP_REGS_SIZE = ${constants.find {it.name=='FLEN'}?.value?:0};
enum reg_e {
- ${registers.collect{it.name}.join(', ')}, NUM_REGS,
- TRAP_STATE=NUM_REGS,
- PENDING_TRAP,
- ICOUNT,
- CYCLE,
- INSTRET
+ ${registers.collect{it.name}.join(', ')}, NUM_REGS, TRAP_STATE=NUM_REGS, PENDING_TRAP, ICOUNT, CYCLE, INSTRET, INSTRUCTION, LAST_BRANCH
};
using reg_t = uint${addrDataWidth}_t;
@@ -121,7 +111,7 @@ template <> struct traits<${coreDef.name.toLowerCase()}> {
enum mem_type_e { ${spaces.collect{it.name}.join(', ')} };
- enum class opcode_e : unsigned short {<%instructions.eachWithIndex{instr, index -> %>
+ enum class opcode_e {<%instructions.eachWithIndex{instr, index -> %>
${instr.instruction.name} = ${index},<%}%>
MAX_OPCODE
};
@@ -147,14 +137,6 @@ struct ${coreDef.name.toLowerCase()}: public arch_if {
inline uint64_t stop_code() { return interrupt_sim; }
- inline phys_addr_t v2p(const iss::addr_t& addr){
- if (addr.space != traits<${coreDef.name.toLowerCase()}>::MEM || addr.type == iss::address_type::PHYSICAL ||
- addr_mode[static_cast(addr.access)&0x3]==address_type::PHYSICAL) {
- return phys_addr_t(addr.access, addr.space, addr.val&traits<${coreDef.name.toLowerCase()}>::addr_mask);
- } else
- return virt2phys(addr);
- }
-
virtual phys_addr_t virt2phys(const iss::addr_t& addr);
virtual iss::sync_type needed_sync() const { return iss::NO_SYNC; }
@@ -169,8 +151,10 @@ struct ${coreDef.name.toLowerCase()}: public arch_if {
}}%>
uint32_t trap_state = 0, pending_trap = 0;
uint64_t icount = 0;
+ uint64_t cycle = 0;
uint64_t instret = 0;
- uint32_t last_branch;
+ uint32_t instruction = 0;
+ uint32_t last_branch = 0;
} reg;
#pragma pack(pop)
std::array addr_mode;
@@ -190,3 +174,4 @@ if(fcsr != null) {%>
}
}
#endif /* _${coreDef.name.toUpperCase()}_H_ */
+// clang-format on
diff --git a/gen_input/templates/CORENAME_instr.yaml.gtl b/gen_input/templates/CORENAME_instr.yaml.gtl
index 122be5e..d9fdcbf 100644
--- a/gen_input/templates/CORENAME_instr.yaml.gtl
+++ b/gen_input/templates/CORENAME_instr.yaml.gtl
@@ -8,9 +8,14 @@
instrGroups[groupName]+=it;
}
instrGroups
-}%><%getInstructionGroups().each{name, instrList -> %>
-${name}: <% instrList.findAll{!it.instruction.name.startsWith("__")}.each { %>
- - ${it.instruction.name}:
+}%><%int index = 0; getInstructionGroups().each{name, instrList -> %>
+${name}: <% instrList.each { %>
+ ${it.instruction.name}:
+ index: ${index++}
encoding: ${it.encoding}
- mask: ${it.mask}<%}}%>
+ mask: ${it.mask}<%if(it.attributes.size) {%>
+ attributes: ${it.attributes}<%}%>
+ size: ${it.length}
+ branch: ${it.modifiesPC}
+ delay: ${it.isConditional?"[1,1]":"1"}<%}}%>
diff --git a/gen_input/templates/CORENAME_sysc.cpp.gtl b/gen_input/templates/CORENAME_sysc.cpp.gtl
new file mode 100644
index 0000000..6163aa1
--- /dev/null
+++ b/gen_input/templates/CORENAME_sysc.cpp.gtl
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (C) 2023 MINRES Technologies GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *******************************************************************************/
+// clang-format off
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+<%
+def array_count = coreDef.name.toLowerCase()=="tgc5d" || coreDef.name.toLowerCase()=="tgc5e"? 3 : 2;
+%>
+namespace iss {
+namespace interp {
+using namespace sysc;
+volatile std::array ${coreDef.name.toLowerCase()}_init = {
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|m_p|interp", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ }),
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p|interp", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%if(coreDef.name.toLowerCase()=="tgc5d" || coreDef.name.toLowerCase()=="tgc5e") {%>,
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p_clic_pmp|interp", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%}%>
+};
+}
+#if defined(WITH_LLVM)
+namespace llvm {
+using namespace sysc;
+volatile std::array ${coreDef.name.toLowerCase()}_init = {
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|m_p|llvm", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ }),
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p|llvm", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%if(coreDef.name.toLowerCase()=="tgc5d" || coreDef.name.toLowerCase()=="tgc5e") {%>,
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p_clic_pmp|llvm", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%}%>
+};
+}
+#endif
+#if defined(WITH_TCC)
+namespace tcc {
+using namespace sysc;
+volatile std::array ${coreDef.name.toLowerCase()}_init = {
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|m_p|tcc", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ }),
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p|tcc", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%if(coreDef.name.toLowerCase()=="tgc5d" || coreDef.name.toLowerCase()=="tgc5e") {%>,
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p_clic_pmp|tcc", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%}%>
+};
+}
+#endif
+#if defined(WITH_ASMJIT)
+namespace asmjit {
+using namespace sysc;
+volatile std::array ${coreDef.name.toLowerCase()}_init = {
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|m_p|asmjit", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ }),
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p|asmjit", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%if(coreDef.name.toLowerCase()=="tgc5d" || coreDef.name.toLowerCase()=="tgc5e") {%>,
+ iss_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p_clic_pmp|asmjit", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
+ auto* cc = reinterpret_cast(data);
+ auto* cpu = new sc_core_adapter>(cc);
+ return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast(cpu), gdb_port)}};
+ })<%}%>
+};
+}
+#endif
+}
+// clang-format on
\ No newline at end of file
diff --git a/gen_input/templates/asmjit/CORENAME.cpp.gtl b/gen_input/templates/asmjit/CORENAME.cpp.gtl
new file mode 100644
index 0000000..74f54d4
--- /dev/null
+++ b/gen_input/templates/asmjit/CORENAME.cpp.gtl
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (C) 2017, 2023 MINRES Technologies GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *******************************************************************************/
+// clang-format off
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef FMT_HEADER_ONLY
+#define FMT_HEADER_ONLY
+#endif
+#include
+
+#include
+#include
+
+namespace iss {
+namespace asmjit {
+
+
+namespace ${coreDef.name.toLowerCase()} {
+using namespace ::asmjit;
+using namespace iss::arch;
+using namespace iss::debugger;
+
+template class vm_impl : public iss::asmjit::vm_base {
+public:
+ using traits = arch::traits;
+ using super = typename iss::asmjit::vm_base;
+ using virt_addr_t = typename super::virt_addr_t;
+ using phys_addr_t = typename super::phys_addr_t;
+ using code_word_t = typename super::code_word_t;
+ using mem_type_e = typename super::mem_type_e;
+ using addr_t = typename super::addr_t;
+
+ vm_impl();
+
+ vm_impl(ARCH &core, unsigned core_id = 0, unsigned cluster_id = 0);
+
+ void enableDebug(bool enable) { super::sync_exec = super::ALL_SYNC; }
+
+ target_adapter_if *accquire_target_adapter(server_if *srv) override {
+ debugger_if::dbg_enabled = true;
+ if (vm_base::tgt_adapter == nullptr)
+ vm_base::tgt_adapter = new riscv_target_adapter(srv, this->get_arch());
+ return vm_base::tgt_adapter;
+ }
+
+protected:
+ using vm_base::get_reg_ptr;
+ using this_class = vm_impl;
+ using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
+
+ continuation_e gen_single_inst_behavior(virt_addr_t&, unsigned int &, jit_holder&) override;
+ inline const char *name(size_t index){return traits::reg_aliases.at(index);}
+
+ template::type>
+ inline S sext(U from) {
+ auto mask = (1ULL<
+
+private:
+ /****************************************************************************
+ * start opcode definitions
+ ****************************************************************************/
+ struct instruction_descriptor {
+ size_t length;
+ uint32_t value;
+ uint32_t mask;
+ compile_func op;
+ };
+ struct decoding_tree_node{
+ std::vector instrs;
+ std::vector children;
+ uint32_t submask = std::numeric_limits::max();
+ uint32_t value;
+ decoding_tree_node(uint32_t value) : value(value){}
+ };
+
+ decoding_tree_node* root {nullptr};
+
+ const std::array instr_descr = {{
+ /* entries are: size, valid value, valid mask, function ptr */<%instructions.each{instr -> %>
+ /* instruction ${instr.instruction.name}, encoding '${instr.encoding}' */
+ {${instr.length}, ${instr.encoding}, ${instr.mask}, &this_class::__${generator.functionName(instr.name)}},<%}%>
+ }};
+
+ /* instruction definitions */<%instructions.eachWithIndex{instr, idx -> %>
+ /* instruction ${idx}: ${instr.name} */
+ continuation_e __${generator.functionName(instr.name)}(virt_addr_t& pc, code_word_t instr, jit_holder& jh){
+ uint64_t PC = pc.val;
+ <%instr.fields.eachLine{%>${it}
+ <%}%>if(this->disass_enabled){
+ /* generate disass */
+ }
+ x86::Compiler& cc = jh.cc;
+ //ideally only do this if necessary (someone / plugin needs it)
+ cc.mov(jh.pc,PC);
+ cc.comment(fmt::format("\\n${instr.name}_{:#x}:",pc.val).c_str());
+ this->gen_sync(jh, PRE_SYNC, ${idx});
+ pc=pc+ ${instr.length/8};
+
+ gen_instr_prologue(jh, pc.val);
+ cc.comment("\\n//behavior:");
+ /*generate behavior*/
+ <%instr.behavior.eachLine{%>${it}
+ <%}%>
+ gen_instr_epilogue(jh);
+ this->gen_sync(jh, POST_SYNC, ${idx});
+ return returnValue;
+ }
+ <%}%>
+ /****************************************************************************
+ * end opcode definitions
+ ****************************************************************************/
+ continuation_e illegal_intruction(virt_addr_t &pc, code_word_t instr, jit_holder& jh ) {
+
+ return BRANCH;
+ }
+ //decoding functionality
+
+ void populate_decoding_tree(decoding_tree_node* root){
+ //create submask
+ for(auto instr: root->instrs){
+ root->submask &= instr.mask;
+ }
+ //put each instr according to submask&encoding into children
+ for(auto instr: root->instrs){
+ bool foundMatch = false;
+ for(auto child: root->children){
+ //use value as identifying trait
+ if(child->value == (instr.value&root->submask)){
+ child->instrs.push_back(instr);
+ foundMatch = true;
+ }
+ }
+ if(!foundMatch){
+ decoding_tree_node* child = new decoding_tree_node(instr.value&root->submask);
+ child->instrs.push_back(instr);
+ root->children.push_back(child);
+ }
+ }
+ root->instrs.clear();
+ //call populate_decoding_tree for all children
+ if(root->children.size() >1)
+ for(auto child: root->children){
+ populate_decoding_tree(child);
+ }
+ else{
+ //sort instrs by value of the mask, this works bc we want to have the least restrictive one last
+ std::sort(root->children[0]->instrs.begin(), root->children[0]->instrs.end(), [](const instruction_descriptor& instr1, const instruction_descriptor& instr2) {
+ return instr1.mask > instr2.mask;
+ });
+ }
+ }
+ compile_func decode_instr(decoding_tree_node* node, code_word_t word){
+ if(!node->children.size()){
+ if(node->instrs.size() == 1) return node->instrs[0].op;
+ for(auto instr : node->instrs){
+ if((instr.mask&word) == instr.value) return instr.op;
+ }
+ }
+ else{
+ for(auto child : node->children){
+ if (child->value == (node->submask&word)){
+ return decode_instr(child, word);
+ }
+ }
+ }
+ return nullptr;
+ }
+};
+
+template void debug_fn(CODE_WORD instr) {
+ volatile CODE_WORD x = instr;
+ instr = 2 * x;
+}
+
+template vm_impl::vm_impl() { this(new ARCH()); }
+
+template
+vm_impl::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id)
+: vm_base(core, core_id, cluster_id) {
+ root = new decoding_tree_node(std::numeric_limits::max());
+ for(auto instr: instr_descr){
+ root->instrs.push_back(instr);
+ }
+ populate_decoding_tree(root);
+}
+
+template
+continuation_e
+vm_impl::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt, jit_holder& jh) {
+ enum {TRAP_ID=1<<16};
+ code_word_t instr = 0;
+ phys_addr_t paddr(pc);
+ auto *const data = (uint8_t *)&instr;
+ if(this->core.has_mmu())
+ paddr = this->core.virt2phys(pc);
+ auto res = this->core.read(paddr, 4, data);
+ if (res != iss::Ok)
+ throw trap_access(TRAP_ID, pc.val);
+ if (instr == 0x0000006f || (instr&0xffff)==0xa001)
+ throw simulation_stopped(0); // 'J 0' or 'C.J 0'
+ ++inst_cnt;
+ auto f = decode_instr(root, instr);
+ if (f == nullptr)
+ f = &this_class::illegal_intruction;
+ return (this->*f)(pc, instr, jh);
+}
+
+
+
+} // namespace ${coreDef.name.toLowerCase()}
+
+template <>
+std::unique_ptr create(arch::${coreDef.name.toLowerCase()} *core, unsigned short port, bool dump) {
+ auto ret = new ${coreDef.name.toLowerCase()}::vm_impl(*core, dump);
+ if (port != 0) debugger::server::run_server(ret, port);
+ return std::unique_ptr(ret);
+}
+} // namespace asmjit
+} // namespace iss
+
+#include
+#include
+#include
+namespace iss {
+namespace {
+volatile std::array dummy = {
+ core_factory::instance().register_creator("${coreDef.name.toLowerCase()}|m_p|asmjit", [](unsigned port, void*) -> std::tuple{
+ auto* cpu = new iss::arch::riscv_hart_m_p();
+ auto* vm = new asmjit::${coreDef.name.toLowerCase()}::vm_impl(*cpu, false);
+ if (port != 0) debugger::server::run_server(vm, port);
+ return {cpu_ptr{cpu}, vm_ptr{vm}};
+ }),
+ core_factory::instance().register_creator("${coreDef.name.toLowerCase()}|mu_p|asmjit", [](unsigned port, void*) -> std::tuple{
+ auto* cpu = new iss::arch::riscv_hart_mu_p();
+ auto* vm = new asmjit::${coreDef.name.toLowerCase()}::vm_impl(*cpu, false);
+ if (port != 0) debugger::server::run_server(vm, port);
+ return {cpu_ptr{cpu}, vm_ptr{vm}};
+ })
+};
+}
+}
+// clang-format on
\ No newline at end of file
diff --git a/gen_input/templates/interp/CORENAME.cpp.gtl b/gen_input/templates/interp/CORENAME.cpp.gtl
index 98817ce..c2eb071 100644
--- a/gen_input/templates/interp/CORENAME.cpp.gtl
+++ b/gen_input/templates/interp/CORENAME.cpp.gtl
@@ -30,23 +30,23 @@
*
*******************************************************************************/
<%
-import com.minres.coredsl.util.BigIntegerWithRadix
-
def nativeTypeSize(int size){
if(size<=8) return 8; else if(size<=16) return 16; else if(size<=32) return 32; else return 64;
}
%>
-#include "../fp_functions.h"
+// clang-format off
#include
-#include
#include
#include
#include
#include
+#include
#include
-#include
#include
#include
+#include
+#include
+#include
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
@@ -63,6 +63,10 @@ using namespace iss::arch;
using namespace iss::debugger;
using namespace std::placeholders;
+struct memory_access_exception : public std::exception{
+ memory_access_exception(){}
+};
+
template class vm_impl : public iss::interp::vm_base {
public:
using traits = arch::traits;
@@ -73,6 +77,7 @@ public:
using addr_t = typename super::addr_t;
using reg_t = typename traits::reg_t;
using mem_type_e = typename traits::mem_type_e;
+ using opcode_e = typename traits::opcode_e;
vm_impl();
@@ -92,37 +97,16 @@ protected:
using compile_ret_t = virt_addr_t;
using compile_func = compile_ret_t (this_class::*)(virt_addr_t &pc, code_word_t instr);
- inline const char *name(size_t index){return traits::reg_aliases.at(index);}
+ inline const char *name(size_t index){return index::opcode_e decode_inst_id(code_word_t instr);
virt_addr_t execute_inst(finish_cond_e cond, virt_addr_t start, uint64_t icount_limit) override;
// some compile time constants
- // enum { MASK16 = 0b1111110001100011, MASK32 = 0b11111111111100000111000001111111 };
- enum { MASK16 = 0b1111111111111111, MASK32 = 0b11111111111100000111000001111111 };
- enum { EXTR_MASK16 = MASK16 >> 2, EXTR_MASK32 = MASK32 >> 2 };
- enum {
- LUT_SIZE = 1 << util::bit_count(static_cast(EXTR_MASK32)),
- LUT_SIZE_C = 1 << util::bit_count(static_cast(EXTR_MASK16))
- };
-
- std::array lut;
-
- std::array lut_00, lut_01, lut_10;
- std::array lut_11;
-
- struct instruction_pattern {
- uint32_t value;
- uint32_t mask;
- typename arch::traits::opcode_e id;
- };
-
- std::array, 4> qlut;
inline void raise(uint16_t trap_id, uint16_t cause){
auto trap_val = 0x80ULL << 24 | (cause << 16) | trap_id;
- this->template get_reg(traits::TRAP_STATE) = trap_val;
- this->template get_reg(traits::NEXT_PC) = std::numeric_limits::max();
+ this->core.reg.trap_state = trap_val;
+ this->template get_reg(traits::NEXT_PC) = std::numeric_limits::max();
}
inline void leave(unsigned lvl){
@@ -137,44 +121,6 @@ protected:
using coro_t = boost::coroutines2::coroutine::pull_type;
std::vector spawn_blocks;
- template
- T& pc_assign(T& val){super::ex_info.branch_taken=true; return val;}
- inline uint8_t readSpace1(typename super::mem_type_e space, uint64_t addr){
- auto ret = super::template read_mem(space, addr);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- return ret;
- }
- inline uint16_t readSpace2(typename super::mem_type_e space, uint64_t addr){
- auto ret = super::template read_mem(space, addr);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- return ret;
- }
- inline uint32_t readSpace4(typename super::mem_type_e space, uint64_t addr){
- auto ret = super::template read_mem(space, addr);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- return ret;
- }
- inline uint64_t readSpace8(typename super::mem_type_e space, uint64_t addr){
- auto ret = super::template read_mem(space, addr);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- return ret;
- }
- inline void writeSpace1(typename super::mem_type_e space, uint64_t addr, uint8_t data){
- super::write_mem(space, addr, data);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- }
- inline void writeSpace2(typename super::mem_type_e space, uint64_t addr, uint16_t data){
- super::write_mem(space, addr, data);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- }
- inline void writeSpace4(typename super::mem_type_e space, uint64_t addr, uint32_t data){
- super::write_mem(space, addr, data);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- }
- inline void writeSpace8(typename super::mem_type_e space, uint64_t addr, uint64_t data){
- super::write_mem(space, addr, data);
- if(this->template get_reg(traits::TRAP_STATE)) throw 0;
- }
template::type>
inline S sext(U from) {
auto mask = (1ULL<
${it}<%}%>
<%}%>
+
private:
/****************************************************************************
* start opcode definitions
****************************************************************************/
- struct InstructionDesriptor {
+ struct instruction_descriptor {
size_t length;
uint32_t value;
uint32_t mask;
typename arch::traits::opcode_e op;
};
+ struct decoding_tree_node{
+ std::vector instrs;
+ std::vector children;
+ uint32_t submask = std::numeric_limits::max();
+ uint32_t value;
+ decoding_tree_node(uint32_t value) : value(value){}
+ };
- const std::array instr_descr = {{
+ decoding_tree_node* root {nullptr};
+ const std::array instr_descr = {{
/* entries are: size, valid value, valid mask, function ptr */<%instructions.each{instr -> %>
{${instr.length}, ${instr.encoding}, ${instr.mask}, arch::traits::opcode_e::${instr.instruction.name}},<%}%>
}};
- //static constexpr typename traits::addr_t upper_bits = ~traits::PGMASK;
iss::status fetch_ins(virt_addr_t pc, uint8_t * data){
- auto phys_pc = this->core.v2p(pc);
- //if ((pc.val & upper_bits) != ((pc.val + 2) & upper_bits)) { // we may cross a page boundary
- // if (this->core.read(phys_pc, 2, data) != iss::Ok) return iss::Err;
- // if ((data[0] & 0x3) == 0x3) // this is a 32bit instruction
- // if (this->core.read(this->core.v2p(pc + 2), 2, data + 2) != iss::Ok) return iss::Err;
- //} else {
- if (this->core.read(phys_pc, 4, data) != iss::Ok) return iss::Err;
- //}
+ if(this->core.has_mmu()) {
+ auto phys_pc = this->core.virt2phys(pc);
+// if ((pc.val & upper_bits) != ((pc.val + 2) & upper_bits)) { // we may cross a page boundary
+// if (this->core.read(phys_pc, 2, data) != iss::Ok) return iss::Err;
+// if ((data[0] & 0x3) == 0x3) // this is a 32bit instruction
+// if (this->core.read(this->core.v2p(pc + 2), 2, data + 2) != iss::Ok)
+// return iss::Err;
+// } else {
+ if (this->core.read(phys_pc, 4, data) != iss::Ok)
+ return iss::Err;
+// }
+ } else {
+ if (this->core.read(phys_addr_t(pc.access, pc.space, pc.val), 4, data) != iss::Ok)
+ return iss::Err;
+
+ }
return iss::Ok;
}
+
+ void populate_decoding_tree(decoding_tree_node* root){
+ //create submask
+ for(auto instr: root->instrs){
+ root->submask &= instr.mask;
+ }
+ //put each instr according to submask&encoding into children
+ for(auto instr: root->instrs){
+ bool foundMatch = false;
+ for(auto child: root->children){
+ //use value as identifying trait
+ if(child->value == (instr.value&root->submask)){
+ child->instrs.push_back(instr);
+ foundMatch = true;
+ }
+ }
+ if(!foundMatch){
+ decoding_tree_node* child = new decoding_tree_node(instr.value&root->submask);
+ child->instrs.push_back(instr);
+ root->children.push_back(child);
+ }
+ }
+ root->instrs.clear();
+ //call populate_decoding_tree for all children
+ if(root->children.size() >1)
+ for(auto child: root->children){
+ populate_decoding_tree(child);
+ }
+ else{
+ //sort instrs by value of the mask, this works bc we want to have the least restrictive one last
+ std::sort(root->children[0]->instrs.begin(), root->children[0]->instrs.end(), [](const instruction_descriptor& instr1, const instruction_descriptor& instr2) {
+ return instr1.mask > instr2.mask;
+ });
+ }
+ }
+ typename arch::traits::opcode_e decode_instr(decoding_tree_node* node, code_word_t word){
+ if(!node->children.size()){
+ if(node->instrs.size() == 1) return node->instrs[0].op;
+ for(auto instr : node->instrs){
+ if((instr.mask&word) == instr.value) return instr.op;
+ }
+ }
+ else{
+ for(auto child : node->children){
+ if (child->value == (node->submask&word)){
+ return decode_instr(child, word);
+ }
+ }
+ }
+ return arch::traits::opcode_e::MAX_OPCODE;
+ }
};
template void debug_fn(CODE_WORD insn) {
@@ -247,16 +261,11 @@ constexpr size_t bit_count(uint32_t u) {
template
vm_impl::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id)
: vm_base(core, core_id, cluster_id) {
- unsigned id=0;
- for (auto instr : instr_descr) {
- auto quadrant = instr.value & 0x3;
- qlut[quadrant].push_back(instruction_pattern{instr.value, instr.mask, instr.op});
- }
- for(auto& lut: qlut){
- std::sort(std::begin(lut), std::end(lut), [](instruction_pattern const& a, instruction_pattern const& b){
- return bit_count(a.mask) > bit_count(b.mask);
- });
+ root = new decoding_tree_node(std::numeric_limits