13 : module_name_{
"NONE"},
14 instance_name_{
"NONE"},
16 constructor_stmt_{nullptr},
17 constructor_decl_{nullptr},
18 instance_decl_{nullptr} {}
21 const clang::CXXRecordDecl *decl)
23 instance_name_{
"NONE"},
24 class_decl_{const_cast<
clang::CXXRecordDecl *>(decl)},
25 instance_decl_{nullptr} {}
28 const std::tuple<const std::string &, clang::CXXRecordDecl *> &element)
29 : module_name_{get<0>(element)}, class_decl_{get<1>(element)} {}
131 DEBUG_WITH_TYPE(
"DebugDestructors", llvm::dbgs() <<
"\n~ModuleInstance\n";);
143 for (
auto &v :
vef_) {
156 auto iport{get<1>(input_port)};
164 delete get<1>(output_port);
170 delete get<1>(io_port);
176 delete get<1>(other);
180 for (
auto &ef :
vef_) {
198 const std::vector<std::string> &parm_list) {
203 const std::vector<std::string> &parm_list) {
219 const std::vector<std::string> &instanceList) {
229 std::map<std::string, std::string> portSignalMap) {
234 const std::string &port_type) {
235 if (port_type ==
"sc_in") {
236 std::copy(begin(found_ports), end(found_ports), back_inserter(
in_ports_));
238 if (port_type ==
"sc_out") {
239 std::copy(begin(found_ports), end(found_ports), back_inserter(
out_ports_));
241 if (port_type ==
"sc_inout") {
242 std::copy(begin(found_ports), end(found_ports),
245 if (port_type ==
"others") {
246 std::copy(begin(found_ports), end(found_ports),
250 if (port_type ==
"sc_signal") {
252 for (
auto const &signal_port : found_ports) {
253 auto port_decl{get<1>(signal_port)};
254 auto name{port_decl->getName()};
262 if (port_type ==
"sc_stream_in") {
263 std::copy(begin(found_ports), end(found_ports),
266 if (port_type ==
"sc_stream_out") {
267 std::copy(begin(found_ports), end(found_ports),
274 std::string n{mit.first};
284 std::string name{mit.first};
320 for (
unsigned int i = 0; i < efv->size(); ++i) {
324 std::string entryName{ef->
getName()};
325 std::string entryType{
""};
330 entryType =
"SC_THREAD";
334 entryType =
"SC_METHOD";
338 entryType =
"SC_CTHREAD";
360const std::vector<EntryFunctionContainer *>
454 os <<
"nested module " << submod <<
" module type name "
455 << submod->getName();
457 if (submod->getInstanceInfo().getInstanceNames().size() > 0) {
458 os <<
" instance name: ";
460 for (
auto const &name : submod->getInstanceInfo().getInstanceNames()) {
471 "number_of_ports_bound: " + std::to_string(
port_bindings_.size()) +
"\n";
475 auto port_name{get<0>(pb)};
476 auto binding{get<1>(pb)};
479 "caller_instance_type_name: " + binding->getCallerInstanceTypeName() +
481 str +=
"caller_instance_name: " + binding->getCallerInstanceName() +
"\n";
483 for (
const auto &sub : binding->getCallerArraySubscripts()) {
484 auto is_int_lit{clang::dyn_cast<clang::IntegerLiteral>(sub)};
485 auto is_dref_expr{clang::dyn_cast<clang::DeclRefExpr>(sub)};
487 str +=
"caller_array_subscripts: ";
493 str +=
"caller_array_subscripts: " +
494 is_dref_expr->getNameInfo().getName().getAsString() +
"\n";
498 str +=
"caller_port_name: " + binding->getCallerPortName() +
"\n";
500 for (
const auto &sub : binding->getCallerPortArraySubscripts()) {
501 auto is_int_lit{clang::dyn_cast<clang::IntegerLiteral>(sub)};
502 auto is_dref_expr{clang::dyn_cast<clang::DeclRefExpr>(sub)};
504 str +=
"caller_port_array_subscripts: ";
510 str +=
"caller_port_array_subscripts: " +
511 is_dref_expr->getNameInfo().getName().getAsString() +
"\n";
515 str +=
"callee_instance_name:: " + binding->getCalleeInstanceName() +
"\n";
517 for (
const auto &sub : binding->getCalleeArraySubscripts()) {
518 auto is_int_lit{clang::dyn_cast<clang::IntegerLiteral>(sub)};
519 auto is_dref_expr{clang::dyn_cast<clang::DeclRefExpr>(sub)};
521 str +=
"callee_port_array_subscripts: ";
527 str +=
"callee_port_array_subscripts: " +
528 is_dref_expr->getNameInfo().getName().getAsString() +
"\n";
532 str +=
"callee_port_name: " + binding->getCalleePortName() +
"\n";
537 LLVM_DEBUG(llvm::dbgs() << str;);
548 os <<
"\nPort : " << it.first <<
" bound to signal : " << it.second;
555 str +=
"number_of_processes: " + std::to_string(
process_map_.size()) +
"\n";
559 str += pit.first +
": " + pd->
asString() +
"\n";
569 os <<
"Input interfaces: " <<
iinterfaces_.size() <<
"\n";
575 mit.second->dump(os, tabn);
581 os <<
"Output interfaces: " <<
ointerfaces_.size() <<
"\n";
586 mit.second->dump(os, tabn);
597 mit.second->dump(os, tabn);
607 str +=
"number_of_input_ports: " + std::to_string(
in_ports_.size()) +
"\n";
609 auto name = get<0>(mit);
610 auto pd = get<1>(mit);
611 str +=
"name: " + name +
" " + pd->asString() +
"\n";
614 str +=
"number_of_output_ports: " + std::to_string(
out_ports_.size()) +
"\n";
616 auto name = get<0>(mit);
617 auto pd = get<1>(mit);
618 str +=
"name: " + name +
" " + pd->asString() +
"\n";
621 str +=
"number_of_inout_ports: " + std::to_string(
inout_ports_.size()) +
"\n";
623 auto name = get<0>(mit);
624 auto pd = get<1>(mit);
625 str +=
"name: " + name +
" " + pd->asString() +
"\n";
628 str +=
"number_of_instream_ports: " + std::to_string(
istreamports_.size()) +
631 auto name = get<0>(mit);
632 auto pd = get<1>(mit);
633 str +=
"name: " + name +
" " + pd->asString() +
"\n";
636 str +=
"number_of_outstream_ports: " + std::to_string(
ostreamports_.size()) +
639 auto name = get<0>(mit);
640 auto pd = get<1>(mit);
641 str +=
"name: " + name +
" " + pd->asString() +
"\n";
644 str +=
"number_of_other_vars: " + std::to_string(
other_fields_.size()) +
"\n";
646 auto name = get<0>(mit);
647 auto pd = get<1>(mit);
648 str +=
"name: " + name +
" " + pd->asString() +
"\n";
651 str +=
"number_of_nested_modules: " + std::to_string(
nested_modules_.size()) +
654 auto module_name{mit->getName()};
656 auto instance_info{mit->getInstanceInfo()};
657 str +=
"module_name: " + module_name;
658 for (
auto const &inst_name : instance_info.getInstanceNames()) {
659 str +=
" " + inst_name;
664 os <<
"Dump ports\n";
671 str +=
"number_of_signals: " + std::to_string(
signals_.size()) +
"\n";
675 str += sit.first +
" " + s->
asString() +
"\n";
692 os <<
"\n# Instances:\n";
694 os <<
"# Port Declaration:\n";
696 os <<
"\n# Signal Declaration:\n";
698 os <<
"\n# Processes:\n";
702 os <<
"# Signal binding:\n";
712 os <<
"\n=======================================================\n";
721 str +=
"is_array: true\n";
722 str +=
"array_sizes: ";
738 str +=
"template_args: " + std::to_string(
template_args_.size()) +
"\n";
743 str +=
"nested_modules: " + std::to_string(
nested_modules_.size()) +
"\n";
745 for (
auto const &name : submod->getInstanceInfo().getInstanceNames()) {
751 LLVM_DEBUG(llvm::outs() << str;);
clang::CXXMethodDecl * getEntryMethod()
PROCESS_TYPE getProcessType()
clang::CXXConstructorDecl * getConstructorDecl() const
clang::Stmt * getConstructorStmt() const
std::vector< EntryFunctionContainer * > entryFunctionVectorType
Typedefs.
std::map< string, FindTemplateTypes * > interfaceType
void addConstructor(FindConstructor *)
std::pair< std::string, InterfaceDecl * > interfacePairType
std::vector< std::string > template_parameters_
Class template parameters.
std::string instance_name_
const portMapType & getOtherVars()
bool isModuleClassDeclNull()
void addInputInterfaces(FindTLMInterfaces::interfaceType)
portMapType ostreamports_
void addNestedModule(ModuleInstance *submodule)
void addInstances(const std::vector< std::string > &)
std::pair< std::string, ProcessDecl * > processPairType
const std::vector< std::string > & getTemplateParameters() const
ModuleInstance & operator=(const ModuleInstance &from)
portSignalMapType port_signal_map_
const clang::CXXRecordDecl * getModuleClassDecl()
void dumpSignals(llvm::raw_ostream &, int)
void addBaseInstance(ModuleInstance *)
std::vector< ModuleInstance * > base_instances_
clang::Decl * instance_decl_
interfaceMapType ointerfaces_
void setTemplateArgs(const vector< std::string > &)
void dumpPorts(llvm::raw_ostream &)
std::vector< std::tuple< std::string, PortDecl * > > portMapType
const portMapType & getIOPorts()
const portMapType & getOPorts()
void addPortBinding(const std::string &port_name, PortBinding *pb)
std::map< std::string, PortBinding * > portBindingMapType
portMapType other_fields_
const clang::Stmt * getConstructorStmt() const
clang::CXXRecordDecl * class_decl_
void dumpInterfaces(llvm::raw_ostream &, int)
const std::vector< ModuleInstance * > & getNestedModuleInstances() const
void setTemplateParameters(const vector< std::string > &)
void addProcess(FindEntryFunctions::entryFunctionVectorType *)
const portMapType & getOutputStreamPorts()
void addInputOutputInterfaces(FindTLMInterfaces::interfaceType)
std::string dumpPortBinding()
std::map< std::string, InterfaceDecl * > interfaceMapType
void addOutputInterfaces(FindTLMInterfaces::interfaceType)
virtual ~ModuleInstance()
std::vector< std::tuple< std::string, PortDecl * > > PortType
portBindingMapType port_bindings_
std::string getName() const
std::map< std::string, SignalDecl * > signalMapType
std::vector< ModuleInstance * > nested_modules_
Nested modules.
const portMapType & getInputStreamPorts()
const portBindingMapType & getPortBindings()
void dump(llvm::raw_ostream &)
const interfaceMapType & getOInterfaces()
void setModuleName(const std::string &)
const interfaceMapType & getIInterfaces()
ModuleInstanceType getInstanceInfo()
std::string getInstanceName() const
clang::Stmt * constructor_stmt_
portMapType istreamports_
interfaceMapType iointerfaces_
void dump_base_instances(llvm::raw_ostream &os)
const clang::Decl * getInstanceDecl()
void dumpSignalBinding(llvm::raw_ostream &, int)
const clang::CXXConstructorDecl * getConstructorDecl() const
std::pair< std::string, SignalDecl * > signalPairType
void dumpProcesses(llvm::raw_ostream &, int)
interfaceMapType iinterfaces_
const std::vector< ModuleInstance * > & getBaseInstances()
processMapType process_map_
const std::vector< std::string > & getInstanceList()
std::map< std::string, ProcessDecl * > processMapType
std::vector< std::string > instance_list_
void setInstanceInfo(const sc_ast_matchers::ModuleInstanceType &info)
void addSignalBinding(std::map< std::string, std::string >)
std::vector< std::string > template_args_
clang::CXXConstructorDecl * constructor_decl_
std::pair< std::string, PortBinding * > portBindingPairType
std::vector< EntryFunctionContainer * > vef_
ModuleInstance()
Default constructor.
const interfaceMapType & getIOInterfaces()
void dumpInstances(llvm::raw_ostream &, int)
const processMapType & getProcessMap()
int getNumInstances() const
ModuleInstanceType instance_info_
const std::vector< EntryFunctionContainer * > & getEntryFunctionContainer()
void addPorts(const PortType &found_ports, const std::string &port_type)
const portMapType & getIPorts()
const signalMapType & getSignals() const
std::string asString() const
Dump.
std::string asString() const
Dump to string.
Clang forward declarations.
std::string toString(const T &i)
std::vector< llvm::APInt > getArraySizes()
clang::Decl * getInstanceDecl() const
std::string instance_name