scc  2024.06
SystemC components library
cci_broker.h
1 /*******************************************************************************
2  * Copyright 2022 MINRES Technologies GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************/
16 
17 #ifndef _SYSC_SCC_CCI_BROKER_H_
18 #define _SYSC_SCC_CCI_BROKER_H_
19 
20 #include <cci_configuration>
21 #if CCI_VERSION_MAJOR == 1 && CCI_VERSION_MINOR == 0 && CCI_VERSION_PATCH == 0
22 #include <cci_utils/consuming_broker.h>
23 #endif
24 #include <regex>
25 #include <string>
26 #include <unordered_map>
27 #include <unordered_set>
28 #include <vector>
29 
30 namespace scc {
31 class cci_broker : public cci_utils::consuming_broker {
32  std::unordered_set<std::string> expose;
33 
34  bool has_parent;
35  cci::cci_broker_if& m_parent;
36 
37  cci::cci_broker_if& get_parent_broker() {
38  if(sc_core::sc_get_current_object()) {
39  has_parent = true;
40  return unwrap_broker(cci::cci_get_broker());
41  } else {
42  // We ARE the global broker
43  has_parent = false;
44  return *this;
45  }
46  }
47 
48  bool sendToParent(const std::string& parname) const;
49 
50  void insert_matching_preset_value(const std::string& parname);
51 
52  struct wildcard_entry {
53  std::regex rr;
54  cci::cci_value value;
55  cci::cci_originator originator;
56  };
57  std::unordered_map<std::string, wildcard_entry> wildcard_presets;
58  std::unordered_map<std::string, std::regex> wildcard_locks;
59 
60 public:
61  cci::cci_originator get_value_origin(const std::string& parname) const override;
62 
63  cci_broker(const std::string& name);
64 
65  ~cci_broker();
66 
67  bool has_preset_value(const std::string& parname) const override;
68 
69  cci::cci_originator get_preset_value_origin(const std::string& parname) const override;
70 
71  cci::cci_value get_preset_cci_value(const std::string& parname) const override;
91  void set_preset_cci_value(const std::string& parname, const cci::cci_value& cci_value, const cci::cci_originator& originator) override;
92 
113  void lock_preset_value(const std::string& parname) override;
114 
115  cci::cci_value get_cci_value(const std::string& parname, const cci::cci_originator& originator = cci::cci_originator()) const override;
116 
117  cci::cci_param_untyped_handle get_param_handle(const std::string& parname, const cci::cci_originator& originator) const override;
118 
119  std::vector<cci::cci_param_untyped_handle> get_param_handles(const cci::cci_originator& originator) const override;
120 
121  void add_param(cci::cci_param_if* par) override;
122 
123  void remove_param(cci::cci_param_if* par) override;
124 
125  bool is_global_broker() const override;
126 };
127 
128 } // namespace scc
129 #endif // _SYSC_SCC_CCI_BROKER_H_
void lock_preset_value(const std::string &parname) override
Lock a parameter's preset value.
Definition: cci_broker.cpp:167
void set_preset_cci_value(const std::string &parname, const cci::cci_value &cci_value, const cci::cci_originator &originator) override
Set a parameter's preset value.
Definition: cci_broker.cpp:148
SCC TLM utilities.