diff --git a/src/Model.cpp b/src/Model.cpp index b54c665da..1b7d4736c 100644 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -128,21 +128,23 @@ Model::eventMapType Model::getEventMapType() { return event_map_; } unsigned int Model::getNumEvents() { return (event_map_.size() - 3); } void Model::dump(llvm::raw_ostream &os) { - os << "\n# Number of modules : " << modules_.size(); + os << "-- Number of sc_module instances: " << modules_.size(); os << "\n"; for (const auto & mod : modules_ ) { // - os << "Instance name " << mod.first ; + os << "-- Instance name: " << mod.first ; mod.second->dump(os); } + /* for (Model::moduleMapType::iterator mit = modules_.begin(); mit != modules_.end(); mit++) { // Second is the ModuleDecl type. + os << "\n"; vector instanceVec = module_instance_map_[mit->second]; - os << "\n# Module " << mit->first << ": " << instanceVec.size() + os << " Module " << mit->first << ": " << instanceVec.size() << " instances."; for (size_t i = 0; i < instanceVec.size(); i++) { // os <<", instance: " << i + 1 << " "; @@ -150,6 +152,7 @@ void Model::dump(llvm::raw_ostream &os) { } } os << "\n\n"; + */ os << "# Global events:\n"; for (Model::eventMapType::iterator it = event_map_.begin(), diff --git a/src/SystemCClang.cpp b/src/SystemCClang.cpp index 5807a646f..9f439f23c 100644 --- a/src/SystemCClang.cpp +++ b/src/SystemCClang.cpp @@ -241,6 +241,7 @@ bool SystemCConsumer::fire() { module_decl_instances); } + /* //////////////////////////////////////////////////////////////// // Figure out the module map. //////////////////////////////////////////////////////////////// @@ -330,6 +331,7 @@ bool SystemCConsumer::fire() { } // systemcModel_->addModuleDeclInstances(mainmd, moduleDeclVec); } + */ /* FindSCMain scmain(tu, os_); @@ -349,7 +351,6 @@ bool SystemCConsumer::fire() { FindNetlist findNetlist(scmain.getSCMainFunctionDecl()); findNetlist.dump(); systemcModel_->addNetlist(findNetlist); - */ // Only do this if SAUTO flag is set. #ifdef USE_SAUTO @@ -384,8 +385,8 @@ bool SystemCConsumer::fire() { } #endif - os_ << "\n"; - os_ << "\n## SystemC model\n"; + */ + os_ << "[Parsed SystemC model from systemc-clang] \n"; systemcModel_->dump(os_); return true; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f3a7d79a6..6b0e8aab9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,7 +14,7 @@ file(COPY data DESTINATION ${CMAKE_BINARY_DIR}/tests/ ) file(COPY ../examples/llnl-examples DESTINATION ${CMAKE_BINARY_DIR}/tests/data ) set( UNIT_TEST_LIST - # t1 + t1 t2 t3 sreg-test diff --git a/tests/t1.cpp b/tests/t1.cpp index cff634dae..5c978c5c4 100644 --- a/tests/t1.cpp +++ b/tests/t1.cpp @@ -80,7 +80,7 @@ int sc_main(int argc, char *argv[]) { test_instance.in_out(double_sig); test_instance.out1(sig1); - simple_module simple("simple_module"); + simple_module simple("simple_module_instance"); simple.one(sig1); return 0; @@ -98,66 +98,57 @@ int sc_main(int argc, char *argv[]) { // model->dump(llvm::outs()); auto module_decl{model->getModuleDecl()}; - SECTION("Found sc_modules", "[modules]") { + auto test_module{std::find_if( + module_decl.begin(), module_decl.end(), [](const auto &element) { + return element.second->getInstanceName() == "testing"; + })}; + + auto simple_module{std::find_if( + module_decl.begin(), module_decl.end(), [](const auto &element) { + return element.second->getInstanceName() == "simple_module_instance"; + })}; + + SECTION("Found sc_module instances", "[instances]") { // There should be 2 modules identified. - INFO( "ERROR: number of sc_module declarations found: " << module_decl.size() ); - REQUIRE(module_decl.size() == 2); + INFO("ERROR: number of sc_module declarations found: " + << module_decl.size()); - // Check their names, and that their pointers are not nullptr. - - auto test_module{ - std::find_if( - module_decl.begin(), module_decl.end(), - [](const auto &element) { return element.first == "test"; })}; - REQUIRE(test_module != module_decl.end() ); - auto simple_module{ - std::find_if( - module_decl.begin(), module_decl.end(), - [](const auto &element) { return element.first == "simple_module"; })}; - REQUIRE(simple_module != module_decl.end() ); - - SECTION("Checking member ports for test instance", "[ports]") { - // These checks should be performed on the declarations. - - // The module instances have all the information. - // This is necessary until the parsing code is restructured. - // There is only one module instance - auto module_instances{model->getModuleInstanceMap()}; - //auto p_module{module_decl.find("test")}; - - auto p_module{ - std::find_if( - module_decl.begin(), module_decl.end(), - [](const auto &element) { return element.first == "test"; })}; - auto test_module{module_instances[p_module->second].front()}; - - // Check if the proper number of ports are found. - REQUIRE(test_module->getIPorts().size() == 3); - REQUIRE(test_module->getOPorts().size() == 2); - REQUIRE(test_module->getIOPorts().size() == 1); - REQUIRE(test_module->getSignals().size() == 1); - REQUIRE(test_module->getOtherVars().size() == 1); - REQUIRE(test_module->getInputStreamPorts().size() == 0); - REQUIRE(test_module->getOutputStreamPorts().size() == 0); - } + REQUIRE(module_decl.size() == 2); - SECTION("Checking member ports for simple module instance", "[ports]") { - auto module_instances{model->getModuleInstanceMap()}; - // auto p_module{module_decl.find("simple_module")}; - auto p_module{ - std::find_if( - module_decl.begin(), module_decl.end(), - [](const auto &element) { return element.first == "simple_module"; })}; - auto test_module{module_instances[p_module->second].front()}; - - // Check if the proper number of ports are found. - REQUIRE(test_module->getIPorts().size() == 3); - REQUIRE(test_module->getOPorts().size() == 1); - REQUIRE(test_module->getIOPorts().size() == 0); - REQUIRE(test_module->getSignals().size() == 0); - REQUIRE(test_module->getOtherVars().size() == 1); - REQUIRE(test_module->getInputStreamPorts().size() == 0); - REQUIRE(test_module->getOutputStreamPorts().size() == 0); - } + REQUIRE(test_module != module_decl.end()); + REQUIRE(simple_module != module_decl.end()); + + INFO("Checking member ports for test instance."); + // These checks should be performed on the declarations. + + // The module instances have all the information. + // This is necessary until the parsing code is restructured. + // There is only one module instance + // auto module_instances{model->getModuleInstanceMap()}; + // auto p_module{module_decl.find("test")}; + // + // + auto test_module_inst{test_module->second}; + + // Check if the proper number of ports are found. + REQUIRE(test_module_inst->getIPorts().size() == 3); + REQUIRE(test_module_inst->getOPorts().size() == 2); + REQUIRE(test_module_inst->getIOPorts().size() == 1); + REQUIRE(test_module_inst->getSignals().size() == 1); + REQUIRE(test_module_inst->getOtherVars().size() == 1); + REQUIRE(test_module_inst->getInputStreamPorts().size() == 0); + REQUIRE(test_module_inst->getOutputStreamPorts().size() == 0); + + INFO("Checking member ports for simple module instance."); + auto simple_module_inst{simple_module->second}; + + // Check if the proper number of ports are found. + REQUIRE(simple_module_inst->getIPorts().size() == 3); + REQUIRE(simple_module_inst->getOPorts().size() == 1); + REQUIRE(simple_module_inst->getIOPorts().size() == 0); + REQUIRE(simple_module_inst->getSignals().size() == 0); + REQUIRE(simple_module_inst->getOtherVars().size() == 1); + REQUIRE(simple_module_inst->getInputStreamPorts().size() == 0); + REQUIRE(simple_module_inst->getOutputStreamPorts().size() == 0); } }