HAL
boolean_function_table_model.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <QAbstractTableModel>
29 #include <QVector>
30 #include <QString>
31 #include <QSharedPointer>
32 #include "hal_core/netlist/gate.h"
35 
36 #include "hal_core/defines.h"
37 #include "hal_core/utilities/log.h"
38 
39 
40 namespace hal {
51  {
52  public:
53 
62 
69 
76 
82  u32 getGateId() const;
83 
89  EntryType getEntryType() const;
90 
98  virtual QString getPythonCode(){return "";};
99 
100  protected:
105  };
106 
113  {
114  public:
123  BooleanFunctionEntry(u32 gateId, QString functionName, BooleanFunction bf);
124 
132  BooleanFunctionEntry(QString functionName, BooleanFunction bf);
133 
140 
141  QString getPythonCode() override;
142 
143  private:
144  BooleanFunction mBF;
145  };
146 
153  {
154  public:
155  //perhabs exclude SetResetBehav and make it a private boolean?
157 
167 
174  FFComponentEntry(u32 gateId, std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> behav);
175 
176  QString getPythonCode() override;
177 
178  private:
179  QString enumToString();
180  QString behaviorToString(std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> behav);
181  FFCompFunc mSpecificType;
182  };
183 
190  {
191  public:
193 
203 
210  LatchComponentEntry(u32 gateId, std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> behav);
211 
212  QString getPythonCode() override;
213 
214  private:
215  QString enumToString();
216  QString behaviorToString(std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> behav);
217  LatchCompFunc mSpecificType;
218  };
219 
226  {
227 
228  public:
235  //CPBehaviorEntry(u32 gateId, std::pair<GateType::ClearPresetBehavior, GateType::ClearPresetBehavior> cPBehavior);
236  CPBehaviorEntry(u32 gateId, std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> cPBehavior);
237 
243  //std::pair<GateType::ClearPresetBehavior, GateType::ClearPresetBehavior> getCPBehavior() const;
244  std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> getCPBehavior() const;
245 
246  private:
247  //QString cPBehaviourToString (std::pair<GateType::ClearPresetBehavior, GateType::ClearPresetBehavior> cPBehaviour);
248  //std::pair<GateType::ClearPresetBehavior, GateType::ClearPresetBehavior> mCPBehavior;
249 
250  QString cPBehaviourToString (std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> cPBehaviour);
251  std::pair<hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior> mCPBehavior;
252  };
253 
260  {
261  public:
262  //perhaps own enum declaring if this entry stores the pos/neg state?
271  StateComponentEntry(u32 gateId, StateCompType type, QString stateVal);
272 
273  QString getPythonCode() override;
274  StateCompType getStateCompType(){return specificType;};
275 
276  private:
277 
278  QString enumTypeToString();
279  StateCompType specificType;
280  };
281 
294  {
295  Q_OBJECT
296 
297  public:
304 
311  int columnCount(const QModelIndex &parent=QModelIndex()) const override;
312 
319  int rowCount(const QModelIndex &parent=QModelIndex()) const override;
320 
330  QVariant data(const QModelIndex &index, int role) const override;
331 
340  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
341 
350  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
351 
358 
366 
367 
368  private:
370 
372  QString mSeparator = "=";
373  };
374 }
A BooleanFunctionTableEntry that represents a boolean function.
QString getPythonCode() override
BooleanFunction getBooleanFunction() const
BooleanFunctionEntry(u32 gateId, QString functionName, BooleanFunction bf)
An entry in the boolean function table model.
u32 mGateId
u32 getGateId() const
EntryType
@ CPBehavior
@ LatchComp
@ BooleanFunctionStandard
@ StateComp
@ FFComp
EntryType mType
QString mRight
EntryType getEntryType() const
QString getEntryValueString() const
BooleanFunctionTableEntry(u32 gateId)
virtual QString getPythonCode()
QString mLeft
QString getEntryIdentifier() const
A model that holds BooleanFunctions and clear-preset behaviors.
QSharedPointer< BooleanFunctionTableEntry > getEntryAtRow(int row) const
BooleanFunctionTableModel(QObject *parent=nullptr)
void setEntries(QVector< QSharedPointer< BooleanFunctionTableEntry >> entries)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QVariant data(const QModelIndex &index, int role) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
A BooleanFunctionTableEntry that represents a clear-preset behavior.
std::pair< hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior > getCPBehavior() const
CPBehaviorEntry(u32 gateId, std::pair< hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior > cPBehavior)
A entry type that represents properties (functions and behaviors) of an FFCompont.
QString getPythonCode() override
FFComponentEntry(u32 gateId, FFCompFunc type, BooleanFunction func)
FFCompFunc
@ AsyncSet
@ SetResetBehav
@ AsyncReset
@ Clock
@ NextState
FFComponentEntry(u32 gateId, std::pair< hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior > behav)
An entry type that represents properties (functions or behaviors) of a LatchComponent.
LatchComponentEntry(u32 gateId, std::pair< hal::AsyncSetResetBehavior, hal::AsyncSetResetBehavior > behav)
QString getPythonCode() override
LatchComponentEntry(u32 gateId, LatchCompFunc type, BooleanFunction func)
LatchCompFunc
@ AsyncSet
@ AsyncReset
@ Enable
@ DataInFunc
@ SetResetBehav
Utility class that represents a state of the StateComponent.
StateCompType getStateCompType()
StateComponentEntry(u32 gateId, StateCompType type, QString stateVal)
StateCompType
@ NegState
@ PosState
QString getPythonCode() override
quint32 u32
PinType type
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
QObject * parent() const const
Orientation