19 #include <QApplication>
36 mGateInformationFrame =
new DetailsFrameWidget(mGateInfoTable,
"Gate Information",
this);
37 addTab(
"General", mGateInformationFrame,
true);
43 addTab(
"Groupings", mGroupingsFrame,
false);
50 addTab(
"Pins", mPinsFrame,
false);
60 mLutConfigLabel =
new QLabel(
"default",
this);
69 mLutConfigurationFrame =
new DetailsFrameWidget(mLutConfigLabel,
"Configuration String",
this);
73 mMultiTabIndex =
addTab(
"(FF / Latch / LUT)", framesFfLatchLutTab);
74 mMultiTabContent =
widget(mMultiTabIndex);
80 mBooleanFunctionsFrame =
new DetailsFrameWidget(mFullFunctionTable,
"Boolean Functions",
this);
82 addTab(
"Boolean Functions", mBooleanFunctionsFrame,
false);
89 addTab(
"Data", mDataFrame,
false);
103 mGroupingsOfItemTable->
setGate(gate);
109 GateDetailsTabWidget::GateTypeCategory gateTypeCategory = getGateTypeCategory(gate);
110 hideOrShorMultiTab(gateTypeCategory);
111 setupBooleanFunctionTables(gate, gateTypeCategory);
114 void GateDetailsTabWidget::handleGateBooleanFunctionChanged(
Gate*
g)
116 if (
g == mCurrentGate &&
g !=
nullptr)
120 GateDetailsTabWidget::GateTypeCategory gateTypeCategory = getGateTypeCategory(
g);
121 setupBooleanFunctionTables(
g, gateTypeCategory);
125 void GateDetailsTabWidget::hideOrShorMultiTab(GateDetailsTabWidget::GateTypeCategory gateTypeCategory)
127 if (gateTypeCategory != GateDetailsTabWidget::GateTypeCategory::none)
129 showMultiTab(gateTypeCategory);
137 void GateDetailsTabWidget::hideMultiTab()
139 if (mMultiTabVisible)
142 mMultiTabVisible =
false;
146 void GateDetailsTabWidget::showMultiTab(GateDetailsTabWidget::GateTypeCategory gateTypeCategory)
150 switch (gateTypeCategory)
152 case GateDetailsTabWidget::GateTypeCategory::lut: {
161 case GateDetailsTabWidget::GateTypeCategory::ff: {
170 case GateDetailsTabWidget::GateTypeCategory::latch: {
183 if (!mMultiTabVisible)
185 insertTab(mMultiTabIndex, mMultiTabContent, label);
186 mMultiTabVisible =
true;
194 GateDetailsTabWidget::GateTypeCategory GateDetailsTabWidget::getGateTypeCategory(Gate* gate)
const
198 return GateDetailsTabWidget::GateTypeCategory::none;
201 GateType*
type = gate->get_type();
203 std::set<hal::GateTypeProperty> gateTypeProperties =
type->get_properties();
206 auto relevantFind = find_first_of(begin(gateTypeProperties), end(gateTypeProperties), begin(relevantProperties), end(relevantProperties));
208 if (relevantFind == end(gateTypeProperties))
210 return GateDetailsTabWidget::GateTypeCategory::none;
213 switch (*relevantFind)
216 return GateDetailsTabWidget::GateTypeCategory::lut;
220 return GateDetailsTabWidget::GateTypeCategory::ff;
224 return GateDetailsTabWidget::GateTypeCategory::latch;
228 return GateDetailsTabWidget::GateTypeCategory::none;
234 void GateDetailsTabWidget::handleLutConfigContextMenuRequested(
QPoint pos)
239 menu.
addAction(
"Change configuration string", [
this]() {
240 InputDialog ipd(
"Change configuration string",
"New configuration string", mLutConfigLabel->
text().remove(
"0x"));
241 HexadecimalValidator hexValidator;
242 ipd.addValidator(&hexValidator);
245 if (InitComponent* init_component = mCurrentGate->
get_type()->
get_component_as<InitComponent>([](
const GateTypeComponent* c) { return InitComponent::is_class_of(c); });
246 init_component !=
nullptr)
248 std::string cat = init_component->get_init_category(), key = init_component->get_init_identifiers()[0];
249 QString data_type =
"bit_vector";
256 log_error(
"gui",
"Could not load InitComponent from gate with id {}.", mCurrentGate->
get_id());
259 menu.
addAction(
QIcon(
":/icons/python"),
"Get configuration string", [
this]() {
261 init_component !=
nullptr)
263 std::string cat = init_component->get_init_category(), key = init_component->get_init_identifiers()[0];
267 log_error(
"gui",
"Could not load InitComponent from gate with id {}.", mCurrentGate->
get_id());
273 void GateDetailsTabWidget::setupBooleanFunctionTables(Gate* gate, GateDetailsTabWidget::GateTypeCategory gateTypeCategory)
287 "power_down_function"
300 if (gateTypeCategory == GateDetailsTabWidget::GateTypeCategory::ff)
302 specialBfNames = &ffBfNames;
304 else if (gateTypeCategory == GateDetailsTabWidget::GateTypeCategory::latch)
306 specialBfNames = &latchBfNames;
309 std::unordered_map<std::string, BooleanFunction> allBfs = gate->get_boolean_functions(
false);
314 for (
auto& it : allBfs)
317 if (specialBfNames->
contains(bfName))
320 specialFunctions.
insert(bfName, it.second);
325 otherFunctions.
insert(bfName, it.second);
335 for (i = specialFunctions.
begin(); i != specialFunctions.
end(); i++)
338 for (i = otherFunctions.
begin(); i != otherFunctions.
end(); i++)
341 GateType* gt = gate->get_type();
342 if (FFComponent* ff_component = gt->get_component_as<FFComponent>([](
const GateTypeComponent* c) { return FFComponent::is_class_of(c); }); ff_component !=
nullptr)
346 if (!ff_component->get_clock_function().is_empty())
348 if (!ff_component->get_next_state_function().is_empty())
351 if (!ff_component->get_async_set_function().is_empty())
354 if (!ff_component->get_async_reset_function().is_empty())
358 else if (LatchComponent* latch_component = gt->get_component_as<LatchComponent>([](
const GateTypeComponent* c) { return LatchComponent::is_class_of(c); }); latch_component !=
nullptr)
362 if (!latch_component->get_enable_function().is_empty())
365 if (!latch_component->get_data_in_function().is_empty())
368 if (!latch_component->get_async_set_function().is_empty())
371 if (!latch_component->get_async_reset_function().is_empty())
376 if (StateComponent* state_component = gt->get_component_as<StateComponent>([](
const GateTypeComponent* c) { return StateComponent::is_class_of(c); }); state_component !=
nullptr)
378 if (state_component->get_state_identifier() !=
"")
380 new StateComponentEntry(gate->get_id(), StateComponentEntry::StateCompType::PosState,
QString::fromStdString(state_component->get_state_identifier()))));
381 if (state_component->get_neg_state_identifier() !=
"")
383 new StateComponentEntry(gate->get_id(), StateComponentEntry::StateCompType::NegState,
QString::fromStdString(state_component->get_neg_state_identifier()))));
387 switch (gateTypeCategory)
389 case GateDetailsTabWidget::GateTypeCategory::lut: {
390 const std::vector<std::string> lutPins = gate->get_type()->get_pin_names([](
const GatePin* p) {
return p->get_type() ==
PinType::lut; });
393 for (
auto bfEntry : otherFunctionList)
395 if (std::find(lutPins.begin(), lutPins.end(), bfEntry->getEntryIdentifier().toStdString()) != lutPins.end())
397 lutEntries.
append(bfEntry);
405 if (InitComponent* init_component = gt->get_component_as<InitComponent>([](
const GateTypeComponent* c) { return InitComponent::is_class_of(c); }); init_component !=
nullptr)
407 auto typeAndValue = gate->get_data(init_component->get_init_category(), init_component->get_init_identifiers()[0]);
412 mLutConfigLabel->
setText(
" Could not load init string.");
416 if (lutPins.size() > 0)
419 std::basic_string<char> outPin = lutPins.front();
422 BooleanFunction lutFunction = gate->get_boolean_function(outPin);
427 case GateDetailsTabWidget::GateTypeCategory::ff: {
428 mFfFunctionTable->
setEntries(specialFunctionList + setPresetBehavior);
431 case GateDetailsTabWidget::GateTypeCategory::latch: {
432 mLatchFunctionTable->
setEntries(specialFunctionList + setPresetBehavior);
438 mFullFunctionTable->
setEntries(specialFunctionList + otherFunctionList);
A table view that shows BooleanFunctions and clear-preset behaviors.
void setContextMenuPlainDescr(bool enable)
void setEntries(QVector< QSharedPointer< BooleanFunctionTableEntry >> entries)
void enableChangeBooleanFunctionOption(bool enable)
void setContextMenuPythonPlainDescr(bool enable)
void setGateInformation(Gate *g)
GateType * get_type() const
A widget to display the pins of a given gate.
void updateText(const QString &newHeadline)
T * get_component_as(const std::function< bool(const GateTypeComponent *)> &filter=nullptr) const
static bool is_class_of(const GateTypeComponent *component)
void gateBooleanFunctionChanged(Gate *g) const
The Node class object represents a module or a gate.
static QString pyCodeGateData(u32 gateId, QString category, QString key)
static PythonQssAdapter * instance()
#define log_error(channel,...)
NetlistRelay * gNetlistRelay
void setText(const QString &text, QClipboard::Mode mode)
void setWordWrap(bool on)
const Key & key() const const
QMap::iterator insert(const Key &key, const T &value)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool contains(const T &value) const const
QString fromStdString(const std::string &str)
QString toUpper() const const
void setTabText(int index, const QString &label)
void append(const T &value)