torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VerilogExporter.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Source for the VerilogExporter class.
18 
21 #include "torc/Generic.hpp"
22 #include <fstream>
23 #include <sstream>
24 
25 namespace torc {
26 namespace generic {
27 
28  using namespace std;
29  using namespace torc;
30 
31  VerilogExporter::VerilogExporter(RootSharedPtr inRootPtr) : mRootPtr(inRootPtr) {}
32 
34 
35  // prepare the output stream
36  string outFileName = path.string();
37  fstream verilogExport(outFileName.c_str(), ios_base::out);
38  return (*this)(verilogExport);
39  }
40 
41  bool VerilogExporter::operator()(std::ostream& inOutputStream) {
42 
43  // export the Verilog code
44  torc::generic::VerilogExporterVisitor verilogExporterVisitor(mRootPtr, inOutputStream);
45  try {
46  mRootPtr->accept(verilogExporterVisitor);
47  } catch(Error& e) {
48  e.setCurrentLocation(__FUNCTION__, __FILE__, __LINE__);
49  throw;
50  }
51 
52  return true; //mSuccess;
53  }
54 
55 } // namespace generic
56 } // namespace torc
Main torc::generic namespace header.
RootSharedPtr mRootPtr
Root of the generic netlist.
VerilogExporter(RootSharedPtr inRootPtr)
Public constructor.
Header for the VerilogExporter class.
bool operator()(const boost::filesystem::path &inFilename)
Export Verilog to a file.
The Error object thrown by different methods of EdifOM.
Definition: Error.hpp:41
boost::filesystem::path path
Generic netlist object visitor for output as structural Verilog.
Header for the VerilogExporterVisitor class.
boost::shared_ptr< Root > RootSharedPtr
void setCurrentLocation(const std::string &inFunction, const std::string &inFile, uint32_t inLine)
Definition: Error.cpp:73