00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <sstream>
00020 #include <boost/test/unit_test.hpp>
00021 #include "torc/utils/PhysicalDiff.hpp"
00022
00023 namespace torc {
00024
00025 BOOST_AUTO_TEST_SUITE(utils)
00026
00027
00028 BOOST_AUTO_TEST_CASE(PhysicalDiffDesignUnitTest) {
00029 std::ostringstream nullstream(std::ostringstream::out);
00030 PhysicalDiff pd(nullstream);
00031
00032
00033
00034 std::string designName = "design";
00035 std::string designName2 = "design2";
00036 std::string deviceName = "device";
00037 std::string deviceName2 = "device2";
00038 std::string devicePackage = "package";
00039 std::string devicePackage2 = "package2";
00040 std::string deviceSpeedGrade = "speed_grade";
00041 std::string deviceSpeedGrade2 = "speed_grade2";
00042 std::string xdlVersion = "xdl_version";
00043 std::string xdlVersion2 = "xdl_version2";
00044
00045 physical::DesignSharedPtr designPtrLeft = physical::Factory::newDesignPtr(designName,
00046 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00047 BOOST_REQUIRE(designPtrLeft.get() != 0);
00048 physical::DesignSharedPtr designPtrRight = physical::Factory::newDesignPtr(designName,
00049 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00050 BOOST_REQUIRE(designPtrRight.get() != 0);
00051
00052 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00053 designPtrRight->setDevice(deviceName2);
00054 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00055 designPtrRight->setDevice(deviceName);
00056 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00057
00058 designPtrLeft->setPackage(devicePackage2);
00059 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00060 designPtrLeft->setPackage(devicePackage);
00061 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00062
00063 designPtrLeft->setSpeedGrade(deviceSpeedGrade2);
00064 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00065 designPtrLeft->setSpeedGrade(deviceSpeedGrade);
00066 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00067
00068 designPtrRight->setXdlVersion(xdlVersion2);
00069 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00070 designPtrRight->setXdlVersion(xdlVersion);
00071 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00072
00073 physical::ModuleSharedPtr module1PtrLeft
00074 = physical::Factory::newModulePtr("module1", "anchor1");
00075 physical::ModuleSharedPtr module2PtrLeft
00076 = physical::Factory::newModulePtr("module2", "anchor2");
00077 physical::ModuleSharedPtr module1PtrRight
00078 = physical::Factory::newModulePtr("module1", "anchor1");
00079 physical::ModuleSharedPtr module2PtrRight
00080 = physical::Factory::newModulePtr("module2", "anchor2");
00081
00082 BOOST_REQUIRE(designPtrLeft->addModule(module1PtrLeft) == true);
00083 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00084 BOOST_REQUIRE(designPtrRight->addModule(module1PtrRight) == true);
00085 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00086
00087 BOOST_REQUIRE(designPtrRight->addModule(module2PtrRight) == true);
00088 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00089 BOOST_REQUIRE(designPtrLeft->addModule(module2PtrLeft) == true);
00090 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00091
00092 }
00093
00094
00095 BOOST_AUTO_TEST_CASE(PhysicalDiffModuleUnitTest) {
00096 std::ostringstream nullstream(std::ostringstream::out);
00097 PhysicalDiff pd(nullstream);
00098
00099
00100
00101 std::string anchor = "anchor";
00102 std::string anchor2 = "anchor2";
00103 std::string portname = "port";
00104 std::string portname2 = "port2";
00105 std::string pinname = "pinname";
00106 std::string pinname2 = "pinname2";
00107
00108 physical::InstanceSharedPtr instancePtrLeft
00109 = physical::Factory::newInstancePtr("instname", "type", "tile", "site",
00110 physical::eInstanceBondingUnknown);
00111 physical::InstanceSharedPtr instancePtrRight
00112 = physical::Factory::newInstancePtr("instname", "type", "tile", "site",
00113 physical::eInstanceBondingUnknown);
00114
00115 physical::ModuleSharedPtr modulePtrLeft
00116 = physical::Factory::newModulePtr("module1", anchor);
00117 physical::ModuleSharedPtr modulePtrRight
00118 = physical::Factory::newModulePtr("module1", anchor);
00119 physical::PortSharedPtr portLeft
00120 = physical::Factory::newPortPtr(portname, instancePtrLeft, pinname);
00121 physical::PortSharedPtr portLeft2
00122 = physical::Factory::newPortPtr(portname, instancePtrLeft, pinname2);
00123 physical::PortSharedPtr portRight
00124 = physical::Factory::newPortPtr(portname, instancePtrRight, pinname);
00125 physical::PortSharedPtr portRight2
00126 = physical::Factory::newPortPtr(portname, instancePtrRight, pinname2);
00127
00128 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == true);
00129 modulePtrRight->setAnchor(anchor2);
00130 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == false);
00131 modulePtrRight->setAnchor(anchor);
00132 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == true);
00133
00134 modulePtrLeft->addPort(portLeft);
00135 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == false);
00136 modulePtrRight->addPort(portRight);
00137 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == true);
00138
00139 modulePtrRight->removePort(portRight);
00140 modulePtrRight->addPort(portRight2);
00141 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == false);
00142 modulePtrLeft->removePort(portLeft);
00143 modulePtrLeft->addPort(portLeft2);
00144 BOOST_REQUIRE(pd.diffModule(modulePtrLeft, modulePtrRight) == true);
00145
00146 }
00147
00148
00149 BOOST_AUTO_TEST_CASE(PhysicalDiffCircuitUnitTest) {
00150 std::ostringstream nullstream(std::ostringstream::out);
00151 PhysicalDiff pd(nullstream);
00152
00153
00154
00155 std::string designName = "design";
00156 std::string deviceName = "device";
00157 std::string devicePackage = "package";
00158 std::string deviceSpeedGrade = "speed_grade";
00159 std::string xdlVersion = "xdl_version";
00160
00161 physical::DesignSharedPtr designPtrLeft = physical::Factory::newDesignPtr(designName,
00162 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00163 BOOST_REQUIRE(designPtrLeft.get() != 0);
00164 physical::DesignSharedPtr designPtrRight = physical::Factory::newDesignPtr(designName,
00165 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00166 BOOST_REQUIRE(designPtrRight.get() != 0);
00167
00168 physical::InstanceSharedPtr inst1Left
00169 = physical::Factory::newInstancePtr("name1", "type1", "tile1", "site1");
00170 physical::InstanceSharedPtr inst2Left
00171 = physical::Factory::newInstancePtr("name2", "type2", "tile2", "site2");
00172 physical::InstanceSharedPtr inst1Right
00173 = physical::Factory::newInstancePtr("name1", "type1", "tile1", "site1");
00174 physical::InstanceSharedPtr inst2Right
00175 = physical::Factory::newInstancePtr("name2", "type2", "tile2", "site2");
00176
00177 physical::NetSharedPtr net1Left
00178 = physical::Factory::newNetPtr("name1", physical::eNetTypeNormal);
00179 physical::NetSharedPtr net2Left
00180 = physical::Factory::newNetPtr("name2", physical::eNetTypeNormal);
00181 physical::NetSharedPtr net1Right
00182 = physical::Factory::newNetPtr("name1", physical::eNetTypeNormal);
00183 physical::NetSharedPtr net2Right
00184 = physical::Factory::newNetPtr("name2", physical::eNetTypeNormal);
00185
00186 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00187
00188 designPtrLeft->addInstance(inst1Left);
00189 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00190 designPtrRight->addInstance(inst1Right);
00191 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00192 designPtrRight->addInstance(inst2Right);
00193 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00194 designPtrLeft->addInstance(inst2Left);
00195 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00196
00197 designPtrRight->addNet(net1Right);
00198 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00199 designPtrLeft->addNet(net1Left);
00200 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00201 designPtrLeft->addNet(net2Left);
00202 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00203 designPtrRight->addNet(net2Right);
00204 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00205
00206 }
00207
00208
00209 BOOST_AUTO_TEST_CASE(PhysicalDiffConfigMapUnitTest) {
00210 std::ostringstream nullstream(std::ostringstream::out);
00211 PhysicalDiff pd(nullstream);
00212
00213
00214
00215
00216 std::string designName = "design";
00217 std::string deviceName = "device";
00218 std::string devicePackage = "package";
00219 std::string deviceSpeedGrade = "speed_grade";
00220 std::string xdlVersion = "xdl_version";
00221
00222 std::string setting1 = "setting1";
00223 std::string setting2 = "setting2";
00224
00225 physical::DesignSharedPtr designPtrLeft = physical::Factory::newDesignPtr(designName,
00226 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00227 BOOST_REQUIRE(designPtrLeft.get() != 0);
00228 physical::DesignSharedPtr designPtrRight = physical::Factory::newDesignPtr(designName,
00229 deviceName, devicePackage, deviceSpeedGrade, xdlVersion);
00230 BOOST_REQUIRE(designPtrRight.get() != 0);
00231
00232 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00233
00234 designPtrLeft->setConfig("setting1", "name1", "value1");
00235 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00236 designPtrRight->setConfig("setting1", "name1", "value1");
00237 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00238 designPtrRight->setConfig("setting2", "name2", "value2");
00239 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00240 designPtrLeft->setConfig("setting2", "name2", "value3");
00241 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == false);
00242 designPtrLeft->setConfig("setting2", "name2", "value2");
00243 BOOST_REQUIRE(pd.diffDesign(designPtrLeft, designPtrRight) == true);
00244
00245 }
00246
00247
00248 BOOST_AUTO_TEST_CASE(PhysicalDiffInstanceUnitTest) {
00249 std::ostringstream nullstream(std::ostringstream::out);
00250 PhysicalDiff pd(nullstream);
00251
00252
00253
00254 std::string name = "name";
00255 std::string type = "type";
00256 std::string type2 = "type2";
00257 std::string tile = "tile";
00258 std::string tile2 = "tile2";
00259 std::string site = "site";
00260 std::string site2 = "site2";
00261
00262 physical::InstanceSharedPtr instancePtrLeft
00263 = physical::Factory::newInstancePtr(name, type, tile, site);
00264 BOOST_REQUIRE(instancePtrLeft.get() != 0);
00265 physical::InstanceSharedPtr instancePtrRight
00266 = physical::Factory::newInstancePtr(name, type, tile, site);
00267 BOOST_REQUIRE(instancePtrRight.get() != 0);
00268
00269 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == true);
00270
00271 instancePtrLeft->setType(type2);
00272 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == false);
00273 instancePtrRight->setType(type2);
00274 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == true);
00275
00276 instancePtrRight->setTile(tile2);
00277 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == false);
00278 instancePtrLeft->setTile(tile2);
00279 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == true);
00280
00281 instancePtrLeft->setSite(site2);
00282 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == false);
00283 instancePtrRight->setSite(site2);
00284 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == true);
00285
00286 instancePtrLeft->setBonding(physical::eInstanceBondingBonded);
00287 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == false);
00288 instancePtrRight->setBonding(physical::eInstanceBondingBonded);
00289 BOOST_REQUIRE(pd.diffInstance(instancePtrLeft, instancePtrRight) == true);
00290
00291 }
00292
00293
00294 BOOST_AUTO_TEST_CASE(PhysicalDiffNetUnitTest) {
00295 std::ostringstream nullstream(std::ostringstream::out);
00296 PhysicalDiff pd(nullstream);
00297
00298
00299
00300 physical::InstanceSharedPtr instPtrLeft
00301 = physical::Factory::newInstancePtr("inst1", "itype", "tile", "site");
00302 physical::InstanceSharedPtr instPtrRight
00303 = physical::Factory::newInstancePtr("inst1", "itype", "tile", "site");
00304 physical::InstancePinSharedPtr instPin1LeftPtr
00305 = physical::Factory::newInstancePinPtr(instPtrLeft, "pin1");
00306 physical::InstancePinSharedPtr instPin2LeftPtr
00307 = physical::Factory::newInstancePinPtr(instPtrLeft, "pin2");
00308 physical::InstancePinSharedPtr instPin1RightPtr
00309 = physical::Factory::newInstancePinPtr(instPtrRight, "pin1");
00310 physical::InstancePinSharedPtr instPin2RightPtr
00311 = physical::Factory::newInstancePinPtr(instPtrRight, "pin2");
00312 physical::Pip pip1Left = physical::Factory::newPip(
00313 "tile1", "source1", "sink1", physical::ePipUnidirectionalBuffered);
00314 physical::Pip pip1Right = physical::Factory::newPip(
00315 "tile1", "source1", "sink1", physical::ePipUnidirectionalBuffered);
00316
00317 std::string name = "name";
00318 physical::ENetType type = physical::eNetTypePower;
00319
00320 physical::NetSharedPtr netPtrLeft = physical::Factory::newNetPtr(name, type);
00321 physical::NetSharedPtr netPtrRight = physical::Factory::newNetPtr(name, type);
00322
00323 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == true);
00324
00325 netPtrRight->setNetType(physical::eNetTypeNormal);
00326 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == false);
00327 netPtrLeft->setNetType(physical::eNetTypeNormal);
00328 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == true);
00329
00330 netPtrLeft->addSource(instPin1LeftPtr);
00331 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == false);
00332 netPtrRight->addSource(instPin1RightPtr);
00333 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == true);
00334
00335 netPtrLeft->addSink(instPin2LeftPtr);
00336 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == false);
00337 netPtrRight->addSink(instPin2RightPtr);
00338 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == true);
00339
00340 netPtrRight->addPip(pip1Right);
00341 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == false);
00342 netPtrLeft->addPip(pip1Left);
00343 BOOST_REQUIRE(pd.diffNet(netPtrLeft, netPtrRight) == true);
00344 }
00345
00346 BOOST_AUTO_TEST_SUITE_END()
00347
00348 }