Skip to content

Commit

Permalink
Implemented adding components to the gate
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Jun 22, 2024
1 parent 139fc5d commit 9b49be7
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

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

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,26 @@

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

private:
QGridLayout* mLayout;

QLineEdit* mDataIn;
QLineEdit* mEnableOn;
QLineEdit* mAReset;
QLineEdit* mASet;
QLineEdit* mIntState;
QLineEdit* mNegIntState;

QLabel* mLabDataIn;
QLabel* mLabEnableOn;
QLabel* mLabAReset;
QLabel* mLabASet;
QLabel* mLabIntState;
QLabel* mLabNegIntState;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#pragma once
#include "gui/gatelibrary_management/gatelibrary_pages/generalinfo_wizardpage.h"

#include "hal_core/netlist/gate_library/gate_type_component/ram_port_component.h"

#include <QWizardPage>
#include <QGridLayout>
Expand All @@ -39,18 +39,23 @@ namespace hal {
class RAMPortWizardPage:public QWizardPage{
public:
RAMPortWizardPage(QWidget* parent = nullptr);

struct RAMPort{
QLineEdit* dataGroup;
QLineEdit* addressGroup;
QLineEdit* clockFunction;
QLineEdit* enableFunciton;
QLineEdit* isWritePort;
};
QList<RAMPort> getRamPorts();
void setData(GateType* gate);
void initializePage() override;

private:
GateLibraryWizard* mWizard;
QGridLayout* mLayout;

QLineEdit* mDataGroup;
QLineEdit* mAddressGroup;
QLineEdit* mClockFunction;
QLineEdit* mEnableFunciton;
QLineEdit* mIsWritePort;
QList<RAMPort> mRamPortEdits;

QLabel* mLabDataGroup;
QLabel* mLabAddressGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@

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

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@

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

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ namespace hal
mWizard = new GateLibraryWizard(mEditableGatelibrary, mTableModel->getGateTypeAtIndex(index.row()));
mWizard->exec();
initialize(mEditableGatelibrary);

mContentWidget->mTableView->selectRow(index.row());
}

void GateLibraryManager::handleAddWizard()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ namespace hal
mIdentifiers->setText(ids);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,38 @@ namespace hal

mDataIn = new QLineEdit(this);
mEnableOn = new QLineEdit(this);
mAReset = new QLineEdit(this);
mASet = new QLineEdit(this);
mIntState = new QLineEdit(this);
mNegIntState = new QLineEdit(this);

mLabDataIn = new QLabel("Data input function: ");
mLabEnableOn = new QLabel("Enable behaviour function: ");
mLabDataIn = new QLabel("Data input function: ", this);
mLabEnableOn = new QLabel("Enable behaviour function: ", this);
mLabAReset = new QLabel("Asynchronous reset: ", this);
mLabASet = new QLabel("Asynchronous set: ", this);
mLabIntState = new QLabel("Set+Reset -> internal state: ", this);
mLabNegIntState = new QLabel("Set+Reset -> neg. int. state:", this);

mLayout->addWidget(mLabDataIn, 0, 0);
mLayout->addWidget(mDataIn, 0, 1);
mLayout->addWidget(mLabEnableOn, 1, 0);
mLayout->addWidget(mEnableOn, 1, 1);
mLayout->addWidget(mLabAReset, 2, 0);
mLayout->addWidget(mAReset, 2, 1);
mLayout->addWidget(mLabASet, 3, 0);
mLayout->addWidget(mASet, 3, 1);
mLayout->addWidget(mLabIntState, 4, 0);
mLayout->addWidget(mIntState, 4, 1);
mLayout->addWidget(mLabNegIntState, 5, 0);
mLayout->addWidget(mNegIntState, 5, 1);

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

setLayout(mLayout);

}

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

