torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DDBUnitTest.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 Unit test for the DDB class.
18 
19 #include <boost/test/unit_test.hpp>
23 #include "torc/common/Devices.hpp"
27 #include <iostream>
28 
29 namespace torc {
30 namespace architecture {
31 
32 BOOST_AUTO_TEST_SUITE(architecture)
33 
34 using namespace torc::architecture::xilinx;
35 
36 void testDevice(const std::string& inDeviceName);
37 void testDevice(const std::string& inDeviceName) {
38  // functions not tested:
39  // (note: some of these functions are tested in their respective classes)
40  // const string& getFamilyName(void) const;
41  // const Segments& getSegments(void) const;
42  // const WireUsage& getWireUsage(void) const;
43  // const ArcUsage& getArcUsage(void) const;
44  // void clearUsage(void);
45 
46  // functions tested:
47  // DDB(const string& inDeviceName);
48  DDB ddb(inDeviceName);
49 
50  // functions tested:
51  // const string& getDeviceName(void) const;
52  BOOST_CHECK_EQUAL(ddb.getDeviceName(), inDeviceName);
53 
54  // for now this test merely opens representative device databases; regression tests are
55  // performed elsewhere
56  if(true) return;
57 
58  // functions tested:
59  // const Tiles& getTiles(void) const;
60  std::map<TileTypeIndex, int> tileTypeMap;
61  const Tiles& tiles = ddb.getTiles();
62  TileCount tileCount = tiles.getTileCount();
63  for(TileIndex tileIndex; tileIndex < tileCount; tileIndex++) {
64  const TileInfo& tileInfo = tiles.getTileInfo(tileIndex);
65  TileTypeIndex tileTypeIndex = tileInfo.getTypeIndex();
66  const std::string& tileTypeName = tiles.getTileTypeName(tileTypeIndex);
67  tileTypeMap[tileTypeIndex] = 0;
68  (void) tileTypeName;
69  }
70  std::cout << tileTypeMap.size() << " tile types" << std::endl;
71 
72  // functions tested
73  // const Sites& getSites(void) const;
74  std::map<std::string, int> siteTypeMap;
75  const Sites& sites = ddb.getSites();
76  SiteCount siteCount = sites.getSiteCount();
77  for(SiteIndex siteIndex; siteIndex < siteCount; siteIndex++) {
78  const Site& site = sites.getSite(siteIndex);
79  const std::string& siteTypeName = site.getPrimitiveDefPtr()->getName();
80  siteTypeMap[siteTypeName] = 0;
81  }
82  std::cout << ddb;
83  std::cout << siteTypeMap.size() << " site types" << std::endl;
84 }
85 
86 /// \brief Unit test for the DDB class.
87 BOOST_AUTO_TEST_CASE(DDBUnitTest) {
88  // iterate over the devices
90  torc::common::DeviceVector::const_iterator dp = devices.begin();
91  torc::common::DeviceVector::const_iterator de = devices.end();
92  while(dp < de) {
93  const std::string& device = *dp++;
94  if(device.empty()) break;
95  testDevice(device);
96  }
97 }
98 
99 BOOST_AUTO_TEST_SUITE_END()
100 
101 } // namespace architecture
102 } // namespace torc
SiteCount getSiteCount(void) const
Returns the site count for this device.
Definition: Sites.hpp:121
Encapsulation of a tile index in an unsigned 32-bit integer.
const string & getDeviceName(void) const
Returns the device name.
Definition: DDB.hpp:132
const PrimitiveDef * getPrimitiveDefPtr(void) const
Returns a pointer to the associated primitive definition.
Definition: Site.hpp:81
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
BOOST_AUTO_TEST_CASE(ArcUnitTest)
Unit test for the Arc class.
Definition: ArcUnitTest.cpp:29
const Tiles & getTiles(void) const
Returns a constant reference to the family and device tile data.
Definition: DDB.hpp:146
const TileInfo & getTileInfo(TileIndex inTileIndex) const
Returns the TileInfo object for the specified tile.
Definition: Tiles.hpp:137
Header for the Sites class.
Encapsulation of a site count in an unsigned 32-bit integer.
Header for the DDBStreamHelper class.
void testDevice(const std::string &inDeviceName)
Definition: DDBUnitTest.cpp:37
TileCount getTileCount(void) const
Returns the tile count for this device.
Definition: Tiles.hpp:149
const Sites & getSites(void) const
Returns a constant reference to the family and device site data.
Definition: DDB.hpp:144
std::string string
Header for torc::physical output stream helpers.
Encapsulation of a device logic site.
Definition: Site.hpp:30
Site type and population data for the family and the device.
Definition: Sites.hpp:45
Tile map, tile type, and wire information for the family and device.
Definition: Tiles.hpp:36
Encapsulation of a tile count in an unsigned 32-bit integer.
Encapsulation of a tile within a device tile map.
Definition: TileInfo.hpp:33
const char * getTileTypeName(TileTypeIndex inTileTypeIndex) const
Returns the tile type name for the given tile type index.
Definition: Tiles.hpp:164
Header for the Devices class.
const TileTypeIndex & getTypeIndex(void) const
Returns the tile type index for this tile.
Definition: TileInfo.hpp:92
const Site & getSite(SiteIndex inSiteIndex) const
Returns the site for the specified index.
Definition: Sites.hpp:129
Header for the Array class.
Encapsulation of a site index in an unsigned 32-bit integer.
Encapsulation of a tile type index in an unsigned 16-bit integer.
Header for the DDB class.
std::vector< std::string > DeviceVector
Vector of device names.
Definition: Devices.hpp:119
static const DeviceVector & getUnitTestDevices(void)
Returns a subset of devices for unit tests.
Definition: Devices.hpp:209
const string & getName(void) const
Returns the name of the primitive.
Device database types for Xilinx architectures.