HAL
gatelibrary_frame_ff.cpp
Go to the documentation of this file.
3 #include "gui/gui_globals.h"
5 
6 namespace hal
7 {
8 
10  : GatelibraryComponentFrame("Flip Flop", parent)
11  {
12  mClockProperty = new GateLibraryLabel(true, " - ", this);
13  mNextStateProperty = new GateLibraryLabel(true, " - ", this);
14  mAsynchronousResetProperty = new GateLibraryLabel(true, " - ", this);
15  mAsynchronousSetProperty = new GateLibraryLabel(true, " - ", this);
16  mInternalStateOnReset = new GateLibraryLabel(true, " - ", this);
17  mNegatedInternalStateOnReset = new GateLibraryLabel(true, " - ", this);
18 
19  mLayout->addRow(new GateLibraryLabel(false, "Clock:", parent), mClockProperty);
20  mLayout->addRow(new GateLibraryLabel(false, "Next state:", parent), mNextStateProperty);
21  mLayout->addRow(new GateLibraryLabel(false, "Asynchronous reset:", parent), mAsynchronousResetProperty);
22  mLayout->addRow(new GateLibraryLabel(false, "Asynchronous set:", parent), mAsynchronousSetProperty);
23  mLayout->addRow(new GateLibraryLabel(false, "Set+Reset -> internal state:", parent), mInternalStateOnReset);
24  mLayout->addRow(new GateLibraryLabel(false, "Set+Reset -> neg. int. state:", parent), mNegatedInternalStateOnReset);
25 
27  }
28 
30  {
32  {
33  auto ff = gt->get_component_as<FFComponent>([](const GateTypeComponent* c) { return FFComponent::is_class_of(c); });
34 
35  if (ff != nullptr)
36  {
37  mClockProperty->setText(QString::fromStdString(ff->get_clock_function().to_string()));
38  mNextStateProperty->setText(QString::fromStdString(ff->get_next_state_function().to_string()));
39 
40  if (ff->get_async_reset_function().is_empty())
41  {
42  mAsynchronousResetProperty->setText("N/A");
43  mAsynchronousResetProperty->setValue(false);
44  }
45  else
46  {
47  mAsynchronousResetProperty->setText(QString::fromStdString(ff->get_async_reset_function().to_string()));
48  mAsynchronousResetProperty->setValue(true);
49  }
50 
51  if (ff->get_async_set_function().is_empty())
52  {
53  mAsynchronousSetProperty->setText("N/A");
54  mAsynchronousSetProperty->setValue(false);
55  }
56  else
57  {
58  mAsynchronousSetProperty->setText(QString::fromStdString(ff->get_async_set_function().to_string()));
59  mAsynchronousSetProperty->setValue(true);
60  }
61 
62  auto [stateBeh,negStateBeh] = ff->get_async_set_reset_behavior();
63  if (stateBeh == AsyncSetResetBehavior::undef)
64  {
65  mInternalStateOnReset->setText("undefined");
66  mInternalStateOnReset->setValue(false);
67  }
68  else
69  {
70  mInternalStateOnReset->setText(QString::fromStdString(enum_to_string<AsyncSetResetBehavior>(stateBeh)));
71  mInternalStateOnReset->setValue(true);
72  }
73 
74  if (negStateBeh == AsyncSetResetBehavior::undef)
75  {
76  mNegatedInternalStateOnReset->setText("undefined");
77  mNegatedInternalStateOnReset->setValue(false);
78  }
79  else
80  {
81  mNegatedInternalStateOnReset->setText(QString::fromStdString(enum_to_string<AsyncSetResetBehavior>(negStateBeh)));
82  mNegatedInternalStateOnReset->setValue(true);
83  }
84 
85  show();
86  }
87  else
88  hide();
89  }
90  else
91  hide();
92  }
93 }
static bool is_class_of(const GateTypeComponent *component)
void setValue(bool isVal)
bool has_component_of_type(const GateTypeComponent::ComponentType type) const
Definition: gate_type.cpp:54
T * get_component_as(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
Definition: gate_type.h:89
GatelibraryFrameFF(QWidget *parent=nullptr)
void addRow(QWidget *label, QWidget *field)
void setFieldGrowthPolicy(QFormLayout::FieldGrowthPolicy policy)
void setText(const QString &)
QObject * parent() const const
QString fromStdString(const std::string &str)
void hide()
void show()
void update()