Skip to content

Commit

Permalink
added incomplete ram_port implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed May 21, 2024
1 parent 2350eb7 commit 4ba4069
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@
#include <gui/gatelibrary_management/gatelibrary_tab_widgets/gatelibrary_tab_pin.h>

namespace hal {
class GateLibraryWizard;
class PinsWizardPage:public QWizardPage{
Q_OBJECT
public:
PinsWizardPage(QWidget* parent = nullptr);
void setGateType(GateType* gate);
//int nextId() const override;
void initializePage() override;
QList<PinModel::PINGROUP*> getPingroups();

public Q_SLOTS:
void handleDeleteClicked();
private:
QGridLayout* mLayout;
GateLibraryWizard* mWizard;
PinModel* mPinModel;
QTreeView* mPinsTreeView;
GateLibrary* mGateLibrary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
#include <QLabel>

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

private:
GateLibraryWizard* mWizard;
QGridLayout* mLayout;

QLineEdit* mDataGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace hal
class GateLibraryWizard : public QWizard
{
friend class RAMPortWizardPage;
friend class PinsWizardPage;
public:
enum PAGE
{
Expand All @@ -70,10 +71,6 @@ namespace hal
QStringList getProperties();
QList<PinModel::PINGROUP*> getPingroups();
void accept() override;

//int getNextPageId(PAGE page);
//void setPageOrder();

int nextId() const override;
private:
const GateLibrary* mGateLibrary;
Expand All @@ -92,6 +89,8 @@ namespace hal
QString mName;
QStringList mProperties;
QList<PinModel::PINGROUP*> mPingroups;
PinModel* mPinModel;
GateLibraryTabPin* mPinTab;

bool isDirty;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,38 @@ namespace hal
setTitle("Step 2: Pins and Pingroups");
setSubTitle("Edit pins and pingroups");
mLayout = new QGridLayout(this);
mPinModel = new PinModel(this, true);
//mPinModel->setGate(new GateType());

mPinTab = new GateLibraryTabPin(this, true);
//mAddBtn = new QPushButton("Add", this);
mDelBtn = new QPushButton("Delete", this);

mLayout->addWidget(mPinTab, 0, 0, 1, 2);

mLayout->addWidget(mDelBtn, 1, 0);
//mLayout->addWidget(mAddBtn, 1, 1);
mLayout->addWidget(mPinTab, 0, 0, 1, 2);

connect(mDelBtn, &QPushButton::clicked, this, &PinsWizardPage::handleDeleteClicked);

setLayout(mLayout);
}

void PinsWizardPage::setGateType(GateType* gate)
void PinsWizardPage::initializePage(){

//2
//mPinTab = mWizard->mPinTab;
mWizard = static_cast<GateLibraryWizard*>(wizard());
mPinModel = mPinTab->getPinModel();
mWizard->mPinModel = mPinModel;

mPinTab->update(mWizard->mGateType);

}

/*void PinsWizardPage::setGateType(GateType* gate)
{
//1
mWizard = static_cast<GateLibraryWizard*>(wizard());
mPinModel = mWizard->mPinModel;
mPinTab->update(gate);
}
}*/

void PinsWizardPage::handleDeleteClicked()
{
Expand All @@ -39,14 +51,6 @@ namespace hal
pinModel->handleDeleteItem(treeView->currentIndex());
}

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

QList<PinModel::PINGROUP*> PinsWizardPage::getPingroups(){
return mPinModel->getPinGroups();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,6 @@ namespace hal
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);
Expand All @@ -81,13 +42,49 @@ namespace hal
setLayout(mLayout);
}

// int InitWizardPage::nextId() const
// {
// auto parentWizard = wizard();
// if(!parentWizard)
// return -1;
// return static_cast<GateLibraryWizard*>(parentWizard)->getNextPageId(GateLibraryWizard::Init);
// }
void RAMPortWizardPage::initializePage(){
mWizard = static_cast<GateLibraryWizard*>(wizard());
int ramPortCnt = 1;
QList<PinModel::PINGROUP*> pinGroups = mWizard->getPingroups();
/*for (auto pinGroup : mWizard->getPingroups()) {
//assumption at this point: #data fields = #address fields
if(pinGroup->type == PinType::data) ramPortCnt++;
}*/
//check for equality?
//if(dataCnt!=addrCnt)

//create empty lines for ram_port for each data/address pair
for (int i=0; i<pinGroups.length(); i++) {
QString name = pinGroups[i]->name;
PinType type = pinGroups[i]->type;
if(pinGroups[i]->type == PinType::data)
{
mLayout->addWidget(new GateLibraryLabel(false, QString("RAM Port %1").arg(ramPortCnt), 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+i*5, 0);
mLayout->addWidget(mDataGroup, 0+i*5, 1);
mLayout->addWidget(mLabAddressGroup, 1+i*5, 0);
mLayout->addWidget(mAddressGroup, 1+i*5, 1);
mLayout->addWidget(mLabClockFunction, 2+i*5, 0);
mLayout->addWidget(mClockFunction, 2+i*5, 1);
mLayout->addWidget(mLabEnableFunciton, 3+i*5, 0);
mLayout->addWidget(mEnableFunciton, 3+i*5, 1);
mLayout->addWidget(mLabIsWritePort, 4+i*5, 0);
mLayout->addWidget(mIsWritePort, 4+i*5, 1);

ramPortCnt++;
}
}

setLayout(mLayout);

}

void RAMPortWizardPage::setData(GateType *gate){
if(gate != nullptr && gate->has_component_of_type(GateTypeComponent::ComponentType::ram_port))
Expand Down
56 changes: 31 additions & 25 deletions plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ namespace hal
{
GateLibraryWizard::GateLibraryWizard(const GateLibrary *gateLibrary, GateType *gateType, QWidget* parent): QWizard(parent)
{
generalInfoPage = new GeneralInfoWizardPage(gateLibrary, parent);
pinsPage = new PinsWizardPage(parent);
ffPage = new FlipFlopWizardPage(parent);
boolPage = new BoolWizardPage(parent);

latchPage = new LatchWizardPage(parent);
lutPage = new LUTWizardPage(parent);
initPage = new InitWizardPage(parent);
ramPage = new RAMWizardPage(parent);
ramportPage = new RAMPortWizardPage(parent);
statePage = new StateWizardPage(parent);
generalInfoPage = new GeneralInfoWizardPage(gateLibrary, this);
pinsPage = new PinsWizardPage(this);
ffPage = new FlipFlopWizardPage(this);
boolPage = new BoolWizardPage(this);

latchPage = new LatchWizardPage(this);
lutPage = new LUTWizardPage(this);
initPage = new InitWizardPage(this);
ramPage = new RAMWizardPage(this);
ramportPage = new RAMPortWizardPage(this);
statePage = new StateWizardPage(this);

setPage(GeneralInfo, generalInfoPage);
setPage(Pin, pinsPage);
Expand All @@ -33,6 +33,8 @@ namespace hal
mGateLibrary = gateLibrary;
mGateType = gateType;
generalInfoPage->setMode(false);
mPinModel = new PinModel(this, true);
mPinTab = new GateLibraryTabPin(this, true);

if(mGateType != nullptr)
{
Expand All @@ -49,22 +51,23 @@ namespace hal
ramPage->setData(mGateType);
ramportPage->setData(mGateType);
statePage->setData(mGateType);
pinsPage->setGateType(mGateType);
//pinsPage->setGateType(mGateType);
}
}

GateLibraryWizard::GateLibraryWizard(const GateLibrary *gateLibrary, QWidget* parent): QWizard(parent)
{
generalInfoPage = new GeneralInfoWizardPage(gateLibrary, parent);
pinsPage = new PinsWizardPage(parent);
ffPage = new FlipFlopWizardPage(parent);
latchPage = new LatchWizardPage(parent);
lutPage = new LUTWizardPage(parent);
initPage = new InitWizardPage(parent);
ramPage = new RAMWizardPage(parent);
ramportPage = new RAMPortWizardPage(parent);
boolPage = new BoolWizardPage(parent);
statePage = new StateWizardPage(parent);
generalInfoPage = new GeneralInfoWizardPage(gateLibrary, this);
pinsPage = new PinsWizardPage(this);
ffPage = new FlipFlopWizardPage(this);
boolPage = new BoolWizardPage(this);

latchPage = new LatchWizardPage(this);
lutPage = new LUTWizardPage(this);
initPage = new InitWizardPage(this);
ramPage = new RAMWizardPage(this);
ramportPage = new RAMPortWizardPage(this);
statePage = new StateWizardPage(this);

setPage(GeneralInfo, generalInfoPage);
setPage(Pin, pinsPage);
Expand All @@ -76,10 +79,13 @@ namespace hal
setPage(Init, initPage);
setPage(State, statePage);
setPage(BooleanFunction, boolPage);
pinsPage->setGateType(nullptr);
mGateLibrary = gateLibrary;
//pinsPage->setGateType(nullptr);
generalInfoPage->setMode(false);
ffPage->setData(nullptr);
mGateLibrary = gateLibrary;

mPinTab = new GateLibraryTabPin(this, true);
mPinModel = new PinModel(this, true);
}

void GateLibraryWizard::editGate(GateType* gt)
Expand Down Expand Up @@ -116,7 +122,7 @@ namespace hal

QList<PinModel::PINGROUP*> GateLibraryWizard::getPingroups()
{
return pinsPage->getPingroups();
return mPinModel->getPinGroups();
}

int GateLibraryWizard::nextId() const
Expand Down
38 changes: 31 additions & 7 deletions plugins/gui/src/pin_model/pin_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,25 +303,49 @@ namespace hal

switch (itemType)
{
case PinItem::TreeItemType::InvalidPin:
case PinItem::TreeItemType::Pin: {
case PinItem::TreeItemType::InvalidPin:{
pinItem->setType(type);
handleInvalidPinUpdate(pinItem);
break;
}
case PinItem::TreeItemType::InvalidPinGroup:
case PinItem::TreeItemType::Pin: {
pinItem->setType(type);
break;
}
case PinItem::TreeItemType::InvalidPinGroup:{
pinItem->setType(type);
for(auto child : pinItem->getChildren()) //set same type for all pins of the pingroup
{
PinItem* pin = static_cast<PinItem*>(child);
if(pin->getItemType() == PinItem::TreeItemType::Pin || pin->getItemType() == PinItem::TreeItemType::InvalidPin){
pin->setType(type);
handleInvalidPinUpdate(pin);
}
}
handleInvalidGroupUpdate(pinItem);
break;
}
case PinItem::TreeItemType::PinGroup: {
pinItem->setType(type);
for(auto child : pinItem->getChildren()) //set same direction for all pins of the pingroup
//PinModel::PINGROUP* pinGroup = static_cast<PinModel::PINGROUP*>(pinItem);

/*for(auto child : pinItem->getChildren()) //set same type for all pins of the pingroup
{
PinItem* pin = static_cast<PinItem*>(child);
if(pin->getItemType() == PinItem::TreeItemType::Pin || pin->getItemType() == PinItem::TreeItemType::InvalidPin){
pin->setType(type);
handleInvalidPinUpdate(pin);
}
}*/

PinModel::PINGROUP* pg = static_cast<PinModel::PINGROUP*>(index.internalPointer());
for(auto group : mPinGroups){
if(group->name == pinItem->getName()){
for(auto pin : group->pins){
pin->type = PinType::data;
}
break;
}
}
handleInvalidGroupUpdate(pinItem);
break;
}
}
}
Expand Down

0 comments on commit 4ba4069

Please sign in to comment.