00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "torc/physical/XdlImporter.hpp"
00020 #include "torc/physical/xdl/XdlScanner.hpp"
00021 #include <fstream>
00022 #include <sstream>
00023
00024 namespace torc {
00025 namespace physical {
00026
00027 using namespace std;
00028 using namespace torc;
00029
00030 XdlImporter::XdlImporter(void) : mTraceScanning(false), mTraceParsing(false),
00031 mDesignName(), mDesignPart(), mDesignDevice(), mDesignPackage(), mDesignSpeedGrade(),
00032 mDesignXdlVersion(), mDesignPtr(), mCircuitPtr(), mModuleCount(0), mModuleName(""),
00033 mModuleAnchor(""), mModuleInstance(""), mModulePtr(), mReferenceInstantiation(""),
00034 mReferenceModule(""), mReferenceInstance(""), mReferenceModulePtr(),
00035 mReferenceInstancePtr(), mInstanceReferencePtr(), mPortName(""), mPortInstance(""),
00036 mPortPin(""), mInstanceCount(0), mInstanceName(), mInstanceType(""), mInstanceSite(""),
00037 mInstanceTile(""), mInstanceBonding(eInstanceBondingUnknown), mNetCount(0),
00038 mNetType(eNetTypeNormal), mNetName(), mPinInstance(""), mPinName(""),
00039 mPinDirection(ePinDirectionUnknown), mPipTile(""), mPipSource(""), mPipSink(""),
00040 mPipDirection(static_cast<EPipDirection>(0)), mRoutethroughConfigSetting(),
00041 mRoutethroughConfigName(), mRoutethroughConfigValue(), mRoutethroughInstance(),
00042 mRoutethroughSource(""), mRoutethroughSink(""), mConfigCount(0), mConfigSetting(),
00043 mConfigName(), mConfigValue() {
00044
00045 mSuccess = true;
00046 }
00047
00048 bool XdlImporter::operator()(istream& in, const string& name) {
00049 mStreamName = name;
00050
00051 XdlScanner scanner(&in);
00052 scanner.set_debug(mTraceScanning);
00053 this->lexer = &scanner;
00054
00055 XdlParser parser(*this);
00056 parser.set_debug_level(mTraceParsing);
00057 bool result = parser.parse() == 0;
00058 return mSuccess && result;
00059 }
00060
00061 bool XdlImporter::operator()(const boost::filesystem::path& path) {
00062 string pathname = path.string();
00063 ifstream in(pathname.c_str());
00064 if (!in.good()) return false;
00065 return (*this)(in, pathname);
00066 }
00067
00068 bool XdlImporter::operator()(const string &input, const string& name) {
00069 istringstream iss(input);
00070 return (*this)(iss, name);
00071 }
00072
00073 void XdlImporter::error(const location& l, const string& m) {
00074 failure();
00075 cerr << l << ": " << m << std::endl;
00076 }
00077
00078 void XdlImporter::error(const string& m) {
00079 failure();
00080 cerr << m << std::endl;
00081 }
00082
00083 }
00084 }
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096