torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/FactoryUnitTest.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 Factory class.
18 
19 #include <boost/test/unit_test.hpp>
21 
22 namespace torc {
23 namespace physical {
24 
25 BOOST_AUTO_TEST_SUITE(physical)
26 
27 /// \brief Unit test for the Factory class.
28 BOOST_AUTO_TEST_CASE(FactoryUnitTest) {
29  // functions tested:
30  // static DesignSharedPtr newDesignPtr(const string& inName, const string& inDevice,
31  // const string& inPackage, const string& inSpeedGrade, const string& inXdlVersion);
32  DesignSharedPtr designPtr = Factory::newDesignPtr("design", "device", "package", "speed",
33  "version");
34  BOOST_REQUIRE(designPtr.get() != 0);
35 
36  // functions tested:
37  // static ModuleSharedPtr newModulePtr(const string& inName, const string& inAnchor);
38  ModuleSharedPtr modulePtr = Factory::newModulePtr("name", "anchor");
39  BOOST_REQUIRE(modulePtr.get() != 0);
40 
41  // functions tested:
42  // static InstanceSharedPtr newInstancePtr(const string& inName, const string& inType,
43  // const string& inTile, const string& inSite, EInstanceBonding inBonding,
44  // InstanceReferenceSharedPtr inInstanceReferencePtr);
45  InstanceSharedPtr instance1Ptr = Factory::newInstancePtr("name", "type", "tile", "site");
46  BOOST_REQUIRE(instance1Ptr.get() != 0);
47 
48  // functions tested:
49  // static PortSharedPtr newPortPtr(const string& inName, InstanceSharedPtr inInstancePtr,
50  // const string& inPinName);
51  PortSharedPtr portPtr = Factory::newPortPtr("name", instance1Ptr, "pin");
52  BOOST_REQUIRE(portPtr.get() != 0);
53 
54  // functions tested:
55  // static NetSharedPtr newNetPtr(const string& inName, ENetType inNetType = eNetTypeNormal);
56  NetSharedPtr net1Ptr = Factory::newNetPtr("name");
57  BOOST_REQUIRE(net1Ptr.get() != 0);
58 
59  // functions tested:
60  // static InstanceReferenceSharedPtr newInstanceReferencePtr(const string& inInstantiationName,
61  // ModuleSharedPtr inModulePtr, InstanceSharedPtr inInstancePtr);
62  InstanceReferenceSharedPtr instanceReferencePtr = Factory::newInstanceReferencePtr("name",
63  modulePtr, instance1Ptr);
64  BOOST_REQUIRE(instanceReferencePtr.get() != 0);
65 
66  // functions tested:
67  InstanceSharedPtr instance2Ptr = Factory::newInstancePtr("name", "type", "tile", "site",
68  eInstanceBondingUnknown, instanceReferencePtr);
69  BOOST_REQUIRE(instance2Ptr.get() != 0);
70 
71  // functions tested:
72  // static torc::physical::InstancePin newInstancePinPtr(InstanceSharedPtr inInstancePtr,
73  // const string& inPinName);
74  InstancePinSharedPtr instancePinPtr = Factory::newInstancePinPtr(instance2Ptr, "pin");
75  BOOST_REQUIRE(instancePinPtr->getInstancePtr().lock() == instance2Ptr);
76 
77  // functions tested:
78  // static RoutethroughSharedPtr newRoutethroughPtr(const string& inSetting,
79  // const string& inName, const string& inValue, const InstanceWeakPtr& inInstancePtr,
80  // const string& inSourceWireName, const string& inSinkWireName);
81  RoutethroughSharedPtr routethroughPtr = Factory::newRoutethroughPtr("setting", "name", "value",
82  instance2Ptr, "source", "sink");
83  BOOST_REQUIRE(routethroughPtr.get() != 0);
84 
85  // functions tested:
86  // static torc::physical::Pip newPip(const string& inTileName, const string& inSourceWireName,
87  // const string& inSinkWireName, EPipDirection inPipDirection,
88  // RoutethroughSharedPtr inRoutethroughPtr);
89  Pip pip = Factory::newPip("tile", "source", "sink", ePipUnidirectionalBuffered,
90  routethroughPtr);
91  BOOST_REQUIRE(pip.getRoutethroughPtr() == routethroughPtr);
92 }
93 
94 BOOST_AUTO_TEST_SUITE_END()
95 
96 } // namespace physical
97 } // namespace torc
static PortSharedPtr newPortPtr(const string &inName, InstanceSharedPtr inInstancePtr, const string &inPinName)
Create and return a new Port shared pointer.
boost::shared_ptr< Port > PortSharedPtr
Shared pointer encapsulation of a Port.
static NetSharedPtr newNetPtr(const string &inName, ENetType inNetType=eNetTypeNormal)
Create and return a new Net share pointer.
boost::shared_ptr< class InstancePin > InstancePinSharedPtr
Shared pointer encapsulation of an InstancePin.
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
boost::shared_ptr< Module > ModuleSharedPtr
Shared pointer encapsulation of a Module.
Definition: Module.hpp:114
static torc::physical::Pip newPip(const string &inTileName, const string &inSourceWireName, const string &inSinkWireName, EPipDirection inPipDirection, RoutethroughSharedPtr inRoutethroughPtr=RoutethroughSharedPtr())
Construct a pip and return it.
boost::shared_ptr< Net > NetSharedPtr
Shared pointer encapsulation of a Net.
static InstanceSharedPtr newInstancePtr(const string &inName, const string &inType, const string &inTile, const string &inSite, EInstanceBonding inBonding=eInstanceBondingUnknown, InstanceReferenceSharedPtr inInstanceReferencePtr=InstanceReferenceSharedPtr())
Construct and return a new Instance shared pointer.
boost::shared_ptr< Instance > InstanceSharedPtr
Shared pointer encapsulation of an Instance.
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
Physical design programmable interconnect point.
Definition: Pip.hpp:34
boost::shared_ptr< Routethrough > RoutethroughSharedPtr
Shared pointer encapsulation of a Routethrough.
static RoutethroughSharedPtr newRoutethroughPtr(const string &inSetting, const string &inName, const string &inValue, const InstanceWeakPtr &inInstancePtr, const string &inSourceWireName, const string &inSinkWireName)
Construct and return a new Routethrough shared pointer.
static InstancePinSharedPtr newInstancePinPtr(InstanceSharedPtr inInstancePtr, const string &inPinName)
Construct and return a new InstancePin shared pointer.
static ModuleSharedPtr newModulePtr(const string &inName, const string &inAnchor)
Create and return a new Module shared pointer.
static DesignSharedPtr newDesignPtr(const string &inName, const string &inDevice, const string &inPackage, const string &inSpeedGrade, const string &inXdlVersion)
Create and return a new Design shared pointer.
Header for the Factory class.
boost::shared_ptr< InstanceReference > InstanceReferenceSharedPtr
Shared pointer encapsulation of an InstanceReference.
static InstanceReferenceSharedPtr newInstanceReferencePtr(const string &inInstantiationName, ModuleSharedPtr inModulePtr, InstanceSharedPtr inInstancePtr)
Create and return a new InstanceReference shared pointer.