torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TraceUnitTest.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 Regression test for Tracer class.
18 
19 #include <boost/test/unit_test.hpp>
22 #include "torc/router/Trace.hpp"
23 #include <map>
24 
25 //#include <boost/filesystem/convenience.hpp>
27 //#include "torc/physical/Factory.hpp"
28 //#include "torc/physical/XdlExporter.hpp"
31 #include <fstream>
32 
33 namespace torc {
34 namespace router {
35 
37 
43 
44  TraceUnitTestFixture() : ddb("xc5vlx30") {
45  //tracer(*ddbPtr);
46  BOOST_MESSAGE("CONSTRUCT");
47  BOOST_MESSAGE(ddb);
48  ddb.useArc(ddb.tilePipToArc("CLBLL_X16Y42", "SITE_CTRL_B0", "L_CE"));
49  ddb.useArc(ddb.tilePipToArc("CLBLL_X16Y42", "SITE_IMUX_B5", "L_A1"));
50  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "CTRL0", "CTRL_B0"));
51  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "FAN6", "FAN_BOUNCE6"));
52  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "FAN_BOUNCE6", "GFAN1"));
53  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "GFAN1", "CTRL0"));
54  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "NL2END2", "FAN6"));
55  ddb.useArc(ddb.tilePipToArc("INT_X16Y42", "NL2END2", "IMUX_B5"));
56  ddb.useArc(ddb.tilePipToArc("INT_X16Y40", "NW2MID1", "NL2BEG2"));
57 
58  twSource = ddb.lookupTilewire("INT_X16Y40", "NW2MID1");
59  twSink1 = ddb.lookupTilewire("CLBLL_X16Y42", "L_CE");
60  twSink2 = ddb.lookupTilewire("CLBLL_X16Y42", "L_A1");
61  twMid = ddb.lookupTilewire("INT_X16Y42", "FAN_BOUNCE6");
62 
63  BOOST_CHECK_EQUAL(ddb.getArcUsage().getArcUsageCount(), 9u);
64  }
66 };
67 
68 BOOST_AUTO_TEST_SUITE(router)
69 
70 BOOST_FIXTURE_TEST_SUITE(TraceT, TraceUnitTestFixture)
71 
72 BOOST_AUTO_TEST_CASE(trace_full_net) {
73  Trace trace(ddb, twMid, Trace::eTraceFullNet);
74  BOOST_CHECK_EQUAL(trace.getSources().size(), 1u);
75  BOOST_CHECK_EQUAL(trace.getSinks().size(), 2u);
76  BOOST_CHECK_EQUAL(trace.getBranchPoints().size(), 1u);
77  BOOST_CHECK_EQUAL(trace.getArcs().size(), 9u);
78 }
79 
80 BOOST_AUTO_TEST_CASE(trace_to_sinks) {
81  Trace trace(ddb, twMid, Trace::eTraceToSinks);
82  BOOST_CHECK_EQUAL(trace.getSources().size(), 0u);
83  BOOST_CHECK_EQUAL(trace.getSinks().size(), 1u);
84  BOOST_CHECK_EQUAL(trace.getBranchPoints().size(), 0u);
85  BOOST_CHECK_EQUAL(trace.getArcs().size(), 4u);
86 }
87 
88 BOOST_AUTO_TEST_CASE(trace_to_branch) {
89  Trace trace(ddb, twMid, Trace::eTraceToBranch);
90  BOOST_CHECK_EQUAL(trace.getSources().size(), 0u);
91  BOOST_CHECK_EQUAL(trace.getSinks().size(), 1u);
92  BOOST_CHECK_EQUAL(trace.getBranchPoints().size(), 1u);
93  BOOST_CHECK_EQUAL(trace.getArcs().size(), 6u);
94 }
95 
96 BOOST_AUTO_TEST_CASE(trace_to_sources) {
97  Trace trace(ddb, twMid, Trace::eTraceToSources);
98  BOOST_CHECK_EQUAL(trace.getSources().size(), 1u);
99  BOOST_CHECK_EQUAL(trace.getSinks().size(), 0u);
100  BOOST_CHECK_EQUAL(trace.getBranchPoints().size(), 1u);
101  BOOST_CHECK_EQUAL(trace.getArcs().size(), 3u);
102 }
103 
104 BOOST_AUTO_TEST_CASE(trace_single_path) {
105  Trace trace(ddb, twMid, Trace::eTraceSinglePath);
106  BOOST_CHECK_EQUAL(trace.getSources().size(), 0u);
107  BOOST_CHECK_EQUAL(trace.getSinks().size(), 1u);
108  BOOST_CHECK_EQUAL(trace.getBranchPoints().size(), 1u);
109  BOOST_CHECK_EQUAL(trace.getArcs().size(), 6u);
110 }
111 
112 BOOST_AUTO_TEST_SUITE_END()
113 
114 BOOST_AUTO_TEST_SUITE_END()
115 
116 } // namespace router
117 } // namespace torc
TraceNodePtrVector & getSources()
Get trace source nodes.
Definition: Trace.hpp:113
Device database, including complete wiring and logic support.
Definition: DDB.hpp:42
Arc tilePipToArc(const std::string &inTileName, const std::string &inSourceWireName, const std::string &inSinkWireName)
Returns the arc for the specified pip tile and wires.
Definition: DDB.hpp:243
Header for the DirectoryTree class.
ArcUsage & getArcUsage(void)
Returns a constant reference to the design arc usage.
Definition: DDB.hpp:148
uint32_t getArcUsageCount(void) const
Returns the number of arcs in use.
Definition: ArcUsage.hpp:228
void useArc(const Arc &inArc)
Marks the arc and all of its source and sink segment wires as used.
Definition: DDB.hpp:173
TraceNodePtrVector & getBranchPoints()
Get trace branch point nodes.
Definition: Trace.hpp:117
architecture::Tilewire twSink2
Header for Boost.Test helper functions.
ArcVector & getArcs()
Get all Arcs found during the trace.
Definition: Trace.hpp:121
Provides path extraction from usage information in a DDB instance..
Definition: Trace.hpp:36
Encapsulation of a device tile and wire pair.
Definition: Tilewire.hpp:39
Header for torc::physical output stream helpers.
Header for the Trace class.
Tilewire lookupTilewire(const std::string &inTileName, const std::string &inWireName)
Returns the tilewire for the specified tile and wire names.
Definition: DDB.hpp:257
architecture::Tilewire twSource
Header for the DDB class.
architecture::Tilewire twSink1
BOOST_AUTO_TEST_CASE(NetRouterHeuristicT)
Unit test for the Heuristic.
Header for the XdlImporter class.
TraceNodePtrVector & getSinks()
Get trace sink nodes.
Definition: Trace.hpp:109