torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex7PrimitiveStructureUnitTest.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 Virtex2PrimitiveStructure class.
18 
19 #include <boost/test/unit_test.hpp>
22 #include <iostream>
23 
24 namespace torc {
25 namespace packer {
26 
27 BOOST_AUTO_TEST_SUITE(packer)
28 
29 /// \brief Unit test for the Virtex7PrimitiveStructure class.
30 BOOST_AUTO_TEST_CASE(Virtex7PrimitiveStructureUnitTest) {
31 
32  using namespace torc::architecture;
33  // open and initialize a database
34  DDB ddb("xc7a100t");
35  // look up the logic sites in the device
36  const Sites& sites = ddb.getSites();
37  // define a vector of PrimitiveStructure objects
38  typedef std::map<std::string, PrimitiveStructureSharedPtr> PrimitiveStructuresSharedPtrMap;
39  PrimitiveStructuresSharedPtrMap primitiveStructures;
40  // look up the primitive def types
41  typedef const Array<const PrimitiveDef> PrimitiveDefArray;
42  PrimitiveDefArray& primitiveDefs = sites.getSiteTypes();
43  PrimitiveDefArray::const_iterator p = primitiveDefs.begin();
44  PrimitiveDefArray::const_iterator e = primitiveDefs.end();
45  while(p < e) {
46  // create a PrimitiveStructure object for this PrimitiveDef
47  PrimitiveStructureSharedPtr primitiveStructurePtr(new Virtex7PrimitiveStructure(&*p++));
48  const torc::architecture::PrimitiveDef* primitiveDefPtr
49  = primitiveStructurePtr->getPrimitiveDefPtr();
50  const std::string& primitiveDefName = primitiveDefPtr->getName();
51  // insert the PrimitiveStructure into the map
52  primitiveStructures[primitiveDefName] = primitiveStructurePtr;
53  }
54 
55  // iterate through the PrimitiveStructure entries in the map
56  // (just to make sure we can read out what we put in)
57  PrimitiveStructuresSharedPtrMap::iterator psp = primitiveStructures.begin();
58  PrimitiveStructuresSharedPtrMap::iterator pse = primitiveStructures.end();
59  while(psp != pse) {
60  // look up the PrimitiveDef name and the PrimitiveStructure object
61  std::string primitiveDefName = psp->first;
62  PrimitiveStructureSharedPtr primitiveStructurePtr = psp->second;
63  (void) primitiveStructurePtr;
64  //const torc::architecture::PrimitiveDef* primitiveDefPtr
65  // = primitiveStructurePtr->getPrimitiveDefPtr();
66  // std::cout << "PrimitiveDef: " << primitiveDefName << std::endl;
67  psp++;
68  }
69 
70 }
71 
72 BOOST_AUTO_TEST_SUITE_END()
73 
74 } // namespace architecture
75 } // namespace torc
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
Encapsulation of primitive site definition, with associated connections, elements, and pins.
Header for the Virtex7PrimitiveStructure class.
const Sites & getSites(void) const
Returns a constant reference to the family and device site data.
Definition: DDB.hpp:144
std::string string
Site type and population data for the family and the device.
Definition: Sites.hpp:45
Subclass of PrimitiveStructure for Virtex7.
BOOST_AUTO_TEST_CASE(PrimitiveStructureUnitTest)
Unit test for the PrimitiveStructure class.
T * begin(void)
Returns the non-constant begin iterator.
Definition: Array.hpp:95
boost::shared_ptr< PrimitiveStructure > PrimitiveStructureSharedPtr
Shared pointer encapsulation of a PrimitiveStructure.
Header for the DDB class.
Encapsulation of a static array.
Definition: Array.hpp:39
const string & getName(void) const
Returns the name of the primitive.