Skip to content

Commit

Permalink
Added wizard pages for State component and RAM Port
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed May 2, 2024
1 parent 7c40d55 commit 2350eb7
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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_pages/generalinfo_wizardpage.h"


#include <QWizardPage>
#include <QGridLayout>
#include <QTabWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QLabel>

namespace hal {
class RAMPortWizardPage:public QWizardPage{
public:
RAMPortWizardPage(QWidget* parent = nullptr);
//void initializePage() override;
//int nextId() const override;
void setData(GateType* gate);

private:
QGridLayout* mLayout;

QLineEdit* mDataGroup;
QLineEdit* mAddressGroup;
QLineEdit* mClockFunction;
QLineEdit* mEnableFunciton;
QLineEdit* mIsWritePort;

QLabel* mLabDataGroup;
QLabel* mLabAddressGroup;
QLabel* mLabClockFunction;
QLabel* mLabEnableFunciton;
QLabel* mLabIsWritePort;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// 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_pages/generalinfo_wizardpage.h"


#include <QWizardPage>
#include <QGridLayout>
#include <QTabWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QLabel>

namespace hal {
class StateWizardPage:public QWizardPage{
public:
StateWizardPage(QWidget* parent = nullptr);
//void initializePage() override;
//int nextId() const override;
void setData(GateType* gate);

private:
QGridLayout* mLayout;

QLineEdit* mStateIdentifier;
QLineEdit* mNegStateIdentifier;

QLabel* mLabStateIdentifier;
QLabel* mLabNegStateIdentifier;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include "gui/gatelibrary_management/gatelibrary_pages/lut_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_pages/init_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_pages/ram_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_pages/state_wizardpage.h"


#include <QWizard>
#include <QWizardPage>
Expand All @@ -42,6 +45,7 @@ namespace hal
{
class GateLibraryWizard : public QWizard
{
friend class RAMPortWizardPage;
public:
enum PAGE
{
Expand All @@ -51,7 +55,9 @@ namespace hal
Latch,
LUT,
RAM,
RAMPort,
Init,
State,
BooleanFunction
};

Expand All @@ -62,6 +68,7 @@ namespace hal
void addGate();
void setData(GateLibrary* gateLibrary, GateType* gateType);
QStringList getProperties();
QList<PinModel::PINGROUP*> getPingroups();
void accept() override;

//int getNextPageId(PAGE page);
Expand All @@ -78,7 +85,9 @@ namespace hal
LUTWizardPage* lutPage;
InitWizardPage* initPage;
RAMWizardPage* ramPage;
RAMPortWizardPage* ramportPage;
BoolWizardPage* boolPage;
StateWizardPage* statePage;

QString mName;
QStringList mProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace hal
//TODO:
//mTabWidget->addTab(mStateTableTab, "State Table");

mAReset->setDisabled(true);
mASet->setDisabled(true);

setLayout(mLayout);

}
Expand Down Expand Up @@ -72,10 +75,16 @@ namespace hal
mNextState->setText(QString::fromStdString(ff->get_next_state_function().to_string()));

if (ff->get_async_reset_function().is_empty()) mAReset->setText("N/A");
else mAReset->setText(QString::fromStdString(ff->get_async_reset_function().to_string()));
else {
mAReset->setDisabled(false);
mAReset->setText(QString::fromStdString(ff->get_async_reset_function().to_string()));
}

if (ff->get_async_set_function().is_empty()) mASet->setText("N/A");
else mASet->setText(QString::fromStdString(ff->get_async_set_function().to_string()));
else {
mASet->setDisabled(false);
mASet->setText(QString::fromStdString(ff->get_async_set_function().to_string()));
}

auto [stateBeh,negStateBeh] = ff->get_async_set_reset_behavior();
if (stateBeh == AsyncSetResetBehavior::undef) mIntState->setText("undefined");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#include "gui/gatelibrary_management/gatelibrary_pages/ram_port_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_wizard.h"
#include "gui/gatelibrary_management/gatelibrary_label.h"
#include "hal_core/netlist/gate_library/gate_type_component/ram_port_component.h"

namespace hal
{
RAMPortWizardPage::RAMPortWizardPage(QWidget* parent) : QWizardPage(parent)
{
setTitle("RAM Port");
setSubTitle("Enter parameters for RAM Port component");
mLayout = new QGridLayout(this);
mLabDataGroup = new QLabel("Name of the data pingroup: ");
mLabAddressGroup = new QLabel("Name of the address pingroup: ");
mLabClockFunction = new QLabel("Clock boolean function: ");
mLabEnableFunciton = new QLabel("Enable boolean function: ");
mLabIsWritePort = new QLabel("Is a write port: ");


int dataCnt =0, addrCnt=0;

//Error at casting
//GateLibraryWizard *wizard = reinterpret_cast<GateLibraryWizard*>(this->wizard());
//QList<PinModel::PINGROUP*> pingroups = wizard->getPingroups();


/*for (auto pinGroup : pingroups) {
if(pinGroup->type == PinType::data) dataCnt++;
if(pinGroup->type == PinType::address) addrCnt++;
}*/

//check for equality?
//if(dataCnt!=addrCnt)

//create empty lines for ram_port for each data/address pair
for (int i=0; i<dataCnt; i++) {
mLayout->addWidget(new GateLibraryLabel(false, QString("RAM Port %1").arg(i+1), this));

mDataGroup = new QLineEdit(this);
mAddressGroup = new QLineEdit(this);
mClockFunction = new QLineEdit(this);
mEnableFunciton = new QLineEdit(this);
mIsWritePort = new QLineEdit(this);

mLayout->addWidget(mLabDataGroup, 0, 0);
mLayout->addWidget(mDataGroup, 0, 1);
mLayout->addWidget(mLabAddressGroup, 1, 0);
mLayout->addWidget(mAddressGroup, 1, 1);
mLayout->addWidget(mLabClockFunction, 2, 0);
mLayout->addWidget(mClockFunction, 2, 1);
mLayout->addWidget(mLabEnableFunciton, 3, 0);
mLayout->addWidget(mEnableFunciton, 3, 1);
mLayout->addWidget(mLabIsWritePort, 4, 0);
mLayout->addWidget(mIsWritePort, 4, 1);

}

/*mDataGroup = new QLineEdit(this);
mAddressGroup = new QLineEdit(this);
mClockFunction = new QLineEdit(this);
mEnableFunciton = new QLineEdit(this);
mIsWritePort = new QLineEdit(this);
mLabDataGroup = new QLabel("Name of the data pingroup: ");
mLabAddressGroup = new QLabel("Name of the address pingroup: ");
mLabClockFunction = new QLabel("Clock boolean function: ");
mLabEnableFunciton = new QLabel("Enable boolean function: ");
mLabIsWritePort = new QLabel("Is a write port: ");
mLayout->addWidget(mLabDataGroup, 0, 0);
mLayout->addWidget(mDataGroup, 0, 1);
mLayout->addWidget(mLabAddressGroup, 1, 0);
mLayout->addWidget(mAddressGroup, 1, 1);
mLayout->addWidget(mLabClockFunction, 2, 0);
mLayout->addWidget(mClockFunction, 2, 1);
mLayout->addWidget(mLabEnableFunciton, 3, 0);
mLayout->addWidget(mEnableFunciton, 3, 1);
mLayout->addWidget(mLabIsWritePort, 4, 0);
mLayout->addWidget(mIsWritePort, 4, 1);*/

setLayout(mLayout);
}

// int InitWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::Init);
// }

void RAMPortWizardPage::setData(GateType *gate){
if(gate != nullptr && gate->has_component_of_type(GateTypeComponent::ComponentType::ram_port))
{
auto ram_ports = gate->get_components([](const GateTypeComponent* c) {return RAMPortComponent::is_class_of(c);});
int cnt = 1;

if(!ram_ports.empty())
{
for (auto comp : ram_ports) {
//mLayout->addWidget(new GateLibraryLabel(false, QString("RAM Port %1").arg(cnt), this));
auto ram_port = comp->convert_to<RAMPortComponent>();

GateLibraryLabel* dataGroup = new GateLibraryLabel(true,QString::fromStdString(ram_port->get_data_group()), this);
GateLibraryLabel* addressGroup = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_address_group()), this);
GateLibraryLabel* clkFunc = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_clock_function().to_string()), this);
GateLibraryLabel* enableFunc = new GateLibraryLabel(true, QString::fromStdString(ram_port->get_enable_function().to_string()), this);
GateLibraryLabel* writePort = new GateLibraryLabel(true, ram_port->is_write_port() ? "True" : "False", this);

/*mLayout->addWidget(new GateLibraryLabel(false, "Name of the data pingroup:", this), dataGroup);
mLayout->addWidget(new GateLibraryLabel(false, "Name of the address pingroup:", this), addressGroup);
mLayout->addWidget(new GateLibraryLabel(false, "Clock boolean function:", this), clkFunc);
mLayout->addWidget(new GateLibraryLabel(false, "Enable boolean function:", this), enableFunc);
mLayout->addWidget(new GateLibraryLabel(false, "Is a write port:", this), writePort);*/

cnt++;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "gui/gatelibrary_management/gatelibrary_pages/state_wizardpage.h"
#include "gui/gatelibrary_management/gatelibrary_wizard.h"
#include "hal_core/netlist/gate_library/gate_type_component/state_component.h"

namespace hal
{
StateWizardPage::StateWizardPage(QWidget* parent) : QWizardPage(parent)
{
setTitle("State");
setSubTitle("Enter parameters for state component");
mLayout = new QGridLayout(this);

mStateIdentifier = new QLineEdit(this);
mNegStateIdentifier = new QLineEdit(this);

mLabStateIdentifier = new QLabel("State identifier: ");
mLabNegStateIdentifier = new QLabel("Negative state identifier: ");

mLayout->addWidget(mLabStateIdentifier, 0, 0);
mLayout->addWidget(mStateIdentifier, 0, 1);
mLayout->addWidget(mLabNegStateIdentifier, 1, 0);
mLayout->addWidget(mNegStateIdentifier, 1, 1);

setLayout(mLayout);
}

// int InitWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::Init);
// }

void StateWizardPage::setData(GateType *gate){
if(gate != nullptr && gate->has_component_of_type(GateTypeComponent::ComponentType::state))
{
auto stat = gate->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()));
}
}
}
}
Loading

0 comments on commit 2350eb7

Please sign in to comment.