Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
systemc-clang
Commits
ba54bdf4
Commit
ba54bdf4
authored
Dec 28, 2018
by
rmrf
Browse files
Clean up code
parent
9bd7b4c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/SystemCClang.cpp
View file @
ba54bdf4
...
...
@@ -17,39 +17,37 @@ bool SystemCConsumer::postFire() {
bool
SystemCConsumer
::
fire
()
{
TranslationUnitDecl
*
tu
=
_context
.
getTranslationUnitDecl
();
TranslationUnitDecl
*
tu
{
_context
.
getTranslationUnitDecl
()
}
;
// Reflection database.
_systemcModel
=
new
Model
()
;
_systemcModel
=
new
Model
{}
;
// Find the sc_modules
SCModules
scmod
(
tu
,
_os
)
;
SCModules
scmod
{
tu
,
_os
}
;
// ANI : Do we need FindGlobalEvents?
FindGlobalEvents
fglobals
(
tu
,
_os
)
;
FindGlobalEvents
::
globalEventMapType
eventMap
=
fglobals
.
getEventMap
();
FindGlobalEvents
fglobals
{
tu
,
_os
}
;
FindGlobalEvents
::
globalEventMapType
eventMap
{
fglobals
.
getEventMap
()
}
;
_systemcModel
->
addGlobalEvents
(
eventMap
);
SCModules
::
moduleMapType
scmodules
=
scmod
.
getSystemCModulesMap
();
SCModules
::
moduleMapType
scmodules
{
scmod
.
getSystemCModulesMap
()
}
;
for
(
SCModules
::
moduleMapType
::
iterator
mit
=
scmodules
.
begin
(),
mitend
=
scmodules
.
end
();
mit
!=
mitend
;
++
mit
)
{
ModuleDecl
*
md
=
new
ModuleDecl
(
mit
->
first
,
mit
->
second
)
;
ModuleDecl
*
md
=
new
ModuleDecl
{
mit
->
first
,
mit
->
second
}
;
_systemcModel
->
addModuleDecl
(
md
);
}
////////////////////////////////////////////////////////////////
// Find the sc_main
////////////////////////////////////////////////////////////////
FindSCMain
scmain
(
tu
,
_os
)
;
FindSCMain
scmain
{
tu
,
_os
}
;
if
(
scmain
.
isSCMainFound
()
)
{
FunctionDecl
*
fnDecl
=
scmain
.
getSCMainFunctionDecl
();
FunctionDecl
*
fnDecl
{
scmain
.
getSCMainFunctionDecl
()
}
;
FindSimTime
scstart
(
fnDecl
,
_os
)
;
_systemcModel
->
addSimulationTime
(
scstart
.
returnSimTime
());
FindSimTime
scstart
{
fnDecl
,
_os
}
;
_systemcModel
->
addSimulationTime
(
scstart
.
returnSimTime
()
);
}
else
{
_os
<<
"
\n
Could not find SCMain"
;
}
...
...
@@ -57,61 +55,60 @@ bool SystemCConsumer::fire() {
////////////////////////////////////////////////////////////////
// Find the netlist.
////////////////////////////////////////////////////////////////
FindNetlist
findNetlist
(
scmain
.
getSCMainFunctionDecl
()
)
;
FindNetlist
findNetlist
{
scmain
.
getSCMainFunctionDecl
()
}
;
findNetlist
.
dump
();
_systemcModel
->
addNetlist
(
findNetlist
);
////////////////////////////////////////////////////////////////
// Figure out the module map.
////////////////////////////////////////////////////////////////
Model
::
moduleMapType
moduleMap
=
_systemcModel
->
getModuleDecl
();
Model
::
moduleMapType
moduleMap
{
_systemcModel
->
getModuleDecl
()
}
;
for
(
Model
::
moduleMapType
::
iterator
mit
=
moduleMap
.
begin
(),
mitend
=
moduleMap
.
end
();
mit
!=
mitend
;
mit
++
)
{
ModuleDecl
*
mainmd
=
mit
->
second
;
int
numInstances
=
mainmd
->
getNumInstances
();
ModuleDecl
*
mainmd
{
mit
->
second
}
;
int
numInstances
{
mainmd
->
getNumInstances
()
}
;
vector
<
ModuleDecl
*>
moduleDeclVec
;
_os
<<
"
\n
"
;
_os
<<
"For module: "
<<
mit
->
first
<<
" num instance : "
<<
numInstances
;
for
(
unsigned
int
num
{
0
};
num
<
numInstances
;
++
num
)
{
ModuleDecl
*
md
=
new
ModuleDecl
()
;
vector
<
EntryFunctionContainer
*
>
_entryFunctionContainerVector
;
FindConstructor
constructor
(
mainmd
->
getModuleClassDecl
(),
_os
)
;
for
(
unsigned
int
num
{
0
};
num
<
numInstances
;
++
num
)
{
ModuleDecl
*
md
=
new
ModuleDecl
{}
;
vector
<
EntryFunctionContainer
*>
_entryFunctionContainerVector
;
FindConstructor
constructor
{
mainmd
->
getModuleClassDecl
(),
_os
}
;
md
->
addConstructor
(
constructor
.
returnConstructorStmt
());
FindPorts
ports
(
mainmd
->
getModuleClassDecl
(),
_os
)
;
md
->
addInputPorts
(
ports
.
getInputPorts
());
md
->
addOutputPorts
(
ports
.
getOutputPorts
());
md
->
addInputOutputPorts
(
ports
.
getInputOutputPorts
());
FindPorts
ports
{
mainmd
->
getModuleClassDecl
(),
_os
}
;
md
->
addInputPorts
(
ports
.
getInputPorts
()
);
md
->
addOutputPorts
(
ports
.
getOutputPorts
()
);
md
->
addInputOutputPorts
(
ports
.
getInputOutputPorts
()
);
FindTLMInterfaces
findTLMInterfaces
(
mainmd
->
getModuleClassDecl
(),
_os
)
;
md
->
addInputInterfaces
(
findTLMInterfaces
.
getInputInterfaces
());
md
->
addOutputInterfaces
(
findTLMInterfaces
.
getOutputInterfaces
());
md
->
addInputOutputInterfaces
(
findTLMInterfaces
.
getInputOutputInterfaces
());
FindTLMInterfaces
findTLMInterfaces
{
mainmd
->
getModuleClassDecl
(),
_os
}
;
md
->
addInputInterfaces
(
findTLMInterfaces
.
getInputInterfaces
()
);
md
->
addOutputInterfaces
(
findTLMInterfaces
.
getOutputInterfaces
()
);
md
->
addInputOutputInterfaces
(
findTLMInterfaces
.
getInputOutputInterfaces
()
);
FindSignals
signals
(
mainmd
->
getModuleClassDecl
(),
_os
)
;
md
->
addSignals
(
signals
.
getSignals
());
FindSignals
signals
{
mainmd
->
getModuleClassDecl
(),
_os
}
;
md
->
addSignals
(
signals
.
getSignals
()
);
FindEntryFunctions
findEntries
(
mainmd
->
getModuleClassDecl
(),
_os
)
;
FindEntryFunctions
::
entryFunctionVectorType
*
entryFunctions
=
findEntries
.
getEntryFunctions
();
md
->
addProcess
(
entryFunctions
);
FindEntryFunctions
findEntries
{
mainmd
->
getModuleClassDecl
(),
_os
}
;
FindEntryFunctions
::
entryFunctionVectorType
*
entryFunctions
{
findEntries
.
getEntryFunctions
()
}
;
md
->
addProcess
(
entryFunctions
);
for
(
size_t
i
=
0
;
i
<
entryFunctions
->
size
();
i
++
)
{
EntryFunctionContainer
*
ef
=
(
*
entryFunctions
)[
i
];
FindSensitivity
findSensitivity
(
constructor
.
returnConstructorStmt
(),
_os
)
;
ef
->
addSensitivityInfo
(
findSensitivity
);
EntryFunctionContainer
*
ef
{
(
*
entryFunctions
)[
i
]
}
;
FindSensitivity
findSensitivity
{
constructor
.
returnConstructorStmt
(),
_os
}
;
ef
->
addSensitivityInfo
(
findSensitivity
);
if
(
ef
->
getEntryMethod
()
==
nullptr
)
{
if
(
ef
->
getEntryMethod
()
==
nullptr
)
{
_os
<<
"ERROR"
;
continue
;
}
FindWait
findWaits
(
ef
->
getEntryMethod
(),
_os
)
;
FindWait
findWaits
{
ef
->
getEntryMethod
(),
_os
}
;
ef
->
addWaits
(
findWaits
);
FindNotify
findNotify
(
ef
->
_entryMethodDecl
,
_os
)
;
FindNotify
findNotify
{
ef
->
_entryMethodDecl
,
_os
}
;
ef
->
addNotifys
(
findNotify
);
/*
...
...
@@ -119,19 +116,18 @@ bool SystemCConsumer::fire() {
if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG();
//suspensionAutomata.dumpSusCFG();
suspensionAutomata.genSauto();
suspensionAutomata.genSauto();
//suspensionAutomata.dumpSauto();
ef->addSusCFGAuto(suspensionAutomata);
ef->addSusCFGAuto(suspensionAutomata);
}
*/
*/
_entryFunctionContainerVector
.
push_back
(
ef
);
}
moduleDeclVec
.
push_back
(
md
);
}
_systemcModel
->
addModuleDeclInstances
(
mainmd
,
moduleDeclVec
);
}
/*
FindSCMain scmain(tu, _os);
...
...
@@ -205,11 +201,11 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) {
}
SystemCConsumer
::
SystemCConsumer
(
CompilerInstance
&
ci
)
:
_os
(
llvm
::
errs
()
)
,
_sm
(
ci
.
getSourceManager
()
)
,
_context
(
ci
.
getASTContext
()
)
,
_ci
(
ci
)
,
_systemcModel
(
nullptr
)
{
_os
{
llvm
::
errs
()
}
,
_sm
{
ci
.
getSourceManager
()
}
,
_context
{
ci
.
getASTContext
()
}
,
_ci
{
ci
}
,
_systemcModel
{
nullptr
}
{
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment