00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <boost/test/unit_test.hpp>
00020 #include "torc/architecture/Tiles.hpp"
00021 #include "torc/architecture/DDB.hpp"
00022 #include "torc/common/Devices.hpp"
00023
00024 namespace torc {
00025 namespace architecture {
00026
00027 BOOST_AUTO_TEST_SUITE(architecture)
00028
00029
00030 void testDeviceTiles(DDB& inDDB);
00031
00032
00033 BOOST_AUTO_TEST_CASE(TilesUnitTest) {
00034
00035
00036 const torc::common::DeviceVector& devices = torc::common::Devices::getUnitTestDevices();
00037 torc::common::DeviceVector::const_iterator dp = devices.begin();
00038 torc::common::DeviceVector::const_iterator de = devices.end();
00039 while(dp < de) {
00040 const std::string& device = *dp++;
00041 if(device.empty()) break;
00042 DDB ddb(device);
00043 testDeviceTiles(ddb);
00044 }
00045
00046 }
00047
00048 void testDeviceTiles(DDB& inDDB) {
00049
00050
00051
00052
00053
00054
00055 const Tiles& tiles = inDDB.getTiles();
00056
00057
00058
00059
00060
00061 xilinx::TileTypeCount tileTypeCount = tiles.getTileTypeCount();
00062 if(tileTypeCount == xilinx::TileTypeCount(0))
00063 BOOST_CHECK(tileTypeCount != 0);
00064
00065
00066
00067
00068
00069 for(xilinx::TileTypeIndex tileTypeIndex; tileTypeIndex < tileTypeCount; tileTypeIndex++) {
00070 const char* tileTypeName = tiles.getTileTypeName(tileTypeIndex);
00071 if(*tileTypeName == 0)
00072 BOOST_CHECK(*tileTypeName != 0);
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 xilinx::TileCount tileCount = tiles.getTileCount();
00084 xilinx::TileRow rowCount = tiles.getRowCount();
00085 xilinx::TileCol colCount = tiles.getColCount();
00086 if(tileCount == xilinx::TileCount(0))
00087 BOOST_CHECK(tileCount != 0);
00088 if(rowCount == xilinx::TileRow(0))
00089 BOOST_CHECK(rowCount != 0);
00090 if(colCount == xilinx::TileCol(0))
00091 BOOST_CHECK(colCount != 0);
00092 if(static_cast<int>(tileCount) != rowCount * colCount)
00093 BOOST_CHECK_EQUAL(static_cast<int>(tileCount), rowCount * colCount);
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 for(xilinx::TileIndex tileIndex; tileIndex < tileCount; tileIndex++) {
00106
00107 const TileInfo& tileInfo = tiles.getTileInfo(tileIndex);
00108
00109 xilinx::TileRow tileRow = tileInfo.getRow();
00110 xilinx::TileCol tileCol = tileInfo.getCol();
00111 const char* tileName = tileInfo.getName();
00112 if(*tileName == 0)
00113 BOOST_CHECK(*tileName != 0);
00114 xilinx::TileIndex rowColTileIndex = tiles.getTileIndex(tileRow, tileCol);
00115 if(tileIndex != rowColTileIndex)
00116 BOOST_CHECK_EQUAL(tileIndex, rowColTileIndex);
00117 xilinx::TileIndex findTileIndex = tiles.findTileIndex(tileName);
00118 if(tileIndex != findTileIndex)
00119 BOOST_CHECK_EQUAL(tileIndex, findTileIndex);
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 for(xilinx::TileTypeIndex tileTypeIndex; tileTypeIndex < tileTypeCount; tileTypeIndex++) {
00132
00133 xilinx::WireCount wireCount = tiles.getWireCount(tileTypeIndex);
00134 const Array<const WireInfo>& wireInfoArray = tiles.getWireInfo(tileTypeIndex);
00135 for(xilinx::WireIndex wireIndex; wireIndex < wireCount; wireIndex++) {
00136 const WireInfo& wireInfo = tiles.getWireInfo(tileTypeIndex, wireIndex);
00137 if(&wireInfo != &wireInfoArray[wireIndex])
00138 BOOST_CHECK(&wireInfo == &wireInfoArray[wireIndex]);
00139 const char* wireName = wireInfo.getName();
00140 if(*wireName == 0)
00141 BOOST_CHECK(*wireName != 0);
00142 xilinx::WireIndex findWireIndex = tiles.findWireIndex(tileTypeIndex, wireName);
00143 if(wireIndex != findWireIndex)
00144 BOOST_CHECK_EQUAL(wireIndex, findWireIndex);
00145 }
00146 }
00147 }
00148
00149 BOOST_AUTO_TEST_SUITE_END()
00150
00151 }
00152 }