84 set<MachineValidator::ErrorCode> errorsToCheck;
89 machineValidator.
validate(errorsToCheck);
91 for (
int i = 0; i < results->
errorCount(); i++) {
94 string msg =
"ADF file doesn't have a GCU.";
98 string msg =
"No address space bound to GCU.";
149 "Can't determine global connection register.");
154 vector<pair<string, string> > missingInputs;
155 vector<pair<string, string> > missingOutputs;
161 if ((missingInputs.size() > 0) || (missingOutputs.size() > 0)) {
162 for (
unsigned int i = 0; i < missingInputs.size(); i++) {
164 missing.append(
"Missing connection: ");
165 missing.append(missingInputs[i].first);
166 missing.append(
" : ");
167 missing.append(missingInputs[i].second);
168 missing.append(
" -> ");
172 for (
unsigned int i = 0; i < missingOutputs.size(); i++) {
174 missing.append(
"Missing connection: ");
176 missing.append(
" -> ");
177 missing.append(missingOutputs[i].first);
178 missing.append(
" : ");
179 missing.append(missingOutputs[i].second);
200 for (std::set<ErrorCode>::const_iterator iter = errorsToCheck.begin();
201 iter != errorsToCheck.end(); iter++) {
213 "Can't determine global connection register.");
220 "Can't determine global connection register.");
223 vector<pair<string, string> > missingInputs;
224 vector<pair<string, string> > missingOutputs;
230 if ((missingInputs.size() > 0) || (missingOutputs.size() > 0)) {
231 for (
unsigned int i = 0; i < missingInputs.size(); i++) {
233 missing.append(
"Missing connection: ");
234 missing.append(missingInputs[i].first);
235 missing.append(
" : ");
236 missing.append(missingInputs[i].second);
237 missing.append(
" -> ");
241 for (
unsigned int i = 0; i < missingOutputs.size(); i++) {
243 missing.append(
"Missing connection: ");
245 missing.append(
" -> ");
246 missing.append(missingOutputs[i].first);
247 missing.append(
" : ");
248 missing.append(missingOutputs[i].second);
274 string msg =
"Error found in boolean register check.";
283 "Can't determine global connection register.");
284 string msg =
"Global connection register can't be determined.";
290 vector<pair<string, string> > missingInputs;
291 vector<pair<string, string> > missingOutputs;
298 if ((missingInputs.size() > 0) || (missingOutputs.size() > 0)) {
299 for (
unsigned int i = 0; i < missingInputs.size(); i++) {
301 missing.append(
"Missing connection: ");
302 missing.append(missingInputs[i].first);
303 missing.append(
" : ");
304 missing.append(missingInputs[i].second);
305 missing.append(
" -> ");
309 for (
unsigned int i = 0; i < missingOutputs.size(); i++) {
311 missing.append(
"Missing connection: ");
313 missing.append(
" -> ");
314 missing.append(missingOutputs[i].first);
315 missing.append(
" : ");
316 missing.append(missingOutputs[i].second);
323 return binaryProgram;
338 std::vector<std::string> missingOps;
341 string msg =
"Operation missing from the minimal operation set: ";
342 std::vector<std::string>::iterator it = missingOps.begin();
343 std::vector<std::string>::iterator end = missingOps.end();
364 bool returnValue =
true;
368 for (
int i = 0; i < nav.
count(); i++) {
370 if (rf->
width() == 1) {
376 "Multiple boolean registers.");
385 "No boolean register found.");
392 for (
int i = 0; i < busNav.
count(); i++) {
397 if (registerGuard != NULL) {
404 "Missing boolean register guard on bus: ";
406 message.append(bus->
name()));
414 "Missing boolean register guard on bus: ";
416 message.append(bus->
name()));
434 const Port* sourcePort,
435 const Port* destPort,
475 std::cout << sourceUnit->
name() <<
" : "
479 << destOperation->
name()
482 << segment->
name() <<
") "
491 std::cout << sourceUnit->
name() <<
" : "
496 << segment->
name() <<
") "
505 std::cout << sourceUnit->
name() <<
" : "
512 << segment->
name() <<
") "
517 else if (sourceRF != 0) {
528 std::cout << sourceUnit->
name() <<
" : "
534 << destOperation->
name()
537 << segment->
name() <<
") "
544 std::cout << sourceUnit->
name() <<
" : "
550 << segment->
name() <<
") "
558 std::cout << sourceUnit->
name() <<
" : "
565 << segment->
name() <<
") "
588 if (registerGuard != NULL) {
592 guard = registerGuard;
610 const Port* sourcePort,
611 const Port* destPort,
641 const FUPort* destFUPort =
642 dynamic_cast<const FUPort*
>(destBaseFUPort);
651 new Instruction(NullInstructionTemplate::instance());
652 int destOperand = destOperation->
io(*destFUPort);
660 auto move = std::make_shared<Move>(source,
674 new Instruction(NullInstructionTemplate::instance());
682 auto move = std::make_shared<Move>(source,
694 =
new Instruction(NullInstructionTemplate::instance());
700 auto move = std::make_shared<Move>(source,
710 else if (sourceRF != 0) {
717 const FUPort* destFUPort =
718 dynamic_cast<const FUPort*
>(destBaseFUPort);
725 NullInstructionTemplate::instance());
726 int destOperand = destOperation->
io(*destFUPort);
734 auto move = std::make_shared<Move>(source,
747 new Instruction(NullInstructionTemplate::instance());
755 auto move = std::make_shared<Move>(source,
768 new Instruction(NullInstructionTemplate::instance());
776 auto move = std::make_shared<Move>(source,
798 set<Segment*>& connections,
803 for (
int i = 0; i < busNav.
count(); i++) {
811 connections.insert(segment);
829 vector<pair<string, string> >& toConnections,
830 vector<pair<string, string> >& fromConnections) {
837 map<const Socket*, Connections> rfConnections =
843 n != (*i).second.end(); n++) {
844 if ((*n).first->direction() == Socket::OUTPUT) {
847 set<Segment*> outputIntersection;
850 m != rfConnections.end(); m++) {
851 if ((*m).first->direction() == Socket::INPUT) {
858 if (outputIntersection.size() == 0) {
859 toConnections.push_back(
860 pair<string, string>(
862 (*n).first->name()));
864 }
else if ((*n).first->direction() == Socket::INPUT) {
865 set<Segment*> inputIntersection;
868 m != rfConnections.end(); m++) {
869 if ((*m).first->direction() == Socket::OUTPUT) {
875 (*n).second.triggeredInputs,
880 if (inputIntersection.size() == 0) {
881 fromConnections.push_back(
882 pair<string, string>((*i).first,
883 (*n).first->name()));
894 n != (*i).second.end(); n++) {
895 if ((*n).first->direction() == Socket::OUTPUT) {
898 set<Segment*> outputIntersection;
901 m != rfConnections.end(); m++) {
902 if ((*m).first->direction() == Socket::INPUT) {
909 if (outputIntersection.size() == 0) {
910 toConnections.push_back(
911 pair<string, string>(
912 (*i).first, (*n).first->name()));
914 }
else if ((*n).first->direction() == Socket::INPUT) {
915 set<Segment*> inputIntersection;
918 m != rfConnections.end(); m++) {
919 if ((*m).first->direction() == Socket::OUTPUT) {
925 (*n).second.triggeredInputs,
930 if (inputIntersection.size() == 0) {
931 fromConnections.push_back(
932 pair<string, string>(
933 (*i).first, (*n).first->name()));
942 set<Segment*> outputIntersection;
943 set<Segment*> inputIntersection;
946 n != (*i).second.end(); n++) {
947 if ((*n).first->direction() == Socket::OUTPUT) {
952 m != rfConnections.end(); m++) {
953 if ((*m).first->direction() == Socket::INPUT) {
962 if (outputIntersection.size() == 0) {
963 toConnections.push_back(pair<string, string>((*i).first,
"-"));
969 set<Segment*> outputIntersection;
970 set<Segment*> inputIntersection;
973 n != (*i).second.end(); n++) {
975 if ((*n).first->direction() == Socket::OUTPUT) {
980 m != rfConnections.end(); m++) {
982 if ((*m).first->direction() == Socket::INPUT) {
989 }
else if ((*n).first->direction() == Socket::INPUT) {
992 m != rfConnections.end(); m++) {
994 if ((*m).first->direction() == Socket::OUTPUT) {
1003 if (outputIntersection.size() == 0) {
1004 toConnections.push_back(pair<string, string>((*i).first,
"-"));
1006 if (inputIntersection.size() == 0) {
1011 fromConnections.push_back(
1012 pair<string, string>((*i).first,
"-"));
1027 map<const Socket*, Connections> rfConnections =
1033 n != (*i).second.end(); n++) {
1035 if ((*n).first->direction() == Socket::OUTPUT) {
1038 set<Segment*> outputIntersection;
1041 m != rfConnections.end(); m++) {
1043 if ((*m).first->direction() == Socket::INPUT) {
1045 (*n).second.outputs,
1047 outputIntersection);
1050 if (outputIntersection.size() == 0) {
1051 cout <<
"Missing connection: " << (*i).first
1052 <<
": " << (*n).first->name()
1053 <<
" -> " << rf->
name() <<
": " << endl;
1055 }
else if ((*n).first->direction() == Socket::INPUT) {
1056 set<Segment*> inputIntersection;
1059 m != rfConnections.end(); m++) {
1061 if ((*m).first->direction() == Socket::OUTPUT) {
1064 (*m).second.outputs,
1067 (*n).second.triggeredInputs,
1068 (*m).second.outputs,
1072 if (inputIntersection.size() == 0) {
1073 cout <<
"Missing connection: " << rf->
name()
1074 <<
" -> " << (*i).first
1075 <<
": " << (*n).first->name() << endl;
1086 n != (*i).second.end(); n++) {
1088 if ((*n).first->direction() == Socket::OUTPUT) {
1091 set<Segment*> outputIntersection;
1094 m != rfConnections.end(); m++) {
1096 if ((*m).first->direction() == Socket::INPUT) {
1098 (*n).second.outputs,
1100 outputIntersection);
1103 if (outputIntersection.size() == 0) {
1104 cout <<
"Missing connection: " << (*i).first
1105 <<
": " << (*n).first->name()
1106 <<
" -> " << rf->
name() << endl;
1108 }
else if ((*n).first->direction() == Socket::INPUT) {
1109 set<Segment*> inputIntersection;
1112 m != rfConnections.end(); m++) {
1114 if ((*m).first->direction() == Socket::OUTPUT) {
1117 (*m).second.outputs,
1120 (*n).second.triggeredInputs,
1121 (*m).second.outputs,
1125 if (inputIntersection.size() == 0) {
1126 cout <<
"Missing connection: " << rf->
name()
1127 <<
" -> " << (*i).first
1128 <<
": " << (*n).first->name() << endl;
1137 set<Segment*> outputIntersection;
1138 set<Segment*> inputIntersection;
1141 n != (*i).second.end(); n++) {
1143 if ((*n).first->direction() == Socket::OUTPUT) {
1148 m != rfConnections.end(); m++) {
1150 if ((*m).first->direction() == Socket::INPUT) {
1152 (*n).second.outputs,
1154 outputIntersection);
1159 if (outputIntersection.size() == 0) {
1160 cout <<
"Missing connection: " << (*i).first
1161 <<
" -> " << rf->
name() << endl;
1166 set<Segment*> outputIntersection;
1167 set<Segment*> inputIntersection;
1170 n != (*i).second.end(); n++) {
1172 if ((*n).first->direction() == Socket::OUTPUT) {
1177 m != rfConnections.end(); m++) {
1179 if ((*m).first->direction() == Socket::INPUT) {
1181 (*n).second.outputs,
1183 outputIntersection);
1186 }
else if ((*n).first->direction() == Socket::INPUT) {
1189 m != rfConnections.end(); m++) {
1191 if ((*m).first->direction() == Socket::OUTPUT) {
1194 (*m).second.outputs,
1200 if (outputIntersection.size() == 0) {
1201 cout <<
"Missing connection: " << (*i).first
1202 <<
" -> " << rf->
name() << endl;
1204 if (inputIntersection.size() == 0) {
1205 cout <<
"Missing connection: " << rf->
name()
1206 <<
" -> " << (*i).first << endl;
1220 set<Segment*>& newConnections,
1221 set<Segment*>& connections) {
1223 set<Segment*>::iterator i = newConnections.begin();
1224 for (; i != newConnections.end(); i++) {
1225 connections.insert(*i);
1239 set<HWOperation*>& operations) {
1256 if ((*connectionIter).sourcePort->parentUnit() ==
1258 (*connectionIter).destPort->parentUnit() ==
1262 (*connectionIter).sourcePort,
1263 (*connectionIter).destPort,
1264 (*connectionIter).segment);
1281 const Port* sourcePort,
1282 const Port* destPort,
1285 pair<const Port*, const Port*> connectionPair =
1286 pair<const Port*, const Port*>(sourcePort, destPort);
1287 pair<portSetIter, bool> result =
gcrConnections.insert(connectionPair);
1290 if (result.second) {
1301 if (destRegister != NULL) {
1302 if (sourceRegister != NULL) {
1305 pair<const RegisterFile*, const RegisterFile*>(
1306 sourceRegister, destRegister);
1307 pair<registerRegisterSetIter, bool> registerRegisterResult =
1309 if (registerRegisterResult.second) {
1318 pair<const Port*, const RegisterFile*> portRegisterPair =
1319 pair<const Port*, const RegisterFile*>(
1320 sourcePort, destRegister);
1321 pair<portRegisterSetIter, bool> portRegisterResult =
1323 if (portRegisterResult.second) {
1331 }
else if (sourceRegister != NULL) {
1332 pair<const RegisterFile*, const Port*> registerPortPair =
1333 pair<const RegisterFile*, const Port*>(
1334 sourceRegister, destPort);
1335 pair<registerPortSetIter, bool> registerPortResult =
1337 if (registerPortResult.second) {
1366 cout <<
"----------------------------------------" << endl;
1367 cout <<
"Total: " << counter <<
" connections" << endl;
1381 for (
int i = 0; i < fuNav.
count(); i++) {
1383 map<const Socket*, Connections> fuConnections;
1387 for (
int j = 0; j < fu->
portCount(); j++) {
1394 if (socket != NULL) {
1397 set<Segment*> fuInputs;
1408 fuConnections[socket] = connections;
1409 inputs.push_back(pair<
const Port*, set<Segment*> >(
1417 for (
int i = 0; i < rfNav.
count(); i++) {
1420 map<const Socket*, Connections> rfConnections;
1422 for (
int j = 0; j < rf->
portCount(); j++) {
1427 if (socket != NULL) {
1430 set<Segment*> rfInputs;
1434 rfConnections[socket] = connections;
1437 set<Segment*> >(port, rfInputs));
1446 map<const Socket*, Connections> gcuConnections;
1447 for (
int j = 0; j < gcu->
portCount(); j++) {
1454 if (socket != NULL) {
1456 set<Segment*> gcuInputs;
1466 set<Segment*> >(port, gcuInputs));
1468 gcuConnections[socket] = connections;
1477 for (
int i = 0; i < fuNav.
count(); i++) {
1479 set<const Socket*> outputs;
1480 for (
int j = 0; j < fu->
portCount(); j++) {
1485 if (socket != NULL) {
1487 set<Segment*> outputConnections;
1490 for (
unsigned int k = 0; k <
inputs.size(); k++) {
1491 set<Segment*> intersection;
1501 map<const Socket*, Connections> socketConnections =
1503 Connections connections = socketConnections[socket];
1505 set<Segment*>::iterator iter =
1506 intersection.begin();
1507 for (; iter != intersection.end(); iter++) {
1512 connections.
outputs.insert(*iter);
1516 socketConnections[socket] = connections;
1522 for (
int i = 0; i < rfNav.
count(); i++) {
1524 set<const Socket*> outputs;
1525 for (
int j = 0; j < rf->
portCount(); j++) {
1530 if (socket != NULL) {
1531 set<Segment*> outputConnections;
1534 for (
unsigned int k = 0; k <
inputs.size(); k++) {
1535 set<Segment*> intersection;
1541 map<const Socket*, Connections> socketConnections =
1543 Connections connections = socketConnections[socket];
1545 set<Segment*>::iterator iter =
1546 intersection.begin();
1547 for (; iter != intersection.end(); iter++) {
1552 connections.
outputs.insert(*iter);
1556 socketConnections[socket] = connections;
1565 for (
int i = 0; i < immNav.
count(); i++) {
1568 set<const Socket*> outputs;
1569 for (
int j = 0; j < imm->
portCount(); j++) {
1574 if (socket != NULL) {
1575 set<Segment*> outputConnections;
1577 for (
unsigned int k = 0; k <
inputs.size(); k++) {
1578 set<Segment*> intersection;
1582 map<const Socket*, Connections> socketConnections =
1584 Connections connections = socketConnections[socket];
1586 set<Segment*>::iterator iter =
1587 intersection.begin();
1588 for (; iter != intersection.end(); iter++) {
1594 connections.
outputs.insert(*iter);
1599 socketConnections[socket] = connections;
1606 set<const Socket*> outputs;
1607 for (
int j = 0; j < gcu->
portCount(); j++) {
1612 if (socket != NULL) {
1613 set<Segment*> outputConnections;
1615 for (
unsigned int k = 0; k <
inputs.size(); k++) {
1616 set<Segment*> intersection;
1620 map<const Socket*, Connections> socketConnections =
1622 Connections connections = socketConnections[socket];
1624 set<Segment*>::iterator iter =
1625 intersection.begin();
1626 for (; iter != intersection.end(); iter++) {
1631 connections.
outputs.insert(*iter);
1635 socketConnections[socket] = connections;
1688 const Port* sourcePort,
1689 const Port* destPort,
1692 pair<const Port*, const Port*> connectionPair =
1693 pair<const Port*, const Port*>(sourcePort, destPort);
1694 pair<portSetIter, bool> result =
allConnections.insert(connectionPair);
1697 if (result.second) {
1708 if (destRegister != NULL) {
1709 if (sourceRegister != NULL) {
1712 pair<const RegisterFile*, const RegisterFile*>(
1713 sourceRegister, destRegister);
1714 pair<registerRegisterSetIter, bool> registerRegisterResult =
1716 if (registerRegisterResult.second) {
1725 pair<const Port*, const RegisterFile*> portRegisterPair =
1726 pair<const Port*, const RegisterFile*>(
1727 sourcePort, destRegister);
1728 pair<portRegisterSetIter, bool> portRegisterResult =
1730 if (portRegisterResult.second) {
1738 }
else if (sourceRegister != NULL) {
1739 pair<const RegisterFile*, const Port*> registerPortPair =
1740 pair<const RegisterFile*, const Port*>(
1741 sourceRegister, destPort);
1742 pair<registerPortSetIter, bool> registerPortResult =
1744 if (registerPortResult.second) {
1776 cout <<
"---------------------------" << endl;
1777 cout <<
"Total: " << counter <<
" connections" << endl;
1793 int maxConnectivity = 0;
1804 for (
int i = 0; i < busNav.
count(); i++) {
1806 int width = bus->
width();
1809 if (width > maxWidth) {
1814 for (
int i = 0; i < rfNav.
count(); i++) {
1817 if (rf->
width() >= maxWidth) {
1818 map<const Socket*, Connections> rfConns =
1820 set<Segment*> intersection;
1826 n != rfConns.end(); n++) {
1828 inputs += (*n).second.inputs.size();
1829 outputs += (*n).second.outputs.size();
1831 int sum =
inputs + outputs;
1832 int connectivity = 0;
1834 connectivity = sum - (
inputs - outputs);
1836 connectivity = sum - (outputs -
inputs);
1838 if (connectivity > maxConnectivity) {
1840 maxConnectivity = connectivity;
1842 maxOutputs = outputs;
1843 }
else if (connectivity == maxConnectivity) {
1844 if (sum > (maxInputs + maxOutputs)) {
1846 maxConnectivity = connectivity;
1848 maxOutputs = outputs;