Skip to content

Commit 78b7cf1

Browse files
committed
Added simulate_only_probes() method which disposes all other simulation results
1 parent 84c5556 commit 78b7cf1

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

plugins/generate_hre_task/src/plugin_generate_hre_task.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ namespace hal
108108
break;
109109
}
110110

111+
std::vector<const Net*> probes;
112+
for (u32 id : {3, 4, 5, 14, 18, 15}) // input, output, internal probe 15
113+
probes.push_back(m_original_netlist.get()->get_net_by_id(id));
114+
m_simul_controller.get()->simulate_only_probes(probes);
115+
111116
m_simul_controller.get()->emit_run_simulation();
112117
return true;
113118
}

plugins/simulator/netlist_simulator_controller/include/netlist_simulator_controller/netlist_simulator_controller.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,18 @@ class NETLIST_API NetlistSimulatorController : public QObject {
453453
*/
454454
bool can_import_data() const;
455455

456+
/**
457+
* Discard all results except listed probes
458+
* @param probes List of nets which will be simulated (aka probes)
459+
*/
460+
void simulate_only_probes(const std::vector<const Net*>& probes);
461+
462+
/**
463+
* Discard all results except listed probes
464+
* @param probes Set of net IDs which will be simulated (aka probes)
465+
*/
466+
void simulate_only_probes(const QSet<u32>& probes);
467+
456468
/**
457469
* Store significant information into working directory
458470
* @return True if JSON file created successfully, false otherwise.
@@ -497,6 +509,8 @@ public Q_SLOTS:
497509

498510
SimulationInput* mSimulationInput;
499511

512+
QSet<u32> mSimulateOnlyProbes;
513+
500514
QHash<u32,int> mBadAssignInputWarnings;
501515
};
502516

plugins/simulator/netlist_simulator_controller/src/netlist_simulator_controller.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ namespace hal
254254
checkReadyState();
255255
}
256256

257+
void NetlistSimulatorController::simulate_only_probes(const std::vector<const Net*>& probes)
258+
{
259+
for (const Net* n : probes)
260+
mSimulateOnlyProbes.insert(n->get_id());
261+
}
262+
263+
void NetlistSimulatorController::simulate_only_probes(const QSet<u32>& probes)
264+
{
265+
mSimulateOnlyProbes = probes;
266+
}
267+
257268
u32 NetlistSimulatorController::add_trigger_time(const std::vector<WaveData*>& trigger_waves, const std::vector<int>& trigger_on_values)
258269
{
259270
if (trigger_waves.empty())
@@ -823,21 +834,29 @@ namespace hal
823834
std::filesystem::path resultFile = mSimulationEngine->get_result_filename();
824835
if (resultFile.is_relative())
825836
resultFile = get_working_directory() / resultFile;
826-
VcdSerializer reader(mWorkDir, this);
837+
VcdSerializer reader(mWorkDir, false, this);
827838
QFileInfo info(QString::fromStdString(resultFile.string()));
828839
if (!info.exists() || !info.isReadable())
829840
return false;
830841

831842
QList<const Net*> partialNets;
843+
832844
for (const Net* n : get_partial_netlist_nets())
845+
{
846+
if (!mSimulateOnlyProbes.empty() && !mSimulateOnlyProbes.contains(n->get_id()))
847+
continue;
833848
partialNets.append(n);
849+
}
834850

835851
if (reader.importVcd(QString::fromStdString(resultFile), mWorkDir, partialNets))
836852
{
837853
mWaveDataList->updateFromSaleae();
838854
}
839855
else
840856
return false;
857+
858+
if (!mSimulateOnlyProbes.isEmpty())
859+
QFile::remove(QString::fromStdString(resultFile.string()));
841860
}
842861
return true;
843862
}

0 commit comments

Comments
 (0)