Skip to content

Commit

Permalink
Added frames for lut and state
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Mar 9, 2024
1 parent 8f689ba commit 5c6f103
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,10 @@ namespace hal
void update(GateType* gt) override;

private:

QFormLayout* mFormLayout;

GateLibraryLabel* mClockProperty;
GateLibraryLabel* mNextStateProperty;
GateLibraryLabel* mAsynchronousResetProperty;
GateLibraryLabel* mAsynchronousSetProperty;
GateLibraryLabel* mInternalStateProperty;
GateLibraryLabel* mNegatedInternalStateProperty;
GateLibraryLabel* mInternalStateOnReset;
GateLibraryLabel* mNegatedInternalStateOnReset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ namespace hal
void update(GateType* gt) override;

private:
QFormLayout* mFormLayout;
QString mCategory;
QStringList mIdentifiers;

QLabel* mCategoryLabel;
QLabel* mIdentifiersLabel;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// 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 "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_component_frame.h"

#include <QFormLayout>
#include <QLabel>

namespace hal
{
class GatelibraryFrameLut : public GatelibraryComponentFrame
{
Q_OBJECT

public:
GatelibraryFrameLut(QWidget* parent = nullptr);

void update(GateType* gt) override;

private:
QLabel* mAscending;
};

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// 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 "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_component_frame.h"

#include <QFormLayout>
#include <QLabel>

namespace hal
{
class GatelibraryFrameState : public GatelibraryComponentFrame
{
Q_OBJECT

public:
GatelibraryFrameState(QWidget* parent = nullptr);

void update(GateType* gt) override;

private:
QLabel* mStateIdentifier;
QLabel* mNegStateIdentifier;
};

}


Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace hal
class GateLibraryLabel;
class GatelibraryFrameFF;
class GatelibraryFrameInit;
class GatelibraryFrameState;
class GatelibraryFrameLut;

class GatelibraryFrameGeneral : public GatelibraryComponentFrame
{
Expand Down Expand Up @@ -76,9 +78,11 @@ namespace hal

private:
GatelibraryFrameGeneral* mGeneralFrame;
GatelibraryFrameFF* mFlipflopFrame;
GatelibraryFrameState* mStateFrame;
GatelibraryFrameLut* mLutFrame;
GatelibraryFrameInit* mInitFrame;
GatelibraryFrameBoolean* mBooleanFrame;
GatelibraryFrameFF* mFlipflopFrame;
GatelibraryFrameInit* mInitFrame;
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ namespace hal
mNextStateProperty = new GateLibraryLabel(true, " - ", this);
mAsynchronousResetProperty = new GateLibraryLabel(true, " - ", this);
mAsynchronousSetProperty = new GateLibraryLabel(true, " - ", this);
mInternalStateProperty = new GateLibraryLabel(true, " - ", this);
mNegatedInternalStateProperty = new GateLibraryLabel(true, " - ", this);
mInternalStateOnReset = new GateLibraryLabel(true, " - ", this);
mNegatedInternalStateOnReset = new GateLibraryLabel(true, " - ", this);

mLayout->addRow(new GateLibraryLabel(false, "Clock:", parent), mClockProperty);
mLayout->addRow(new GateLibraryLabel(false, "Next state:", parent), mNextStateProperty);
mLayout->addRow(new GateLibraryLabel(false, "Asynchronous reset:", parent), mAsynchronousResetProperty);
mLayout->addRow(new GateLibraryLabel(false, "Asynchronous set:", parent), mAsynchronousSetProperty);
mLayout->addRow(new GateLibraryLabel(false, "Internal state:", parent), mInternalStateProperty);
mLayout->addRow(new GateLibraryLabel(false, "Negated internal state:", parent), mNegatedInternalStateProperty);
mLayout->addRow(new GateLibraryLabel(false, "Set+Reset -> internal state:", parent), mInternalStateOnReset);
mLayout->addRow(new GateLibraryLabel(false, "Set+Reset -> neg. int. state:", parent), mNegatedInternalStateOnReset);
}
Expand Down Expand Up @@ -61,20 +57,6 @@ namespace hal
mAsynchronousSetProperty->setValue(true);
}