void LatchWizardPage::setData(GateType *gate){
if(gate != nullptr && gate->has_component_of_type(GateTypeComponent::ComponentType::latch))
{
Expand All @@ -42,6 +53,24 @@ namespace hal
{
mEnableOn->setText(QString::fromStdString(latch->get_enable_function().to_string()));
mDataIn->setText(QString::fromStdString(latch->get_data_in_function().to_string()));

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

auto [stateBeh,negStateBeh] = latch->get_async_set_reset_behavior();
if (stateBeh == AsyncSetResetBehavior::undef) mIntState->setText("undefined");
else mIntState->setText(QString::fromStdString(enum_to_string<AsyncSetResetBehavior>(stateBeh)));

if (negStateBeh == AsyncSetResetBehavior::undef) mNegIntState->setText("undefined");
else mNegIntState->setText(QString::fromStdString(enum_to_string<AsyncSetResetBehavior>(negStateBeh)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#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
{
Expand All @@ -11,7 +10,6 @@ namespace hal
setSubTitle("Enter parameters for RAM Port component");
mLayout = new QGridLayout(this);


/*mDataGroup = new QLineEdit(this);
mAddressGroup = new QLineEdit(this);
mClockFunction = new QLineEdit(this);
Expand Down Expand Up @@ -57,11 +55,12 @@ void RAMPortWizardPage::initializePage(){
ramPortCnt++;
mLayout->addWidget(new GateLibraryLabel(false, QString("RAM Port %1").arg(ramPortCnt), this), 6*(ramPortCnt-1), 0);

mDataGroup = new QLineEdit(this);
mAddressGroup = new QLineEdit(this);
mClockFunction = new QLineEdit(this);
mEnableFunciton = new QLineEdit(this);
mIsWritePort = new QLineEdit(this);
RAMPort rp;
rp.dataGroup = new QLineEdit(this);
rp.addressGroup = new QLineEdit(this);
rp.clockFunction = new QLineEdit(this);
rp.enableFunciton = new QLineEdit(this);
rp.isWritePort = new QLineEdit(this);

mLabDataGroup = new QLabel("Name of the data pingroup: ");
mLabAddressGroup = new QLabel("Name of the address pingroup: ");
Expand All @@ -70,23 +69,24 @@ void RAMPortWizardPage::initializePage(){
mLabIsWritePort = new QLabel("Is a write port: ");

mLayout->addWidget(mLabDataGroup, 6*(ramPortCnt-1)+1, 0);
mLayout->addWidget(mDataGroup, 6*(ramPortCnt-1)+1, 1);
mLayout->addWidget(rp.dataGroup, 6*(ramPortCnt-1)+1, 1);
mLayout->addWidget(mLabAddressGroup, 6*(ramPortCnt-1)+2, 0);
mLayout->addWidget(mAddressGroup, 6*(ramPortCnt-1)+2, 1);
mLayout->addWidget(rp.addressGroup, 6*(ramPortCnt-1)+2, 1);
mLayout->addWidget(mLabClockFunction, 6*(ramPortCnt-1)+3, 0);
mLayout->addWidget(mClockFunction, 6*(ramPortCnt-1)+3, 1);
mLayout->addWidget(rp.clockFunction, 6*(ramPortCnt-1)+3, 1);
mLayout->addWidget(mLabEnableFunciton, 6*(ramPortCnt-1)+4, 0);
mLayout->addWidget(mEnableFunciton, 6*(ramPortCnt-1)+4, 1);
mLayout->addWidget(rp.enableFunciton, 6*(ramPortCnt-1)+4, 1);
mLayout->addWidget(mLabIsWritePort, 6*(ramPortCnt-1)+5, 0);
mLayout->addWidget(mIsWritePort, 6*(ramPortCnt-1)+5, 1);
mLayout->addWidget(rp.isWritePort, 6*(ramPortCnt-1)+5, 1);

if(!ram_ports.empty()) {
auto ram_port = ram_ports[ramPortCnt-1]->convert_to<RAMPortComponent>();
mDataGroup->setText(QString::fromStdString(ram_port->get_data_group()));
mAddressGroup->setText(QString::fromStdString(ram_port->get_address_group()));
mClockFunction->setText(QString::fromStdString(ram_port->get_clock_function().to_string()));
mEnableFunciton->setText(QString::fromStdString(ram_port->get_clock_function().to_string()));
mIsWritePort->setText(ram_port->is_write_port() ? "True":"False");
rp.dataGroup->setText(QString::fromStdString(ram_port->get_data_group()));
rp.addressGroup->setText(QString::fromStdString(ram_port->get_address_group()));
rp.clockFunction->setText(QString::fromStdString(ram_port->get_clock_function().to_string()));
rp.enableFunciton->setText(QString::fromStdString(ram_port->get_clock_function().to_string()));
rp.isWritePort->setText(ram_port->is_write_port() ? "True":"False");
mRamPortEdits.append(rp);
}
}
}
Expand All @@ -97,4 +97,8 @@ void RAMPortWizardPage::initializePage(){
void RAMPortWizardPage::setData(GateType *gate){
mGate = gate;
}

QList<RAMPortWizardPage::RAMPort> RAMPortWizardPage::getRamPorts(){
return mRamPortEdits;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ namespace hal
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))
{
Expand Down
Loading

0 comments on commit 9b49be7

Please sign in to comment.