HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
ff_component.cpp
Go to the documentation of this file.
2 
3 #include <memory>
4 
5 namespace hal
6 {
7  FFComponent::FFComponent(std::unique_ptr<GateTypeComponent> component, const BooleanFunction& next_state_bf, const BooleanFunction& clock_bf)
8  : m_component(std::move(component)), m_next_state_bf(next_state_bf.clone()), m_clock_bf(clock_bf.clone())
9  {
10  }
11 
12  std::unique_ptr<FFComponent> FFComponent::create(std::unique_ptr<GateTypeComponent> component, const BooleanFunction& next_state_bf, const BooleanFunction& clock_bf)
13  {
14  return std::unique_ptr<FFComponent>(new FFComponent(std::move(component), next_state_bf.clone(), clock_bf.clone()));
15  }
16 
17  FFComponent::ComponentType FFComponent::get_type() const
18  {
19  return m_type;
20  }
21 
22  bool FFComponent::is_class_of(const GateTypeComponent* component)
23  {
24  return component->get_type() == m_type;
25  }
26 
27  std::vector<GateTypeComponent*> FFComponent::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  BooleanFunction FFComponent::get_next_state_function() const
51  {
52  return m_next_state_bf.clone();
53  }
54 
55  void FFComponent::set_next_state_function(const BooleanFunction& next_state_bf)
56  {
57  m_next_state_bf = next_state_bf.clone();
58  }
59 
60  BooleanFunction FFComponent::get_clock_function() const
61  {
62  return m_clock_bf.clone();
63  }
64 
65  void FFComponent::set_clock_function(const BooleanFunction& clock_bf)
66  {
67  m_clock_bf = clock_bf.clone();
68  }
69 
70  BooleanFunction FFComponent::get_async_reset_function() const
71  {
72  return m_async_reset_bf.clone();
73  }
74 
75  void FFComponent::set_async_reset_function(const BooleanFunction& async_reset_bf)
76  {
77  m_async_reset_bf = async_reset_bf.clone();
78  }
79 
80  BooleanFunction FFComponent::get_async_set_function() const
81  {
82  return m_async_set_bf.clone();
83  }
84 
85  void FFComponent::set_async_set_function(const BooleanFunction& async_set_bf)
86  {
87  m_async_set_bf = async_set_bf.clone();
88  }
89 
90  const std::pair<AsyncSetResetBehavior, AsyncSetResetBehavior>& FFComponent::get_async_set_reset_behavior() const
91  {
92  return m_async_set_reset_behavior;
93  }
94 
95  void FFComponent::set_async_set_reset_behavior(AsyncSetResetBehavior behav_state, AsyncSetResetBehavior behav_neg_state)
96  {
97  m_async_set_reset_behavior = std::make_pair(behav_state, behav_neg_state);
98  }
99 
100 } // namespace hal
BooleanFunction clone() const
virtual ComponentType get_type() const =0
Definition: defines.h:45