62 const std::vector<IDF::FUGenerated::DAGOperation> dagops) {
63 std::vector<TTAMachine::HWOperation*> operations;
64 std::vector<std::string> genops;
70 for (
auto&& op : operations) {
74 maxLatency = op->latency() - 1;
77 maxLatency = op->latency() - 2;
80 maxLatency = op->latency();
83 maxLatency = op->latency() - 1;
86 maxLatency = op->latency() - 2;
88 maxLatency = op->latency();
90 for (
auto&& info : infos) {
91 if (op->name() == info.operationName &&
92 maxLatency >= info.latency) {
94 genops.emplace_back(info.operationName);
100 for (
auto&& op : operations) {
101 for (
auto&& dop : dagops) {
102 if (std::find(genops.begin(), genops.end(), op->name()) ==
104 op->name() == dop.operationName) {
106 genops.emplace_back(dop.operationName);
113 if (genops.size() == neededFUops) {
125 const std::string& option, std::vector<std::string> list,
128 for (
auto&& item : list) {
130 if (lowered_item == lowered_option ||
131 (enableAll && lowered_item ==
"all")) {
141 std::vector<IDF::FUGenerated::DAGOperation>
143 const std::vector<IDF::FUGenerated::Info> infos, std::ostream& verbose) {
144 std::vector<IDF::FUGenerated::DAGOperation> dagops;
145 std::set<std::string> opNames;
147 verbose <<
" can implement DAG operations that use:\n ";
149 for (
auto&& info : infos) {
150 verbose << sep << info.operationName;
161 if (opNames.count(opName) > 0) {
165 for (
int d = 0; d < op.
dagCount(); ++d) {
166 std::vector<IDF::FUGenerated::Info> subops;
171 opNames.insert(opName);
178 verbose <<
" can implement DAG operations:\n ";
180 for (
auto&& op : dagops) {
181 verbose << sep << op.operationName;
195 const OperationDAG& dag,
const std::vector<IDF::FUGenerated::Info> infos,
196 std::vector<IDF::FUGenerated::Info>* subops) {
201 bool canImplement =
true;
202 for (
int n = 0; n < dag.
nodeCount(); ++n) {
206 std::string operation =
210 bool foundOperation =
false;
211 for (
auto&& info : infos) {
212 if (info.operationName == operation) {
213 foundOperation =
true;
215 subops->emplace_back(info);
220 if (foundOperation ==
false) {
221 canImplement =
false;
236 const std::unordered_map<std::string, int>& maxOpLatency) {
244 for (
auto node : sinkNodes) {
246 maxLatency = std::max(latency, maxLatency);
254 const std::unordered_map<std::string, int>& maxOpLatency) {
261 if (maxOpLatency.find(subOpName) != maxOpLatency.end()) {
262 latency = maxOpLatency.at(subOpName);
276 const std::unordered_map<std::string, int>& maxOpLatency,
277 bool allowDifference) {
279 int maxLeafLatency = -1;
280 for (
auto&& e : dag.
inEdges(node)) {
286 if (!allowDifference && maxLeafLatency != -1) {
288 maxLeafLatency == parentLatency &&
289 "Two input edges of DAG node have different latency!");
292 maxLeafLatency = std::max(maxLeafLatency, parentLatency);
296 maxLeafLatency = std::max(maxLeafLatency, 0);
299 return maxLeafLatency;
305 std::vector<IDF::FUGenerated::Info>
308 std::vector<IDF::FUGenerated::Info> infos;
310 for (
auto&& hdb :
options.hdbList) {
312 verbose <<
" searching implementations from " << hdbPath <<
"\n";
316 std::vector<IDF::FUGenerated::Info> newInfos;
317 for (
auto&& row : rows) {
320 opimpl.name, hdbPath, opimpl.
id, opimpl.latency});
324 newInfos.begin(), newInfos.end(),
326 return a.latency > b.latency;
329 infos.insert(infos.end(), newInfos.begin(), newInfos.end());
356 for (
auto&& hdb :
options.hdbList) {
361 for (
auto&& row : rows) {
363 if (!fuEntry->hasImplementation() ||
364 !fuEntry->hasArchitecture()) {
368 auto impl = fuEntry->implementation();
370 if (fu.
operationCount() != arch.architecture().operationCount()) {
373 bool wrongLanguage =
false;
374 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
375 auto f = impl.file(i);
379 wrongLanguage =
true;
385 wrongLanguage =
true;
395 if (!arch.architecture().hasOperation(op->name())) {
400 arch.architecture().operation(op->name())->latency()) {
426 for (
auto&& hdb :
options.hdbList) {
431 for (
auto&& row : rows) {
434 if (!rfEntry->hasImplementation() ||
435 !rfEntry->hasArchitecture()) {
439 auto impl = rfEntry->implementation();
440 bool wrongLanguage =
false;
441 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
442 auto f = impl.file(i);
446 wrongLanguage =
true;
452 wrongLanguage =
true;
471 if (1 != arch.latency()) {
477 if (!arch.hasParameterizedWidth() &&
478 (rf.
width() != arch.width())) {
481 if (!arch.hasParameterizedSize() && (rf.
size() != arch.size())) {
504 for (
auto&& hdb :
options.hdbList) {
509 for (
auto&& row : rows) {
512 if (!rfEntry->hasImplementation() ||
513 !rfEntry->hasArchitecture()) {
517 auto impl = rfEntry->implementation();
518 bool wrongLanguage =
false;
519 for (
int i = 0; i < impl.implementationFileCount(); ++i) {
520 auto f = impl.file(i);
524 wrongLanguage =
true;
530 wrongLanguage =
true;
540 if (iu.
maxReads() != arch.readPortCount()) {
543 if (1 != arch.writePortCount()) {
546 if (iu.
latency() != arch.latency()) {
549 if (!arch.hasParameterizedWidth() &&
550 (iu.
width() != arch.width())) {
553 if (!arch.hasParameterizedSize() && (iu.
size() != arch.size())) {