mInternalStateProperty->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())
{
mNegatedInternalStateProperty->setText(QString::fromStdString(result.get().to_string()));
mNegatedInternalStateProperty->setValue(true);
}
else
{
mNegatedInternalStateProperty->setText("ERROR");
mNegatedInternalStateProperty->setValue(false);
}

auto [stateBeh,negStateBeh] = ff->get_async_set_reset_behavior();
if (stateBeh == AsyncSetResetBehavior::undef)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_lut.h"
#include "gui/gatelibrary_management/gatelibrary_label.h"
#include "hal_core/netlist/gate_library/gate_type_component/lut_component.h"

namespace hal
{
GatelibraryFrameLut::GatelibraryFrameLut(QWidget* parent)
: GatelibraryComponentFrame("LUT Init", parent)
{
mAscending = new GateLibraryLabel(true, " - ", this);

mLayout->addRow(new GateLibraryLabel(false, "Bit Order:", parent), mAscending);
}

void GatelibraryFrameLut::update(GateType* gt)
{
if(gt->has_component_of_type(GateTypeComponent::ComponentType::init))
{
auto lutc = gt->get_component_as<LUTComponent>([](const GateTypeComponent* c) { return LUTComponent::is_class_of(c); });

if(lutc != nullptr)
{
mAscending->setText(QString::fromStdString(lutc->is_init_ascending() ? "Ascending" : "Descending"));
show();
}
else hide();
}
else hide();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_state.h"
#include "gui/gatelibrary_management/gatelibrary_label.h"
#include "hal_core/netlist/gate_library/gate_type_component/state_component.h"

namespace hal
{
GatelibraryFrameState::GatelibraryFrameState(QWidget* parent)
: GatelibraryComponentFrame("Internal States", parent)
{
mStateIdentifier = new GateLibraryLabel(true, " - ", this);
mNegStateIdentifier = new GateLibraryLabel(true, " - ", this);

mLayout->addRow(new GateLibraryLabel(false, "State identifier:", parent), mStateIdentifier);
mLayout->addRow(new GateLibraryLabel(false, "Neg. state identifier:", parent), mNegStateIdentifier);

}

void GatelibraryFrameState::update(GateType* gt)
{
if(gt->has_component_of_type(GateTypeComponent::ComponentType::state))
{
auto stat = gt->get_component_as<StateComponent>([](const GateTypeComponent* c) { return StateComponent::is_class_of(c); });

if(stat != nullptr)
{
mStateIdentifier->setText(QString::fromStdString(stat->get_state_identifier()));
mNegStateIdentifier->setText(QString::fromStdString(stat->get_neg_state_identifier()));
show();
}
else hide();
}
else hide();
}
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

#include "gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_general.h"
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_ff.h"

#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_state.h"
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_lut.h"
#include "gui/gatelibrary_management/gatelibrary_frames/gatelibrary_frame_init.h"

#include "gui/gatelibrary_management/gatelibrary_label.h"
Expand Down Expand Up @@ -101,6 +102,14 @@ namespace hal
layout->addWidget(mFlipflopFrame);
mFlipflopFrame->hide();

mStateFrame = new GatelibraryFrameState(this);
layout->addWidget(mStateFrame);
mStateFrame->hide();

mLutFrame = new GatelibraryFrameLut(this);
layout->addWidget(mLutFrame);
mLutFrame->hide();

mInitFrame = new GatelibraryFrameInit(this);
layout->addWidget(mInitFrame);
mInitFrame->hide();
Expand All @@ -118,13 +127,17 @@ namespace hal
if(!gt){
//TODO make default look
mFlipflopFrame->hide();
mBooleanFrame->hide();
mStateFrame->hide();
mLutFrame->hide();
mInitFrame->hide();
mBooleanFrame->hide();
return;
}

mFlipflopFrame->update(gt);
mBooleanFrame->update(gt);
mStateFrame->update(gt);
mLutFrame->update(gt);
mInitFrame->update(gt);
mBooleanFrame->update(gt);
}
}

0 comments on commit 5c6f103

Please sign in to comment.