torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/OutputStreamHelpersUnitTest.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 Source for the torc::physical output stream helpers.
18 
19 #include <boost/test/unit_test.hpp>
22 #include <sstream>
23 
24 namespace torc {
25 namespace physical {
26 
27 BOOST_AUTO_TEST_SUITE(physical)
28 
29 /// \brief Unit test for the output stream helpers.
30 /// \details It's not pretty, and it's incomplete, but it'll have to do for now.
31 BOOST_AUTO_TEST_CASE(OutputStreamHelpersUnitTest) {
32  std::stringstream s;
33 
34  // functions tested:
35  // std::ostream& operator <<(std::ostream& os, const Design& rhs);
36  std::string designName = "blinker";
37  std::string deviceName = "xc5vlx30";
38  std::string devicePackage = "ff324";
39  std::string deviceSpeedGrade = "-1";
40  std::string xdlVersion = "v3.2";
41  DesignSharedPtr designPtr = Factory::newDesignPtr(designName, deviceName, devicePackage,
42  deviceSpeedGrade, xdlVersion);
43  s << *designPtr;
44  BOOST_CHECK_EQUAL(s.str(), "blinker [xc5vlx30ff324-1, v3.2]");
45  s.str(std::string());
46 
47  // functions tested:
48  // std::ostream& operator <<(std::ostream& os, const Module& rhs);
49  std::string moduleName = "osc7";
50  std::string moduleAnchor = "x0y0";
51  ModuleSharedPtr modulePtr = Factory::newModulePtr(moduleName, moduleAnchor);
52  s << *modulePtr;
53  BOOST_CHECK_EQUAL(s.str(), "osc7 [x0y0]");
54  s.str(std::string());
55 
56  // functions tested:
57  // std::ostream& operator <<(std::ostream& os, const Instance& rhs);
58  std::string instanceName = "blink";
59  std::string instanceType = "SLICEL";
60  std::string instanceTile = "CLBLL_X16Y59";
61  std::string instanceSite = "SLICE_X27Y59";
62  InstanceSharedPtr instancePtr = Factory::newInstancePtr(instanceName, instanceType,
63  instanceTile, instanceSite);
64  s << *instancePtr;
65  BOOST_CHECK_EQUAL(s.str(), "blink");
66  s.str(std::string());
67 
68  // functions tested:
69  // std::ostream& operator <<(std::ostream& os, const Net& rhs);
70  std::string netName = "blink";
71  ENetType netType = eNetTypeNormal;
72  NetSharedPtr netPtr = Factory::newNetPtr(netName, netType);
73  s << *netPtr;
74  BOOST_CHECK_EQUAL(s.str(), "blink");
75  s.str(std::string());
76 
77  // functions tested:
78  // std::ostream& operator <<(std::ostream& os, const InstancePin& rhs);
79  std::string pinName = "DQ";
80  InstancePinSharedPtr instancePinPtr = Factory::newInstancePinPtr(instancePtr, pinName);
81  s << *instancePinPtr;
82  BOOST_CHECK_EQUAL(s.str(), "blink.DQ");
83  s.str(std::string());
84 
85  // functions tested:
86  // std::ostream& operator <<(std::ostream& os, const Pip& rhs);
87  std::string pipTile = "CLBLL_X16Y59";
88  std::string pipSource = "L_DQ";
89  std::string pipSink = "SITE_LOGIC_OUTS3";
91  Pip pip = Factory::newPip(pipTile, pipSource, pipSink, pipDirection);
92  s << pip;
93  BOOST_CHECK_EQUAL(s.str(), "CLBLL_X16Y59 L_DQ -> SITE_LOGIC_OUTS3");
94  s.str(std::string());
95 
96  // functions tested:
97  // std::ostream& operator <<(std::ostream& os, const Config& rhs);
98  std::string configName = "blink";
99  std::string configValue = "#FF";
100  Config config(configName, configValue);
101  s << config;
102  BOOST_CHECK_EQUAL(s.str(), "blink:#FF");
103  s.str(std::string());
104 }
105 
106 BOOST_AUTO_TEST_SUITE_END()
107 
108 } // namespace physical
109 } // namespace torc
ENetType
Enumeration of net power types.
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.
std::string string
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
Configuration. A {name:value} pair.
Definition: Config.hpp:39
Header for torc::physical output stream helpers.
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
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.
EPipDirection
Enumeration of pip directionality.
Header for the Factory class.