CIRCT  20.0.0git
Design.cpp
Go to the documentation of this file.
1 //===- Design.cpp - ESI design hierarchy implementation -------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // DO NOT EDIT!
10 // This file is distributed as part of an ESI package. The source for this file
11 // should always be modified within CIRCT (lib/dialect/ESI/runtime/cpp/).
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "esi/Design.h"
16 
17 #include <map>
18 #include <stdexcept>
19 
20 using namespace esi;
21 
22 namespace esi {
23 
24 /// Build an index of children by AppID.
25 static std::map<AppID, Instance *>
26 buildIndex(const std::vector<std::unique_ptr<Instance>> &insts) {
27  std::map<AppID, Instance *> index;
28  for (auto &item : insts)
29  index[item->getID()] = item.get();
30  return index;
31 }
32 
33 /// Build an index of ports by AppID.
34 static std::map<AppID, const BundlePort &>
35 buildIndex(const std::vector<std::unique_ptr<BundlePort>> &ports) {
36  std::map<AppID, const BundlePort &> index;
37  for (auto &item : ports)
38  index.emplace(item->getID(), *item);
39  return index;
40 }
41 
42 HWModule::HWModule(std::optional<ModuleInfo> info,
43  std::vector<std::unique_ptr<Instance>> children,
44  std::vector<services::Service *> services,
45  std::vector<std::unique_ptr<BundlePort>> &ports)
46  : info(info), children(std::move(children)),
47  childIndex(buildIndex(this->children)), services(services),
48  ports(std::move(ports)), portIndex(buildIndex(this->ports)) {}
49 
51  bool result = false;
52  for (auto &port : ports)
53  result |= port->poll();
54  for (auto &child : children)
55  result |= child->poll();
56  return result;
57 }
58 
59 } // namespace esi
bool poll()
Master poll method.
Definition: Design.cpp:50
const std::vector< std::unique_ptr< BundlePort > > ports
Definition: Design.h:94
const std::vector< std::unique_ptr< Instance > > children
Definition: Design.h:91
HWModule(std::optional< ModuleInfo > info, std::vector< std::unique_ptr< Instance >> children, std::vector< services::Service * > services, std::vector< std::unique_ptr< BundlePort >> &ports)
Definition: Design.cpp:42
Definition: esi.py:1
static std::map< AppID, Instance * > buildIndex(const std::vector< std::unique_ptr< Instance >> &insts)
Build an index of children by AppID.
Definition: Design.cpp:26