torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Virtex5PrimitiveStructureUnitTest.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 Virtex5PrimitiveStructure class.
30 BOOST_AUTO_TEST_CASE(Virtex5PrimitiveStructureUnitTest) {
31 
32  using namespace torc::architecture;
33  // open and initialize a database
34 // DDB ddb("xc2vp4");
35  DDB ddb("xc5vlx30");
36  // look up the logic sites in the device
37  const Sites& sites = ddb.getSites();
38  // define a vector of PrimitiveStructure objects
39  typedef std::map<std::string, PrimitiveStructureSharedPtr> PrimitiveStructuresSharedPtrMap;
40  PrimitiveStructuresSharedPtrMap primitiveStructures;
41  // look up the primitive def types
42  typedef const Array<const PrimitiveDef> PrimitiveDefArray;
43  PrimitiveDefArray& primitiveDefs = sites.getSiteTypes();
44  PrimitiveDefArray::const_iterator p = primitiveDefs.begin();
45  PrimitiveDefArray::const_iterator e = primitiveDefs.end();
46  while(p < e) {
47  // create a PrimitiveStructure object for this PrimitiveDef
48  PrimitiveStructureSharedPtr primitiveStructurePtr(new Virtex5PrimitiveStructure(&*p++));
49  const torc::architecture::PrimitiveDef* primitiveDefPtr
50  = primitiveStructurePtr->getPrimitiveDefPtr();
51  const std::string& primitiveDefName = primitiveDefPtr->getName();
52  // insert the PrimitiveStructure into the map
53  primitiveStructures[primitiveDefName] = primitiveStructurePtr;
54  }
55 
56  // iterate through the PrimitiveStructure entries in the map
57  // (just to make sure we can read out what we put in)
58  PrimitiveStructuresSharedPtrMap::iterator psp = primitiveStructures.begin();
59  PrimitiveStructuresSharedPtrMap::iterator pse = primitiveStructures.end();
60  while(psp != pse) {
61  // look up the PrimitiveDef name and the PrimitiveStructure object
62  std::string primitiveDefName = psp->first;
63  PrimitiveStructureSharedPtr primitiveStructurePtr = psp->second;
64  (void) primitiveStructurePtr;
65  //const torc::architecture::PrimitiveDef* primitiveDefPtr
66  // = primitiveStructurePtr->getPrimitiveDefPtr();
67  // std::cout << "PrimitiveDef: " << primitiveDefName << std::endl;
68  psp++;
69  }
70 
71 }
72 
73 BOOST_AUTO_TEST_SUITE_END()
74 
75 } // namespace architecture
76 } // namespace torc
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
Header for the Virtex5PrimitiveStructure class.
Encapsulation of primitive site definition, with associated connections, elements, and pins.
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
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.
Subclass of PrimitiveStructure for Virtex5.
Encapsulation of a static array.
Definition: Array.hpp:39
const string & getName(void) const
Returns the name of the primitive.