torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PipUnitTest.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 Pip class.
18 
19 #include <boost/test/unit_test.hpp>
21 #include "torc/physical/Pip.hpp"
22 
23 namespace torc {
24 namespace physical {
25 
26 BOOST_AUTO_TEST_SUITE(physical)
27 
28 /// \brief Unit test for the Pip class.
29 BOOST_AUTO_TEST_CASE(PipUnitTest) {
30  // create an accessory instance and routethrough
31  InstanceSharedPtr instancePtr = Factory::newInstancePtr("name", "type", "tile", "site",
33  BOOST_REQUIRE(instancePtr.get() != 0);
34  RoutethroughSharedPtr routethroughPtr = Factory::newRoutethroughPtr("setting", "name", "value",
35  instancePtr, "source", "sink");
36  BOOST_REQUIRE(routethroughPtr.get() != 0);
37 
38  // functions tested:
39  // Pip(const string& inTileName, const string& inSourceWireName,
40  // const string& inSinkWireName, EPipDirection inPipDirection,
41  // RoutethroughSharedPtr inRoutethroughPtr);
42  std::string tile = "tile";
43  std::string source = "source";
44  std::string sink = "sink";
46  Pip pip1 = Factory::newPip(tile, source, sink, direction, routethroughPtr);
47  Pip pip2 = Factory::newPip(tile, source, sink, direction, routethroughPtr);
48 
49  // functions tested:
50  // const TileName& getTileName(void) const;
51  // const WireName& getSourceWireName(void) const;
52  // const WireName& getSinkWireName(void) const;
53  // EPipDirection getDirection(void) const;
54  // const char* getDirectionString(void) const;
55  // static const char* getDirectionString(EPipDirection inPipDirection);
56  BOOST_CHECK_EQUAL(pip1.getTileName(), tile);
57  BOOST_CHECK_EQUAL(pip1.getSourceWireName(), source);
58  BOOST_CHECK_EQUAL(pip1.getSinkWireName(), sink);
59  BOOST_CHECK(pip1.getDirection() == direction);
60  BOOST_CHECK(pip1.getDirectionString() == Pip::getDirectionString(direction));
61  BOOST_CHECK_EQUAL("==", Pip::getDirectionString(ePipBidirectionalUnbuffered));
64  BOOST_CHECK_EQUAL("->", Pip::getDirectionString(ePipUnidirectionalBuffered));
65 
66  // functions tested:
67  // RoutethroughSharedPtr getRoutethroughPtr(void) const;
68  // bool isRoutethrough(void) const;
69  BOOST_CHECK(pip1.isRoutethrough());
70  BOOST_CHECK(pip1.getRoutethroughPtr() == routethroughPtr);
71 
72  // functions tested:
73  // bool operator ==(const Pip& rhs) const;
74  BOOST_CHECK(pip1 == pip1); // name based comparison
75 }
76 
77 BOOST_AUTO_TEST_SUITE_END()
78 
79 } // namespace physical
80 } // namespace torc
const char * getDirectionString(void) const
Returns the pip directionality as a string.
Definition: Pip.cpp:32
std::string string
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
const WireName & getSinkWireName(void) const
Returns the pip sink wire.
Definition: Pip.hpp:77
RoutethroughSharedPtr getRoutethroughPtr(void) const
Returns the pip's routethrough pointer.
Definition: Pip.hpp:83
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.
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.
const TileName & getTileName(void) const
Returns the pip tile.
Definition: Pip.hpp:73
EPipDirection getDirection(void) const
Returns the pip directionality.
Definition: Pip.hpp:79
Physical design programmable interconnect point.
Definition: Pip.hpp:34
const WireName & getSourceWireName(void) const
Returns the pip source wire.
Definition: Pip.hpp:75
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.
Header for the Pip class.
EPipDirection
Enumeration of pip directionality.
Header for the Factory class.
static const char * getDirectionString(EPipDirection inPipDirection)
Returns the pip directionality as a string.
Definition: Pip.cpp:36
bool isRoutethrough(void) const
Indicates whether or not the pip has an associated routethrough.
Definition: Pip.hpp:86