torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VerilogImporter.hpp
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 Header for the VerilogImporter class.
18 
19 #ifndef TORC_GENERIC_VERILOG_VERILOGIMPORTER_HPP
20 #define TORC_GENERIC_VERILOG_VERILOGIMPORTER_HPP
21 
22 // The foundation of this code comes from Wilson Snyder's Verilator available at
23 // http://www.veripool.org/wiki/verilator.
24 
25 #include "torc/generic/Root.hpp"
26 #include "torc/externals/verilator/src/V3Global.h"
27 #include <boost/smart_ptr.hpp>
28 #include <boost/filesystem.hpp>
29 #include <string>
30 #include <vector>
31 
32 namespace torc {
33 namespace generic {
34 
35 namespace generic { class VerilogImporterUnitTest; }
36 
37  /// \brief Importer from structural verilog format into a generic design.
39  protected:
40  // friends
41  /// \brief The unit test class has access to our internals.
43  // types
44  /// \brief Imported type name.
46  // members
47  /// \brief Name of file or input stream for error messages.
48  string mStreamName;
49  // error flags
50  /// \brief Flag signaling parsing success.
51  bool mSuccess;
52  /// \brief Root of generic netlist.
54  public:
55  // constructors
56  /// \brief Construct the parser importer context.
57  VerilogImporter(void);
58  // operators
59  /// \brief Import Verilog from a file.
60  /// \param inFilename Input file name.
61  /// \param inArguments Additional Verilator command line arguments.
62  /// \returns true if successfully parsed.
63  bool operator()(const boost::filesystem::path& inFilename,
64  const std::string& inArguments = std::string());
65  // functions
66  /// \brief Signals a parsing failure by deasserting the success flag.
67  void failure(void) { mSuccess = false; }
68  // accessors
69  /// \brief Returns a shared pointer for the root.
70  /// \details This root is created and populated during verilog import process.
71  RootSharedPtr getRootPtr(void) { return mRootPtr; }
72  };
73 
74 } // namespace generic
75 } // namespace torc
76 
77 #endif // TORC_GENERIC_VERILOG_VERILOGIMPORTER_HPP
Importer from structural verilog format into a generic design.
string mStreamName
Name of file or input stream for error messages.
friend class torc::generic::generic::VerilogImporterUnitTest
The unit test class has access to our internals.
bool mSuccess
Flag signaling parsing success.
VerilogImporter(void)
Construct the parser importer context.
bool operator()(const boost::filesystem::path &inFilename, const std::string &inArguments=std::string())
Import Verilog from a file.
std::string string
RootSharedPtr mRootPtr
Root of generic netlist.
std::string string
Imported type name.
boost::filesystem::path path
void failure(void)
Signals a parsing failure by deasserting the success flag.
RootSharedPtr getRootPtr(void)
Returns a shared pointer for the root.
boost::shared_ptr< Root > RootSharedPtr