torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GenericExample.cpp File Reference

Example program to read in an EDIF file, do something with it, and write it back out. More...

#include "torc/Generic.hpp"
#include "torc/Common.hpp"
#include <fstream>
#include <boost/regex.hpp>
+ Include dependency graph for GenericExample.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Detailed Description

Example program to read in an EDIF file, do something with it, and write it back out.

Definition in file GenericExample.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 27 of file GenericExample.cpp.

27  {
28 
29  // build the file paths
30  (void) argc;
31  torc::common::DirectoryTree directoryTree(argv[0]);
33  boost::filesystem::path referencePath =
34  executablePath / "torc" / "examples" / "GenericExample.reference.edf";
35  boost::filesystem::path generatedPath =
36  executablePath / "regression" / "GenericExample.generated.edf";
37 
38  // import the EDIF design
39  string inFileName = referencePath.string();
40  fstream fileStream(inFileName.c_str());
41  ObjectFactorySharedPtr factoryPtr(new ObjectFactory());
42  EdifImporter importer(factoryPtr);
43  importer(fileStream, inFileName);
44 
45  // look up an instance of interest
46  RootSharedPtr rootPtr = importer.getRootPtr();
47  InstanceSharedPtr instancePtr = rootPtr->findLibrary("work")->findCell("and")
48  ->findView("verilog")->findInstance("oZ0");
49 
50  // change the INIT property (LUT mask) to XOR
51  PropertySharedPtr initPropertyPtr = instancePtr->getProperty("INIT");
52  string originalMask = initPropertyPtr->getValue().get<Value::String>();
53  std::cout << "The original LUT mask was \"" << originalMask << "\"." << std::endl;
54  Value xorMask(Value::eValueTypeString, string("6"));
55  initPropertyPtr->setValue(xorMask);
56 
57  // export the EDIF design
58  string outFileName = generatedPath.string();
59  fstream edifExport(outFileName.c_str(), ios_base::out);
60  EdifExporter exporter(edifExport);
61  exporter(rootPtr);
62 
63  return 0;
64 }
boost::shared_ptr< Instance > InstanceSharedPtr
boost::shared_ptr< ObjectFactory > ObjectFactorySharedPtr
std::string String
Definition: Value.hpp:61
Encapsulation of filesystem paths that are used by the library.
boost::filesystem::path path
boost::shared_ptr< Property > PropertySharedPtr
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
boost::shared_ptr< Root > RootSharedPtr

+ Here is the call graph for this function: