9f564b41 by rmrf

The data structure needs to be updated

1 parent 4a0f052a
......@@ -64,6 +64,8 @@ void Model::addNetlist(FindNetlist &n) {
updateModuleDecl();
}
FindNetlist::instanceListModuleMapType Model::getModuleInstanceList() const { return module_instance_list_;}
void Model::updateModuleDecl() {
for (moduleMapType::iterator it = modules_.begin(), eit = modules_.end();
......@@ -121,7 +123,7 @@ Model::entryFunctionGPUMacroMapType Model::getEntryFunctionGPUMacroMap() {
return entry_function_gpu_macro_map_;
}
Model::moduleInstanceMapType Model::getModuleInstanceMap() {
Model::moduleInstanceMapType Model::getModuleInstanceMap() const {
return module_instance_map_;
}
......
......@@ -50,7 +50,8 @@ public:
moduleMapType getModuleDecl() const;
entryFunctionGPUMacroMapType getEntryFunctionGPUMacroMap();
eventMapType getEventMapType();
moduleInstanceMapType getModuleInstanceMap();
moduleInstanceMapType getModuleInstanceMap() const;
FindNetlist::instanceListModuleMapType getModuleInstanceList() const;
unsigned int getNumEvents();
vector<Transition*> getGSauto();
void dump(raw_ostream &);
......
......@@ -4,7 +4,8 @@
using namespace scpar;
PrintJSON::PrintJSON( const Model & model ) {
PrintJSON::PrintJSON( const Model & model ) :
model_(model) {
cout << "PrintJSON\n";
// Modules
......@@ -14,11 +15,30 @@ PrintJSON::PrintJSON( const Model & model ) {
for ( auto const & [name, module_decl] : module_declarations ) {
cout << "json :> " << name << ", " << module_decl << endl;
json_[name]["pointer"] = to_string( module_decl );
// Instances
instance_names( module_decl );
// Ports
//for ( auto const & [port_name, port_decl] : module_decl->getIPorts( )) {
// json_[name]["ports"]["input"] = port_name;
//}
}
cout << json_.dump(4) << endl;
}
void PrintJSON::instance_names( ModuleDecl * module_decl ) {
// <ModuleDecl *, vector<ModuleDecl *>
auto modules{ model_.getModuleInstanceList() };
auto instance_list{ modules[ module_decl->getName() ] };
cout << "json: > instances: " << instance_list.size() << endl;
for ( auto const & instance_names : instance_list ) {
cout << "json: > names: " << instance_names << endl;
json_[module_decl->getName()]["instance"] = instance_names;
}
}
......
......@@ -15,9 +15,11 @@ namespace scpar {
class PrintJSON {
public:
PrintJSON( const Model & model );
void instance_names(ModuleDecl * module_decl);
private:
json json_;
const Model & model_;
// Disallow
PrintJSON();
......