rdaly525 / coreir

BSD 3-Clause "New" or "Revised" License
101 stars 24 forks source link

Link #996

Closed rdaly525 closed 3 years ago

rdaly525 commented 3 years ago

This PR creates the following APIs relating to loading and generating header and implementation files.

//"Header" is a set of module declarations (should contain no definitions, although it does not check)
 // loaded_modules will contain a set of modules which this header declared.
 bool loadHeader(Context*c, std::string filename, std::vector<Module*>& loaded_modules);

 //"Impl" a set of modules and definitions.
 //Each module in this file should already exist as a declaration in the context
 bool linkImpl(Context*c, std::string filename);

 //Given a set of modules, this will save a file with only the listed modules as declarations
 bool serializeHeader(Context*c, std::string filename, std::vector<std::string> modules);

 //Given a set of modules, this will save a file containing all the modules required to implement those modules.
 bool serializeImpl(Context*c, std::string filename, std::vector<std::string> modules);

Along with a new API to serialize a single circuit (specified by a top) to json. This new API does not require any hacky library/namespace specification.

 bool serializeToFile(Context* c, std::string filename);

These APIs are tested in test/gtests/test_linking.cpp

Internal changes required for this to work