HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
ram_component.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 
5 namespace hal
6 {
7  RAMComponent::RAMComponent(std::unique_ptr<GateTypeComponent> component, const u32 bit_size, std::vector<std::string> init_identifiers)
8  : m_component(std::move(component)), m_bit_size(bit_size), m_init_identifiers(std::move(init_identifiers))
9  {
10  }
11 
12  std::unique_ptr<RAMComponent> RAMComponent::create(std::unique_ptr<GateTypeComponent> component, const u32 bit_size, const std::vector<std::string>& init_identifiers)
13  {
14  return std::unique_ptr<RAMComponent>(new RAMComponent(std::move(component), bit_size, init_identifiers));
15  }
16 
17  RAMComponent::ComponentType RAMComponent::get_type() const
18  {
19  return m_type;
20  }
21 
22  bool RAMComponent::is_class_of(const GateTypeComponent* component)
23  {
24  return component->get_type() == m_type;
25  }
26 
27  std::vector<GateTypeComponent*> RAMComponent::get_components(const std::function<bool(const GateTypeComponent*)>& filter) const
28  {
29  if (m_component != nullptr)
30  {
31  std::vector<GateTypeComponent*> res = m_component->get_components(filter);
32  if (filter)
33  {
34  if (filter(m_component.get()))
35  {
36  res.push_back(m_component.get());
37  }
38  }
39  else
40  {
41  res.push_back(m_component.get());
42  }
43 
44  return res;
45  }
46 
47  return {};
48  }
49 
50  u32 RAMComponent::get_bit_size() const
51  {
52  return m_bit_size;
53  }
54 
55  void RAMComponent::set_bit_size(const u32 bit_size)
56  {
57  m_bit_size = bit_size;
58  }
59 
60  const std::vector<std::string>& RAMComponent::get_init_identifiers() const
61  {
62  return m_init_identifiers;
63  }
64 
65  void RAMComponent::set_init_identifiers(const std::vector<std::string>& init_identifiers)
66  {
67  m_init_identifiers = init_identifiers;
68  }
69 } // namespace hal
virtual ComponentType get_type() const =0
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45