Skip to content

Commit

Permalink
When user run 'Clean' simulation action, perform clean step for simul…
Browse files Browse the repository at this point in the history
…ation only.
  • Loading branch information
KochynVolodymyr committed Aug 28, 2023
1 parent 653f3a3 commit 9a2fcc7
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Compiler/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,12 @@ void TaskManager::resetTask(Task *t) {

QVector<Task *> TaskManager::getDownstreamCleanTasks(Task *t) const {
QVector<Task *> tasks;
for (auto task : m_taskQueue) {
if ((task->cleanTask() == t) && isSimulation(task)) {
tasks.append(t);
return tasks;
}
}
for (auto it{m_taskQueue.rbegin()}; it != m_taskQueue.rend(); ++it) {
if ((*it)->type() == TaskType::Clean) tasks.append(*it);
if (*it == t) break;
Expand Down
14 changes: 8 additions & 6 deletions src/Compiler/TaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ class TaskManager : public QObject {
static bool isSimulation(const Task *const task);
void setDialogProvider(const DialogProvider *const dProvider);

/*!
* \brief getDownstreamClearTasks
* \return vector of clean tasks in reverse order. Vector includes \param t.
* If \param t is simulation clean, return only this task since simulation
* doesn't trigger clean for downstream.
*/
QVector<Task *> getDownstreamCleanTasks(Task *t) const;

signals:
/*!
* \brief taskStateChanged. Emits whenever any task change its status.
Expand Down Expand Up @@ -134,12 +142,6 @@ class TaskManager : public QObject {
void cleanDownStreamStatus(Task *t);
void appendTask(Task *t);
void resetTask(Task *t);

/*!
* \brief getDownstreamClearTasks
* \return vector of clean tasks in reverse order. Vector includes \param t.
*/
QVector<Task *> getDownstreamCleanTasks(Task *t) const;
void registerReportManager(uint type, AbstractReportManager *manager);

private:
Expand Down
1 change: 1 addition & 0 deletions tests/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ set(CPP_LIST
DeviceModeling/rs_parameter_test.cpp
DeviceModeling/device_signal_test.cpp
DeviceModeling/device_net_test.cpp
Compiler/TaskManager_test.cpp
)
set(H_LIST
PinAssignment/TestLoader.h
Expand Down
70 changes: 70 additions & 0 deletions tests/unittest/Compiler/TaskManager_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2022 The Foedag team
GPL License
Copyright (c) 2022 The Open-Source FPGA Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "Compiler/TaskManager.h"

#include "Compiler/Compiler.h"
#include "Compiler/CompilerDefines.h"
#include "gtest/gtest.h"

using namespace FOEDAG;

TEST(TaskManager, getDownstreamCleanTasks) {
TaskManager taskManager{nullptr};

taskManager.task(SIMULATE_RTL)
->setCustomData({CustomDataType::Sim,
QVariant::fromValue(Simulator::SimulationType::RTL)});
taskManager.task(SIMULATE_PNR)
->setCustomData({CustomDataType::Sim,
QVariant::fromValue(Simulator::SimulationType::PNR)});
taskManager.task(SIMULATE_GATE)
->setCustomData({CustomDataType::Sim,
QVariant::fromValue(Simulator::SimulationType::Gate)});
taskManager.task(SIMULATE_BITSTREAM)
->setCustomData(
{CustomDataType::Sim,
QVariant::fromValue(Simulator::SimulationType::BitstreamBackDoor)});

auto simulationRtl = taskManager.task(SIMULATE_RTL_CLEAN);
auto cleanTasks = taskManager.getDownstreamCleanTasks(simulationRtl);
EXPECT_EQ(cleanTasks.count(), 1);
EXPECT_EQ(cleanTasks.at(0), simulationRtl);

auto simulationGate = taskManager.task(SIMULATE_GATE_CLEAN);
cleanTasks = taskManager.getDownstreamCleanTasks(simulationGate);
EXPECT_EQ(cleanTasks.count(), 1);
EXPECT_EQ(cleanTasks.at(0), simulationGate);

auto simulationPnr = taskManager.task(SIMULATE_PNR_CLEAN);
cleanTasks = taskManager.getDownstreamCleanTasks(simulationPnr);
EXPECT_EQ(cleanTasks.count(), 1);
EXPECT_EQ(cleanTasks.at(0), simulationPnr);

auto simulationBitstream = taskManager.task(SIMULATE_BITSTREAM_CLEAN);
cleanTasks = taskManager.getDownstreamCleanTasks(simulationBitstream);
EXPECT_EQ(cleanTasks.count(), 1);
EXPECT_EQ(cleanTasks.at(0), simulationBitstream);

auto analysis = taskManager.task(ANALYSIS_CLEAN);
cleanTasks = taskManager.getDownstreamCleanTasks(analysis);
EXPECT_EQ(cleanTasks.count(), 12);
}

0 comments on commit 9a2fcc7

Please sign in to comment.