HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
gatelibrary_frame_lut.cpp
Go to the documentation of this file.
4 
5 #include <algorithm>
6 #include <vector>
7 
8 namespace hal
9 {
11  : GatelibraryComponentFrame("LUT Init", parent)
12  {
14  }
15 
17  {
19  {
20  hide();
21  return;
22  }
23 
24  auto lutc = gt->get_component_as<LUTComponent>([](const GateTypeComponent* c) { return LUTComponent::is_class_of(c); });
25  if (lutc == nullptr)
26  {
27  hide();
28  return;
29  }
30 
31  // Remove any previously added output-pin rows.
32  // Row 0 = title span (base class) — start removal at row 1.
33  while (mLayout->rowCount() > 1)
34  mLayout->removeRow(1);
35 
36  // Add one row per output pin config, sorted by pin name for deterministic order
37  const auto& raw = lutc->get_output_pin_configs();
38  std::vector<std::pair<std::string, LUTComponent::LUTOutputConfig>> configs(raw.begin(), raw.end());
39  std::sort(configs.begin(), configs.end(), [](const auto& a, const auto& b) { return a.first < b.first; });
40 
41  for (const auto& [pin_name, cfg] : configs)
42  {
43  QString value = QString::fromStdString(cfg.init_identifier);
44  if (cfg.bit_count > 0)
45  value += QString(" [%1..%2] %3").arg(cfg.bit_offset).arg(cfg.bit_offset + cfg.bit_count - 1).arg(cfg.is_ascending ? "asc" : "desc");
46  mLayout->addRow(new GateLibraryLabel(false, QString::fromStdString(pin_name) + ":", this),
47  new GateLibraryLabel(true, value, this));
48  }
49 
50  show();
51  }
52 }
53 
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
GatelibraryFrameLut(QWidget *parent=nullptr)
static bool is_class_of(const GateTypeComponent *component)
Definition: defines.h:45
void addRow(QWidget *label, QWidget *field)
void setFieldGrowthPolicy(QFormLayout::FieldGrowthPolicy policy)
void removeRow(int row)
int rowCount() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromStdString(const std::string &str)
void hide()
void show()
void update()