HAL
gatelibrary_frame_ram_port.cpp
Go to the documentation of this file.
4 
5 #include <QDebug>
6 
7 namespace hal
8 {
10  : GatelibraryComponentFrame("RAM Ports", parent)
11  {
13  }
14 
16  {
17  QLayoutItem* item;
18  while (!mLayout->isEmpty())
19  {
20  if ((item = mLayout->takeAt(0)) != nullptr) {
21  delete item->widget();
22  delete item;
23  }
24  }
25 
26  mLayout->insertRow(0, new GateLibraryLabel(false, "RAM Ports", this));
27 
28 
30  {
31  auto ram_ports = gt->get_components([](const GateTypeComponent* c) {return RAMPortComponent::is_class_of(c);});
32  int cnt = 1;
33 
34  if(!ram_ports.empty())
35  {
36  for (auto comp : ram_ports) {
37  mLayout->addRow(new GateLibraryLabel(false, QString("RAM Port %1").arg(cnt), this));
38  auto ram_port = comp->convert_to<RAMPortComponent>();
39 
40  GateLibraryLabel* dataGroup = new GateLibraryLabel(true,QString::fromStdString(ram_port->get_data_group()), this);
41  GateLibraryLabel* addressGroup = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_address_group()), this);
42  GateLibraryLabel* clkFunc = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_clock_function().to_string()), this);
43  GateLibraryLabel* enableFunc = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_enable_function().to_string()), this);
44  GateLibraryLabel* writePort = new GateLibraryLabel(true, ram_port->is_write_port() ? "True" : "False", this);
45 
46  mLayout->addRow(new GateLibraryLabel(false, "Name of the data pingroup:", this), dataGroup);
47  mLayout->addRow(new GateLibraryLabel(false, "Name of the address pingroup:", this), addressGroup);
48  mLayout->addRow(new GateLibraryLabel(false, "Clock boolean function:", this), clkFunc);
49  mLayout->addRow(new GateLibraryLabel(false, "Enable boolean function:", this), enableFunc);
50  mLayout->addRow(new GateLibraryLabel(false, "Is a write port:", this), writePort);
51 
52  cnt++;
53  }
54 
55  show();
56  }
57  else
58  hide();
59  }
60  else
61  hide();
62  }
63 }
64 
GateLibraryFrameRAMPort(QWidget *parent=nullptr)
std::vector< GateTypeComponent * > get_components(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
Definition: gate_type.cpp:19
bool has_component_of_type(const GateTypeComponent::ComponentType type) const
Definition: gate_type.cpp:54
static bool is_class_of(const GateTypeComponent *component)
void addRow(QWidget *label, QWidget *field)
void setFieldGrowthPolicy(QFormLayout::FieldGrowthPolicy policy)
void insertRow(int row, QWidget *label, QWidget *field)
virtual QLayoutItem * takeAt(int index) override
virtual bool isEmpty() const const override
virtual QWidget * widget()
QString fromStdString(const std::string &str)
void hide()
void show()
void update()