10 #include <QFileDialog>
11 #include <QMessageBox>
21 :
QWizard(parent), mController(controller), mSettings(settings)
47 mButSel =
new QPushButton(
"Current GUI selection",
this);
50 mButNone =
new QPushButton(
"Clear selection",
this);
75 void PageSelectGates::handleCurrentGuiSelection()
84 guiGateSel.
insert(g->get_id());
94 for (
int irow = 0; irow<nrows; irow++)
105 std::vector<Gate*> retval;
117 for (
u32 gid: selGates)
120 if (g) retval.push_back(g);
128 Q_UNUSED(deselected);
130 QString txt(
"\nSelect the gates to be used for simulation.\n");
137 mController->
reset();
156 setSubTitle(
tr(
"\nSelect and generate the clock input\nor indicate that no clock generator is used\n(e.g. when clock signal provided in input data)"));
173 mSpinStartValue =
new QSpinBox(
this);
185 mDontUseClock =
new QCheckBox(
"Do not use clock generator in simulation",
this);
205 if (upcase ==
"CLK" || upcase ==
"CLOCK")
214 void PageClock::dontUseClockChanged(
bool state)
231 int period = mSpinPeriod->
value();
239 std::string clkNetName = mComboNet->
currentText().toStdString();
243 size_t pos = clkNetName.find(
"[");
244 if (
pos != std::string::npos)
245 clkNetName = clkNetName.substr(0,
pos);
247 if (clkNetName == n->get_name())
251 clk, period, mSpinStartValue->
value()==0, mSpinDuration->
value());
263 :
QWizardPage(parent), mController(controller), m_wizard(parent)
266 setSubTitle(
tr(
"\nSelect the engine for the simulation\nIf the engine you are looking for is not listed,\nyou might have to load the plugin first"));
290 for (
int i = 0; i < mLayout->
count(); ++i)
293 if (radioButton && radioButton->
isChecked())
295 selectedEngineName = radioButton->
text();
299 if (selectedEngineName.
toStdString() ==
"verilator")
327 :
QWizardPage(parent), mController(controller), mSettings(settings)
330 setSubTitle(
tr(
"\nEnter engine properties for the verilator"));
342 mAllItems <<
"" <<
"provided_models" <<
"num_of_threads" <<
"compiler" <<
"ssh_server";
344 for (
int irow = 0; irow < mTableWidget->
rowCount(); ++irow)
387 void PageEngineProperties::updateComboBoxes(
const QString &selectedText)
389 if (selectedText ==
"")
392 for (
int irow = 0; irow < mTableWidget->
rowCount(); ++irow)
401 for (
int irow = 0; irow < mTableWidget->
rowCount(); ++irow)
411 for (
const QString &item : mAllItems)
413 if (!selectedItems.
contains(item) || item == currentText || item ==
"")
425 void PageEngineProperties::handleCellChanged(
int irow,
int icolumn)
427 if ((icolumn == 1 && irow >= mTableWidget->
rowCount()-2) ||
428 (icolumn == 0 && irow >= mTableWidget->
rowCount()-1))
436 for (
int irow = 0; irow < mTableWidget->
rowCount(); ++irow)
439 if (!comboBox)
continue;
441 if (key.
isEmpty() || key ==
"")
continue;
448 engProp[key] = value;
458 :
QWizardPage(parent), mController(controller), mDisableToggleHandler(false)
460 setTitle(
tr(
"Step 4 : Simulation Input Data"));
468 mRadFile =
new QRadioButton(
"Simulation input from file",
this);
472 mFrameFile =
new QFrame(
this);
480 mEditFilename =
new QLineEdit(mFrameFile);
494 mRadEditor =
new QRadioButton(
"Enter simulation input manually",
this);
498 mFrameTable =
new QFrame(
this);
506 mDisplayHexValues =
new QCheckBox(
"Display values as hex numbers", mFrameTable);
511 mButFileimport =
new QPushButton(
"Load data from file");
520 handleRadioToggled(
true);
527 handleRadioToggled(
true);
530 bool PageInputData::canFileImport(
const QString& filename)
532 if (filename.
isEmpty())
return false;
533 if (filename.
endsWith(
"saleae.json"))
return true;
534 if (filename.
endsWith(
".vcd"))
return true;
535 if (filename.
endsWith(
".csv"))
return true;
539 void PageInputData::handleRadioToggled(
bool checked)
541 if (mDisableToggleHandler)
return;
542 bool setManualInput =
false;
543 if (
sender() == mRadEditor)
544 setManualInput = checked;
546 setManualInput = !checked;
547 mDisableToggleHandler =
true;
556 mButFileimport->
setEnabled(canFileImport(mEditFilename->
text().toLower()));
572 mDisableToggleHandler =
false;
576 void PageInputData::openFileBrowser()
578 QString filter(
"Simulation data (saleae.json);;"
579 " VCD files (*.vcd);;"
580 " CSV files (*.csv)");
585 if (filename.
isEmpty())
return;
587 mEditFilename->
setText(filename);
591 void PageInputData::updateSubtitle()
600 subtitle =
"No input data file selected so far";
606 if (!fileInfo.isFile() || !fileInfo.isReadable())
608 subtitle =
"File '" + fileName +
"' is not readable";
612 subtitle =
"Parsing input files with extension '." + fileInfo.suffix() +
"' is not supported";
616 subtitle =
"Run simulation with data file '" + fileName +
"'";
624 subtitle =
"Please enter input data in table below";
626 subtitle =
QString(
"%1 input events entered in table so far").
arg(nLines);
631 void PageInputData::handleFileImport()
675 if (fileName.
endsWith(
"saleae.json"))
679 std::unordered_map<Net*, int> lookupTable;
684 lookupTable[
const_cast<Net*
>(inpNet)] = inx;
741 setSubTitle(
tr(
"\nStart simulation based on controller settings from previous steps"));
755 mState =
new QLabel(
"Ready to start simulation",
this);
760 void PageRunSimulation::handleStartClicked()
770 handleStateChanged(mController->
get_state());
793 void PageRunSimulation::handleLogfileRead()
800 if (!success)
return;
804 handleStateChanged(mController->
get_state());
820 :
QWizardPage(parent), mController(controller), mWaveWidget(ww)
822 setTitle(
tr(
"Simulation Done : Load Simulation Results"));
823 setSubTitle(
"\nThis page is not ready yet.\nPlease invoke load results from toolbar.");
829 mButAll =
new QPushButton(
"Wave data for all nets",
this);
831 mButGui =
new QPushButton(
"Only nets selected in GUI",
this);
833 mButNone =
new QPushButton(
"Clear selection",
this);
858 void PageLoadResults::useGuiSelection()
869 for (
int irow = 0; irow<nrows; irow++)
875 for (
int i=0; i<n; i++)
The GateSelectModel class is the source model for module selection.
The GateSelectProxy class allows sorting and filtering of module tables.
void loadFeature(FacExtensionInterface::Feature ft, const QString &extension=QString())
const std::vector< Gate * > & get_gates() const
Gate * get_gate_by_id(const u32 gate_id) const
Module * get_module_by_id(u32 module_id) const
void engineFinished(bool success)
void simulate(u64 picoseconds)
const std::unordered_set< const Gate * > & get_gates() const
bool import_vcd(const std::string &filename, FilterInputFlag filter)
SimulationState get_state() const
void compute_waveform_groups()
std::string get_working_directory() const
std::vector< InputColumnHeader > get_input_column_headers() const
void add_gates(const std::vector< Gate * > &gates)
void import_csv(const std::string &filename, FilterInputFlag filter, u64 timescale=1000000000)
std::filesystem::path get_saleae_directory_filename() const
void stateChanged(hal::NetlistSimulatorController::SimulationState state)
void load_waveform_groups(bool inputs)
WaveDataList * get_waves() const
void add_clock_period(const Net *clock_net, u64 period, bool start_at_zero=true, u64 duration=0)
void setLogReceiver(SimulationLogReceiver *logrec)
WaveData * get_waveform_by_net(const Net *n) const
SimulationEngine * create_simulation_engine(const std::string &name)
void import_saleae(const std::string &dirname, std::unordered_map< Net *, int > lookupTable, u64 timescale=1000000000)
bool can_import_data() const
std::string get_name() const
const std::unordered_set< const Net * > & get_input_nets() const
bool is_no_clock_used() const
PageClock(NetlistSimulatorController *controller, QWidget *parent=nullptr)
virtual bool validatePage() override
virtual void initializePage() override
PageEngine(NetlistSimulatorController *controller, Wizard *parent=nullptr)
virtual bool validatePage() override
int nextId() const override
PageEngineProperties(SimulationSettings *settings, NetlistSimulatorController *controller, QWidget *parent=nullptr)
virtual bool validatePage() override
PageInputData(NetlistSimulatorController *controller, QWidget *parent=nullptr)
virtual bool validatePage() override
virtual void initializePage() override
PageLoadResults(NetlistSimulatorController *controller, WaveWidget *ww, QWidget *parent=nullptr)
virtual bool validatePage() override
virtual void initializePage() override
virtual int nextId() const override
PageRunSimulation(NetlistSimulatorController *controller, QWidget *parent=nullptr)
virtual bool validatePage() override
void handleEngineFinished(bool success)
void onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
PageSelectGates(NetlistSimulatorController *controller, QWidget *parent=nullptr)
std::vector< Gate * > selectedGates() const
virtual bool validatePage() override
GuiPluginTable * mGuiPluginTable
The SaleaeDirectory class provides the API for the SALEAE directory file. The SALEAE directory file w...
int get_datafile_index(const std::string &nam, uint32_t id) const
Get waveform datafile index for net identified by name and id.
void clearAll()
Remove all files and reset internal variables.
The SaleaeDirectoryStoreRequest class is useful to bundle requests for updating SALEAE directory....
const QSet< u32 > & selectedNets() const
const QSet< u32 > & selectedGates() const
const QSet< u32 > & selectedModules() const
static SimulationEngineFactories * instance()
static QString sLogFilename
void handleLog(const QString &txt) override
SimulationProcessOutput(QWidget *parent, QLayout *layout)
QMap< QString, QString > engineProperties() const
void setEngineProperties(const QMap< QString, QString > &engProp)
SaleaeDirectory & saleaeDirectory()
QMap< WaveSelectionEntry, int > entryMap(const QList< QModelIndex > &indexes) const
void setEntryMap(const QMap< WaveSelectionEntry, int > &entries)
void loadWaveData(const QString &saleaDirectoryFile)
void generateSimulationInput(const QString &workdir)
void setup(const std::vector< NetlistSimulatorController::InputColumnHeader > &inpColHeads, bool omitClock)
void setDisplayHexValues(bool hex)
qulonglong maxTime() const
Wizard(SimulationSettings *settings, NetlistSimulatorController *controller, WaveWidget *parent)
int mPageEnginePropertiesId
#define log_info(channel,...)
#define log_warning(channel,...)
bool save(std::filesystem::path file_path, GateLibrary *gate_lib, bool overwrite=false)
QIcon getStyledSvgIcon(const QString &from_to_colors_enabled, const QString &svg_path, QString from_to_colors_disabled=QString())
PluginRelay * gPluginRelay
SelectionRelay * gSelectionRelay
virtual int columnCount(const QModelIndex &parent) const const=0
virtual QVariant data(const QModelIndex &index, int role) const const=0
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
virtual int rowCount(const QModelIndex &parent) const const=0
QAbstractItemModel * model() const const
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
QItemSelectionModel * selectionModel() const const
void addLayout(QLayout *layout, int stretch)
void addSpacing(int size)
void addStretch(int stretch)
virtual int count() const const override
virtual QLayoutItem * itemAt(int index) const const override
void setCheckState(Qt::CheckState state)
void stateChanged(int state)
void addItem(const QString &text, const QVariant &userData)
void addItems(const QStringList &texts)
void setCurrentIndex(int index)
void currentTextChanged(const QString &text)
void setEditable(bool editable)
int findText(const QString &text, Qt::MatchFlags flags) const const
void insertItem(int index, const QString &text, const QVariant &userData)
QString absoluteFilePath(const QString &fileName) const const
virtual bool open(QIODevice::OpenMode mode) override
void setFileName(const QString &name)
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QString absolutePath() const const
bool exists() const const
bool isFile() const const
void setFrameStyle(int style)
void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) const const
bool hasSelection() const const
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
QModelIndexList selectedRows(int column) const const
void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void setText(const QString &)
void textChanged(const QString &text)
void append(const T &value)
bool isEmpty() const const
QMap::const_iterator constBegin() const const
QMap::const_iterator constEnd() const const
QMessageBox::StandardButton warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
bool blockSignals(bool block)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
QObject * sender() const const
QString tr(const char *sourceText, const char *disambiguation, int n)
bool contains(const T &value) const const
QSet::iterator insert(const T &value)
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const const override
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString fromStdString(const std::string &str)
QString fromUtf8(const char *str, int size)
bool isEmpty() const const
QString number(int n, int base)
QString toLower() const const
std::string toStdString() const const
QString toUpper() const const
QString trimmed() const const
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
void sortByColumn(int column)
void resizeColumnsToContents()
void setColumnWidth(int column, int width)
virtual void setModel(QAbstractItemModel *model) override
void setSortingEnabled(bool enable)
QString text() const const
void setHtml(const QString &text)
void insertHtml(const QString &text)
void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode)
uint toUInt(bool *ok) const const
int addPage(QWizardPage *page)
virtual int nextId() const const
void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap)
void setSubTitle(const QString &subTitle)
void setTitle(const QString &title)