Skip to content

Commit

Permalink
implemented saving the changes to the gate made with the wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Jun 27, 2024
1 parent c650b05 commit 4347539
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace hal {
QString getName();
QStringList getProperties();
void setMode(bool edit);
bool isEdit();
bool validatePage() override;
public Q_SLOTS:
void addProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ namespace hal

GateLibraryWizard(GateLibrary* gateLibrary, GateType* gateType = nullptr, QWidget* parent = nullptr);

void editGate(GateType* gt);
void editGate();
GateType* addGate();
void setData(GateLibrary* gateLibrary, GateType* gateType);
QList<PinItem*> getPingroups();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,9 @@ namespace hal

if (gPluginRelay->mGuiPluginTable)
gPluginRelay->mGuiPluginTable->loadFeature(FacExtensionInterface::FacGatelibParser);
//qInfo() << "selected file: " << fileName;

auto gateLibrary = gate_library_manager::load(std::filesystem::path(fileName.toStdString()));

/*for (auto const elem : gateLibrary->get_gate_types())
{
qInfo() << QString::fromStdString(elem.second->get_name());
}*/

mEditableGatelibrary = gateLibrary;
mDemoNetlist = netlist_factory::create_netlist(mEditableGatelibrary);
mReadOnly = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ namespace hal

setLayout(mLayout);

registerField("name*", mName);
registerField("properties", mProperties);

//TODO: fetch data from enum GateTypeProperty
mAddProperty->addItems(QStringList{
"combinational",
Expand Down Expand Up @@ -77,6 +74,11 @@ namespace hal
mIsEdit = edit;
}

bool GeneralInfoWizardPage::isEdit()
{
return mIsEdit;
}

void GeneralInfoWizardPage::setData(QString name, QStringList properties)
{
mName->setText(name);
Expand All @@ -93,7 +95,6 @@ namespace hal
{
QStringList res;
for (int i = 0; i < mProperties->count(); i++) {
//qInfo()<<mProperties->item(i)->text();
res.append(mProperties->item(i)->text());
}
return res;
Expand Down
85 changes: 57 additions & 28 deletions plugins/gui/src/gatelibrary_management/gatelibrary_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,15 @@ namespace hal
}
}

void GateLibraryWizard::editGate(GateType* gt)
void GateLibraryWizard::editGate()
{

}

GateType* GateLibraryWizard::addGate()
{
//Convert QStringList to std::set
std::set<GateTypeProperty> properties_set;
for(QString prop : generalInfoPage->getProperties())
properties_set.insert(enum_from_string<GateTypeProperty>(prop.toStdString()));
//Set name, properties and the parent component
mNewGateType = mGateLibrary->create_gate_type(generalInfoPage->getName().toStdString(), properties_set, setComponents());
//Set pingroups and pins
for(PinItem* pingroup : getPingroups())
{
std::vector<GatePin*> gatepins;
for (auto it : pingroup->getChildren()) {
PinItem* pin = static_cast<PinItem*>(it);
if(pin->getItemType() != PinItem::TreeItemType::PinCreator)
{
auto res = mNewGateType->create_pin(pin->getName().toStdString(), pin->getDirection(), pin->getPinType());
if(res.is_ok()) gatepins.push_back(res.get());
}
}
if(pingroup->getItemType() != PinItem::TreeItemType::GroupCreator)
mNewGateType->create_pin_group(pingroup->getName().toStdString(), gatepins, pingroup->getDirection(), pingroup->getPinType());
}

//Set boolean functions
mNewGateType->add_boolean_functions(boolPage->getBoolFunctions());
return mNewGateType;

}

void GateLibraryWizard::setData(GateLibrary *gateLibrary, GateType* gateType)
Expand All @@ -104,10 +81,61 @@ namespace hal

void GateLibraryWizard::accept()
{
//TODO: get all the data after user finishes
/*if(generalInfoPage->isEdit()) editGate();
else addGate();*/

//Convert QStringList to std::set
std::set<GateTypeProperty> properties_set;
for(QString prop : generalInfoPage->getProperties())
properties_set.insert(enum_from_string<GateTypeProperty>(prop.toStdString()));

if(generalInfoPage->isEdit())
{
mGateType = mGateLibrary->replace_gate_type(mGateType->get_id(), generalInfoPage->getName().toStdString(), properties_set, setComponents());
//Set pingroups and pins
for(PinItem* pingroup : getPingroups())
{
std::vector<GatePin*> gatepins;
for (auto it : pingroup->getChildren()) {
PinItem* pin = static_cast<PinItem*>(it);
if(pin->getItemType() != PinItem::TreeItemType::PinCreator)
{
auto res = mGateType->create_pin(pin->getName().toStdString(), pin->getDirection(), pin->getPinType());
if(res.is_ok()) gatepins.push_back(res.get());
}
}
if(pingroup->getItemType() != PinItem::TreeItemType::GroupCreator)
mGateType->create_pin_group(pingroup->getName().toStdString(), gatepins, pingroup->getDirection(), pingroup->getPinType());
}

//TODO: Set boolean functions without adding the same double
//also: boolean functions may be removed
mGateType->add_boolean_functions(boolPage->getBoolFunctions());
}
else
{
//Set name, properties and the parent component
mNewGateType = mGateLibrary->create_gate_type(generalInfoPage->getName().toStdString(), properties_set, setComponents());
//Set pingroups and pins
for(PinItem* pingroup : getPingroups())
{
std::vector<GatePin*> gatepins;
for (auto it : pingroup->getChildren()) {
PinItem* pin = static_cast<PinItem*>(it);
if(pin->getItemType() != PinItem::TreeItemType::PinCreator)
{
auto res = mNewGateType->create_pin(pin->getName().toStdString(), pin->getDirection(), pin->getPinType());
if(res.is_ok()) gatepins.push_back(res.get());
}
}
if(pingroup->getItemType() != PinItem::TreeItemType::GroupCreator)
mNewGateType->create_pin_group(pingroup->getName().toStdString(), gatepins, pingroup->getDirection(), pingroup->getPinType());
}

//Set boolean functions
mNewGateType->add_boolean_functions(boolPage->getBoolFunctions());
}

if(!mGateLibrary->contains_gate_type_by_name(generalInfoPage->getName().toStdString())) addGate();
else editGate(mGateLibrary->get_gate_type_by_name(generalInfoPage->getName().toStdString()));

this->close();
}
Expand Down Expand Up @@ -251,6 +279,7 @@ namespace hal
else if(properties.contains("latch")) return Latch;
else if(properties.contains("c_lut")) return LUT;
else if(properties.contains("ram")) return RAM;
else return BoolFunc;
case FlipFlop:
if(properties.contains("latch")) return Latch;
else if(properties.contains("c_lut")) return LUT;
Expand Down

0 comments on commit 4347539

Please sign in to comment.