15 emptyEntry.output =
"No LUT gate selected yet...";
16 mLutEntries.
append(emptyEntry);
23 return (mInputPins.
size() + 1);
29 return mLutEntries.
size();
42 return mLutEntries[
index.
row()].output;
60 if (section < mInputPins.
size())
61 return mInputPins[section];
81 mOutputPin = outputPinName;
86 std::sort(bfVariables.begin(), bfVariables.end(), std::greater<>());
87 for (std::string v : bfVariables)
91 std::reverse(bfVariables.begin(), bfVariables.end());
94 if (ttVariant.is_ok())
97 std::vector<BooleanFunction::Value> truthTable = ttVariant.get().at(0);
99 for (
u32 truthTableIdx = 0; truthTableIdx < truthTable.size(); truthTableIdx++)
103 for (
int i = 0; i < mInputPins.
size(); i++)
105 u32 shift = mInputPins.
size() - i - 1;
106 u8 inputBit =
u8((truthTableIdx >> shift) & 1);
107 entry.inputBits.append(inputBit);
111 if (val == BooleanFunction::Value::ZERO)
113 else if (val == BooleanFunction::Value::ONE)
115 else if (val == BooleanFunction::Value::Z)
119 mLutEntries.
append(entry);
std::set< std::string > get_variable_names() const
Result< std::vector< std::vector< Value > > > compute_truth_table(const std::vector< std::string > &ordered_variables={}, bool remove_unknown_variables=false) const
Value
represents the type of the node
bool setData(const QModelIndex &index, const QVariant &value, int role) override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
QVariant data(const QModelIndex &index, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setBooleanFunction(const BooleanFunction lutFunction, const QString outputPinName)
LUTTableModel(QObject *parent=nullptr)
CORE_API std::vector< T > to_vector(const Container< T, Args... > &container)
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
void layoutChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QObject * parent() const const
QString fromStdString(const std::string &str)
void append(const T &value)