-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base class for component frames added
- Loading branch information
Showing
16 changed files
with
332 additions
and
251 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...s/gui/include/gui/gatelibrary_management/gatelibrary_frames/gatelibrary_component_frame.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved. | ||
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved. | ||
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved. | ||
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#pragma once | ||
|
||
#include "hal_core/defines.h" | ||
#include "hal_core/netlist/gate_library/gate_type.h" | ||
|
||
#include <QFormLayout> | ||
#include <QLabel> | ||
#include <QFrame> | ||
|
||
namespace hal | ||
{ | ||
class GatelibraryComponentFrame : public QFrame | ||
{ | ||
Q_OBJECT | ||
|
||
protected: | ||
QString mTitle; | ||
QFormLayout* mLayout; | ||
|
||
public: | ||
GatelibraryComponentFrame(const QString& title, QWidget* parent = nullptr); | ||
|
||
virtual ~GatelibraryComponentFrame() {;} | ||
|
||
virtual void update(GateType* gt) = 0; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugins/gui/include/gui/gatelibrary_management/gatelibrary_label.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved. | ||
// Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved. | ||
// Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved. | ||
// Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#pragma once | ||
|
||
#include <QLabel> | ||
#include <QObject> | ||
|
||
namespace hal | ||
{ | ||
class GateLibraryLabel : public QLabel | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PROPERTY(bool isValue READ isValue WRITE setValue) // label or value | ||
bool mValue; | ||
public: | ||
GateLibraryLabel(bool isVal, const QString& txt= QString(), QWidget* parent = nullptr); | ||
bool isValue() const { return mValue; } | ||
void setValue(bool isVal) { mValue = isVal; } | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
plugins/gui/src/gatelibrary_management/gatelibrary_frames/gatelibrary_component_frame.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_component_frame.h" | ||
#include "gui/gatelibrary_management/gatelibrary_label.h" | ||
|
||
namespace hal { | ||
GatelibraryComponentFrame::GatelibraryComponentFrame(const QString& title, QWidget* parent) | ||
: QFrame(parent), mTitle(title) | ||
{ | ||
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | ||
setFrameStyle(QFrame::Sunken | QFrame::Panel); | ||
setLineWidth(2); | ||
mLayout = new QFormLayout(this); | ||
mLayout->addRow(new GateLibraryLabel(false, mTitle, this)); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
plugins/gui/src/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_ff.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_ff.h" | ||
#include "gui/gatelibrary_management/gatelibrary_label.h" | ||
#include "gui/gui_globals.h" | ||
#include "hal_core/netlist/gate_library/gate_type_component/ff_component.h" | ||
|
||
namespace hal | ||
{ | ||
|
||
GatelibraryFrameFF::GatelibraryFrameFF(QWidget* parent) | ||
: GatelibraryComponentFrame("Flip Flop", parent) | ||
{ | ||
mClockPropertyLabel = new GateLibraryLabel(true, " - ", this); | ||
mNextStatePropertyLabel = new GateLibraryLabel(true, " - ", this); | ||
mAsynchronousResetPropertyLabel = new GateLibraryLabel(true, " - ", this); | ||
mInternalStatePropertyLabel = new GateLibraryLabel(true, " - ", this); | ||
mNegatedInternalStatePropertyLabel = new GateLibraryLabel(true, " - ", this); | ||
|
||
mLayout->addRow(new GateLibraryLabel(false, "Clock:", parent), mClockPropertyLabel); | ||
mLayout->addRow(new GateLibraryLabel(false, "Next state:", parent), mNextStatePropertyLabel); | ||
mLayout->addRow(new GateLibraryLabel(false, "Asynchronous reset:", parent), mAsynchronousResetPropertyLabel); | ||
mLayout->addRow(new GateLibraryLabel(false, "Internal state:", parent), mInternalStatePropertyLabel); | ||
mLayout->addRow(new GateLibraryLabel(false, "Negated internal state:", parent), mNegatedInternalStatePropertyLabel); | ||
} | ||
|
||
void GatelibraryFrameFF::update(GateType* gt) | ||
{ | ||
if (gt->has_component_of_type(GateTypeComponent::ComponentType::ff)) | ||
{ | ||
auto ff = gt->get_component_as<FFComponent>([](const GateTypeComponent* c) { return FFComponent::is_class_of(c); }); | ||
|
||
if (ff != nullptr) | ||
{ | ||
mClockPropertyLabel->setText(QString::fromStdString(ff->get_clock_function().to_string())); | ||
mNextStatePropertyLabel->setText(QString::fromStdString(ff->get_next_state_function().to_string())); | ||
mAsynchronousResetPropertyLabel->setText(QString::fromStdString(ff->get_async_reset_function().to_string())); | ||
|
||
mInternalStatePropertyLabel->setText(QString::fromStdString(gt->get_boolean_function().to_string())); | ||
|
||
Result<BooleanFunction> result = BooleanFunction::Not(gt->get_boolean_function(), gt->get_boolean_function().size()); | ||
if(result.is_ok()) | ||
mNegatedInternalStatePropertyLabel->setText(QString::fromStdString(result.get().to_string())); | ||
else{ | ||
mNegatedInternalStatePropertyLabel->setText("ERROR"); | ||
} | ||
show(); | ||
} | ||
else | ||
hide(); | ||
} | ||
else | ||
hide(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "gui/gatelibrary_management/gatelibrary_label.h" | ||
|
||
namespace hal { | ||
GateLibraryLabel::GateLibraryLabel(bool isVal, const QString& txt, QWidget *parent) | ||
: QLabel(txt,parent) | ||
{ | ||
mValue = isVal; | ||
} | ||
} |
Oops, something went wrong.