6 #include "torc/physical/xdl/parser.h"
18 #include <boost/test/unit_test.hpp>
19 #include "OutputStreamHelpers.hpp"
30 BOOST_AUTO_TEST_SUITE(physical_database)
35 const char* designName =
"design";
36 Design design(designName);
37 BOOST_CHECK_EQUAL(designName, design.getName());
40 const char* moduleName =
"module";
41 Module module(moduleName);
42 BOOST_CHECK_EQUAL(moduleName, module.getName());
45 const char* instanceName =
"instance";
46 Instance instance(instanceName);
47 BOOST_CHECK_EQUAL(instanceName, instance.getName());
50 const char* netName =
"net";
52 BOOST_CHECK_EQUAL(netName, net.getName());
60 InstancePin instancePin1(instance,
"pin1");
61 InstancePin instancePin2(instance,
"pin2");
64 net.addSource(instancePin1);
65 net.addSink(instancePin2);
66 BOOST_CHECK(net.hasAnySources());
67 BOOST_CHECK(net.hasOneSource());
68 BOOST_CHECK(net.hasMultipleSources() ==
false);
69 BOOST_CHECK(net.hasAnySinks());
70 BOOST_CHECK(net.hasOneSink());
71 BOOST_CHECK(net.hasMultipleSinks() ==
false);
73 InstancePinVector::const_iterator sourcesBegin = net.sourcesBegin();
74 InstancePinVector::const_iterator sourcesEnd = net.sourcesEnd();
75 InstancePinVector::const_iterator sinksBegin = net.sinksBegin();
76 InstancePinVector::const_iterator sinksEnd = net.sinksEnd();
77 BOOST_CHECK_EQUAL(*sourcesBegin, instancePin1);
78 BOOST_CHECK_EQUAL(*sinksBegin, instancePin2);
79 BOOST_CHECK(net.containsSource(instancePin1));
80 BOOST_CHECK(net.containsSource(instancePin2) ==
false);
81 BOOST_CHECK(net.containsSink(instancePin1) ==
false);
82 BOOST_CHECK(net.containsSink(instancePin2));
85 BOOST_CHECK(net.removeSource(instancePin1));
86 BOOST_CHECK(net.removeSource(instancePin2) ==
false);
87 BOOST_CHECK(net.removeSink(instancePin1) ==
false);
88 BOOST_CHECK(net.removeSink(instancePin2));
89 sourcesBegin = net.sourcesBegin();
90 sourcesEnd = net.sourcesEnd();
91 sinksBegin = net.sinksBegin();
92 sinksEnd = net.sinksEnd();
93 BOOST_CHECK_EQUAL(sourcesBegin, sourcesEnd);
94 BOOST_CHECK_EQUAL(sinksBegin, sinksEnd);
95 BOOST_CHECK(net.hasAnySources() ==
false);
96 BOOST_CHECK(net.hasOneSource() ==
false);
97 BOOST_CHECK(net.hasMultipleSources() ==
false);
98 BOOST_CHECK(net.hasAnySinks() ==
false);
99 BOOST_CHECK(net.hasOneSink() ==
false);
100 BOOST_CHECK(net.hasMultipleSinks() ==
false);
106 Routethrough routethrough(
"setting",
"name",
"value", instance,
"source",
"sink");
110 net.addPip(pip2, routethrough);
111 BOOST_CHECK(net.containsPip(pip1));
112 BOOST_CHECK(net.containsPip(pip2));
114 BOOST_CHECK(pip1.isRoutethrough() ==
false);
115 BOOST_CHECK(pip2.isRoutethrough() ==
false);
116 PipVector::const_iterator pipsBegin = net.pipsBegin();
117 PipVector::const_iterator pipsEnd = net.pipsEnd();
118 BOOST_CHECK((pipsBegin++)->isRoutethrough() ==
false);
119 BOOST_CHECK((pipsBegin++)->isRoutethrough());
122 BOOST_CHECK(net.removePip(pip1));
123 BOOST_CHECK(net.removePip(pip2));
124 BOOST_CHECK(net.containsPip(pip1) ==
false);
125 BOOST_CHECK(net.containsPip(pip2) ==
false);
126 pipsBegin = net.pipsBegin();
127 pipsEnd = net.pipsEnd();
128 BOOST_CHECK_EQUAL(pipsBegin, pipsEnd);
131 Config config1(
"name1",
"value1");
132 Config config2(
"name2",
"value2");
133 Config config3(
"name3",
"value3");
134 Config config4(
"name4",
"value4");
137 configMap.setConfig(
"config", config1);
138 configMap.setConfig(
"config", config2);
139 configMap.setConfig(
"_config", config3);
140 configMap.setConfig(
"_config", config4);
141 BOOST_CHECK(configMap.hasConfig(
"config"));
142 BOOST_CHECK(configMap.hasConfig(
"_config"));
143 BOOST_CHECK_EQUAL((
size_t) 1, configMap.getMultiConfigCount(
"config"));
144 BOOST_CHECK_EQUAL((
size_t) 2, configMap.getMultiConfigCount(
"_config"));
146 configMap.getConfig(
"config", config5);
147 BOOST_CHECK_EQUAL(config2, config5);
150 BOOST_CHECK_EQUAL(config3, p->second); p++;
151 BOOST_CHECK_EQUAL(config4, p->second); p++;
152 BOOST_CHECK_EQUAL(config2, p->second); p++;
153 std::pair<ConfigMap::const_iterator, ConfigMap::const_iterator> range
154 = configMap.getMultiConfigValues(
"_config");
158 std::cout << p->first <<
":" << p->second.getName() <<
":" << p->second.getValue() << std::endl;
163 module.addInstance(instance);
166 design.addModule(module);
169 ModuleVector::const_iterator modulesBegin = design.modulesBegin();
170 ModuleVector::const_iterator modulesEnd = design.modulesEnd();
171 BOOST_CHECK_EQUAL(*modulesBegin, module);
173 InstanceVector::const_iterator instancesBegin = module.instancesBegin();
174 InstanceVector::const_iterator instancesEnd = module.instancesEnd();
175 NetVector::const_iterator netsBegin = module.netsBegin();
176 NetVector::const_iterator netsEnd = module.netsEnd();
177 BOOST_CHECK_EQUAL(*instancesBegin, instance);
178 BOOST_CHECK_EQUAL(*netsBegin, net);
181 BOOST_AUTO_TEST_SUITE_END()
Header for the Module class.
Header for the ConfigMap class.
Header for the Config class.
Header for the Instance class.
Header for the Routethrough class.
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
const_iterator const_iterator
Constant iterator to {setting,Config} pairs.
Header for the Design class.
Header for the Named class.
Header for the Net class.
Header for the Pip class.
Header for the InstancePin class.