Skip to content

Commit

Permalink
Merge branch 'develop' into synplify-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbreeze413 committed Oct 23, 2024
2 parents 1271c71 + 5622a71 commit 546be59
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 76 deletions.
46 changes: 15 additions & 31 deletions src/Compiler/CompilerOpenFPGA_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
};
interp->registerCmd("verific_parser", verific_parser, this, 0);

#if UPSTREAM_UNUSED
auto target_device = [](void* clientData, Tcl_Interp* interp, int argc,
const char* argv[]) -> int {
CompilerOpenFPGA_ql* compiler = (CompilerOpenFPGA_ql*)clientData;
Expand All @@ -695,6 +696,7 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
return TCL_OK;
};
interp->registerCmd("target_device", target_device, this, 0);
#endif // #if UPSTREAM_UNUSED

auto synthesis_type = [](void* clientData, Tcl_Interp* interp, int argc,
const char* argv[]) -> int {
Expand Down Expand Up @@ -844,6 +846,7 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
};
interp->registerCmd("encrypt_device", encrypt_device, this, 0);

#if AURORA_DEPRECATED
auto generate_fpga_io_map = [](void* clientData, Tcl_Interp* interp, int argc,
const char* argv[]) -> int {

Expand Down Expand Up @@ -974,7 +977,7 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
// we can work with vpr.xml or vpr.xml.en files
std::string vpr_xml_pattern = "vpr\\.xml.*";
std::filesystem::path device_data_dir_path =
std::filesystem::path(compiler->GetSession()->Context()->DataPath() /
std::filesystem::path(QLDeviceManager::getInstance()->deviceDataRootDirPath() /
family /
foundry /
node);
Expand Down Expand Up @@ -1370,6 +1373,7 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
return TCL_OK;
};
interp->registerCmd("generate_fpga_io_map", generate_fpga_io_map, this, 0);
#endif // #if AURORA_DEPRECATED

auto list_devices = [](void* clientData, Tcl_Interp* interp, int argc,
const char* argv[]) -> int {
Expand Down Expand Up @@ -3158,13 +3162,13 @@ std::string CompilerOpenFPGA_ql::BaseVprCommand() {
}

if( QLSettingsManager::getStringValue("vpr", "route", "flat_routing") == "checked" ) {
vpr_options += std::string(" --flat_routing true");
vpr_options += std::string(" --flat_routing on");
// if flat_routing is enabled, increase maximum router iterations to give flat router enough
// time to converage to a legal routing solution
vpr_options += std::string(" --max_router_iterations 100");
}
else if( QLSettingsManager::getStringValue("vpr", "route", "flat_routing") == "unchecked" ) {
vpr_options += std::string(" --flat_routing false");
vpr_options += std::string(" --flat_routing off");
}

// parse vpr analysis options
Expand Down Expand Up @@ -3251,12 +3255,6 @@ std::string CompilerOpenFPGA_ql::BaseVprCommand() {

QLDeviceTarget device_target = QLDeviceManager::getInstance()->getCurrentDeviceTarget();

std::filesystem::path device_type_dir_path =
std::filesystem::path(GetSession()->Context()->DataPath() /
device_target.device_variant.family /
device_target.device_variant.foundry /
device_target.device_variant.node);

m_architectureFile =
QLDeviceManager::getInstance()->deviceVPRArchitectureFile();
if(m_architectureFile.empty()) {
Expand All @@ -3271,7 +3269,7 @@ std::string CompilerOpenFPGA_ql::BaseVprCommand() {
m_architectureFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -4649,21 +4647,6 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)

QLDeviceTarget device_target = QLDeviceManager::getInstance()->getCurrentDeviceTarget();

std::filesystem::path device_type_dir_path =
std::filesystem::path(GetSession()->Context()->DataPath() /
device_target.device_variant.family /
device_target.device_variant.foundry /
device_target.device_variant.node);

std::filesystem::path device_variant_dir_path =
std::filesystem::path(GetSession()->Context()->DataPath() /
device_target.device_variant.family /
device_target.device_variant.foundry /
device_target.device_variant.node /
device_target.device_variant.voltage_threshold /
device_target.device_variant.p_v_t_corner);


std::error_code ec;


Expand All @@ -4682,7 +4665,7 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)
m_OpenFpgaArchitectureFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -4718,7 +4701,7 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)
m_OpenFpgaBitstreamSettingFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -4754,7 +4737,7 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)
m_OpenFpgaRepackConstraintsFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -4790,7 +4773,7 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)
m_OpenFpgaSimSettingFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -4823,7 +4806,7 @@ std::string CompilerOpenFPGA_ql::FinishOpenFPGAScript(const std::string& script)
m_OpenFpgaFabricKeyFile = GenerateTempFilePath();

m_cryptdbPath =
CRFileCryptProc::getInstance()->getCryptDBFileName(device_type_dir_path.string(),
CRFileCryptProc::getInstance()->getCryptDBFileName((QLDeviceManager::getInstance()->deviceTypeDirPath()).string(),
device_target.device_variant.family +
"_" +
device_target.device_variant.foundry +
Expand Down Expand Up @@ -5486,6 +5469,7 @@ bool CompilerOpenFPGA_ql::GeneratePinConstraints(std::string& filepath_fpga_fix_

bool CompilerOpenFPGA_ql::LoadDeviceData(const std::string& deviceName) {
bool status = true;
#if UPSTREAM_UNUSED
std::filesystem::path datapath = GetSession()->Context()->DataPath();
std::filesystem::path devicefile =
datapath / std::string("etc") / std::string("device.xml");
Expand Down Expand Up @@ -5619,7 +5603,7 @@ bool CompilerOpenFPGA_ql::LoadDeviceData(const std::string& deviceName) {
ErrorMessage("Incorrect device: " + deviceName + "\n");
status = false;
}
#if UPSTREAM_UNUSED

if (!LicenseDevice(deviceName)) {
ErrorMessage("Device is not licensed: " + deviceName + "\n");
status = false;
Expand Down
51 changes: 41 additions & 10 deletions src/Compiler/QLDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ void QLDeviceManager::parseDeviceData() {

// get to the device_data dir path of the installation
std::filesystem::path root_device_data_dir_path =
GlobalSession->Context()->DataPath();
deviceDataRootDirPath();

// clear the list before parsing
device_list.clear();
Expand Down Expand Up @@ -975,7 +975,7 @@ std::vector<QLDeviceVariant> QLDeviceManager::listDeviceVariants(

// get to the device_data dir path of the installation
std::filesystem::path root_device_data_dir_path =
GlobalSession->Context()->DataPath();
deviceDataRootDirPath();

// calculate the device_data dir path for specified device
std::filesystem::path device_data_dir_path = root_device_data_dir_path / family / foundry / node;
Expand Down Expand Up @@ -1189,7 +1189,7 @@ std::vector<QLDeviceVariantLayout> QLDeviceManager::listDeviceVariantLayouts(std
std::vector<QLDeviceVariantLayout> device_variant_layouts = {};

std::filesystem::path root_device_data_dir_path =
GlobalSession->Context()->DataPath();
deviceDataRootDirPath();

std::filesystem::path device_data_dir_path = root_device_data_dir_path / family / foundry / node;

Expand Down Expand Up @@ -1483,13 +1483,13 @@ std::filesystem::path QLDeviceManager::GetArchitectureFileForDeviceVariant(const
{
std::filesystem::path architectureFile;
std::filesystem::path device_type_dir_path =
std::filesystem::path(GlobalSession->Context()->DataPath() /
std::filesystem::path(deviceDataRootDirPath() /
device_variant.family /
device_variant.foundry /
device_variant.node);

std::filesystem::path device_variant_dir_path =
std::filesystem::path(GlobalSession->Context()->DataPath() /
std::filesystem::path(deviceDataRootDirPath() /
device_variant.family /
device_variant.foundry /
device_variant.node /
Expand Down Expand Up @@ -2101,7 +2101,7 @@ int QLDeviceManager::addDevice(std::string family, std::string foundry, std::str
// [1] check if installation already has the device added and inform the user accordingly.
// (device data dir for this device already exists)
std::filesystem::path target_device_data_dir_path =
std::filesystem::path(compiler->GetSession()->Context()->DataPath() /
std::filesystem::path(deviceDataRootDirPath() /
family /
foundry /
node);
Expand Down Expand Up @@ -2147,6 +2147,37 @@ int QLDeviceManager::addDevice(std::string family, std::string foundry, std::str
}


std::filesystem::path QLDeviceManager::deviceDataRootDirPath() {

std::filesystem::path root_device_data_dir_path;

// allow user to override the root device data path using an env variable.
// read env var
const char* const path_device_data_env_str = std::getenv("AURORA2_DEVICE_DATA_DIR"); // this is from setup.sh

if (path_device_data_env_str != nullptr) {

// convert to std::filesystem::path and check if the path exists
root_device_data_dir_path = std::string(path_device_data_env_str);

if(!FileUtils::FileExists(root_device_data_dir_path)) {

root_device_data_dir_path.clear();
}
}

// if we did not get the path from the env var
if(root_device_data_dir_path.empty()) {

// use the device_data dir path of the installation
root_device_data_dir_path =
GlobalSession->Context()->DataPath();
}

return root_device_data_dir_path;
}


bool QLDeviceManager::deviceFileIsEncrypted(std::filesystem::path filepath) {

if(filepath.extension() == ".en") {
Expand All @@ -2161,7 +2192,7 @@ bool QLDeviceManager::deviceFileIsEncrypted(std::filesystem::path filepath) {

std::filesystem::path QLDeviceManager::deviceTypeDirPath(QLDeviceTarget device_target) {

CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());
// CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());

std::filesystem::path device_type_dir_path;

Expand All @@ -2170,7 +2201,7 @@ std::filesystem::path QLDeviceManager::deviceTypeDirPath(QLDeviceTarget device_t
}

device_type_dir_path =
std::filesystem::path(compiler->GetSession()->Context()->DataPath() /
std::filesystem::path(deviceDataRootDirPath() /
device_target.device_variant.family /
device_target.device_variant.foundry /
device_target.device_variant.node);
Expand All @@ -2181,7 +2212,7 @@ std::filesystem::path QLDeviceManager::deviceTypeDirPath(QLDeviceTarget device_t

std::filesystem::path QLDeviceManager::deviceVariantDirPath(QLDeviceTarget device_target) {

CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());
// CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());

std::filesystem::path device_variant_dir_path;

Expand All @@ -2190,7 +2221,7 @@ std::filesystem::path QLDeviceManager::deviceVariantDirPath(QLDeviceTarget devic
}

device_variant_dir_path =
std::filesystem::path(compiler->GetSession()->Context()->DataPath() /
std::filesystem::path(deviceDataRootDirPath() /
device_target.device_variant.family /
device_target.device_variant.foundry /
device_target.device_variant.node /
Expand Down
4 changes: 3 additions & 1 deletion src/Compiler/QLDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class QLDeviceManager : public QObject {
// device files access API to have a uniform way of getting the required files
public:

bool deviceFileIsEncrypted(std::filesystem::path);
std::filesystem::path deviceDataRootDirPath();

bool deviceFileIsEncrypted(std::filesystem::path filepath);

std::filesystem::path deviceTypeDirPath(QLDeviceTarget device_target = QLDeviceTarget());
std::filesystem::path deviceVariantDirPath(QLDeviceTarget device_target = QLDeviceTarget());
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/QLSettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ void QLSettingsManager::updateJSONSettingsForDeviceTarget(QLDeviceTarget device_
// and we have to 'reset' the settings from the template JSON for the new device-type

std::filesystem::path root_device_data_dir_path =
GlobalSession->Context()->DataPath();
QLDeviceManager::getInstance()->deviceDataRootDirPath();

std::filesystem::path device_data_dir_path = root_device_data_dir_path / family_updated / foundry_updated / node_updated;

Expand Down
5 changes: 4 additions & 1 deletion src/Compiler/TaskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ class TaskManager : public QObject {
*/
void done();

void doneDetalied(uint id, TaskStatus status);
/*!
* \brief taskDone. Emits when task is done.
*/
void taskDone(uint id, TaskStatus status);

/*!
* \brief progress
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/TaskManager_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ void TaskManager::runNext(TaskStatus status) {
emit progress(counter, m_taskCount,
QString("%1 Running").arg(t->title()));
return;
} else {
emit taskDone(taskId(t), t->status());
}

QString statusStr{"Complete"};
Expand All @@ -360,7 +362,6 @@ void TaskManager::runNext(TaskStatus status) {

if (m_runStack.isEmpty()) {
emit done();
emit doneDetalied(taskId(t), t->status());
}
}

Expand Down
28 changes: 19 additions & 9 deletions src/Main/Foedag_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,26 @@ Foedag::Foedag(FOEDAG::CommandLine* cmdLine, MainWindowBuilder* mainWinBuilder,
m_context->BinaryPath(exeDirPath);
std::filesystem::path installDir = exeDirPath.parent_path();

// for generic usage (not specific to device-data) use the DataPath()
// API which will always be 'install_dir_path'/device_data/
// this is used as reference to derive other installation paths.
// for device-data specific usage, use the QLDeviceManager::getInstance()->deviceDataRootDirPath()
// API instead.

// removing this, because there are other stuff, such as scripts/ and files
// which are indirectly derived from the DataPath() API value, and these
// will break if the DataPath() is set to some path outside the Aurora installation!!
// this needs to be fixed in the future, but for now, we will leave it alone.
// [1] prefer to take the datapath from environment variable, if set:
if (m_context->DataPath().empty()) {
const char* const path_device_data = std::getenv("AURORA2_DEVICE_DATA_DIR"); // this is from setup.sh
if (path_device_data != nullptr) {
std::filesystem::path dataDir = std::string(path_device_data);
if(FileUtils::FileExists(dataDir)) {
m_context->DataPath(dataDir);
}
}
}
// if (m_context->DataPath().empty()) {
// const char* const path_device_data = std::getenv("AURORA2_DEVICE_DATA_DIR"); // this is from setup.sh
// if (path_device_data != nullptr) {
// std::filesystem::path dataDir = std::string(path_device_data);
// if(FileUtils::FileExists(dataDir)) {
// m_context->DataPath(dataDir);
// }
// }
// }

// [2] check convention, if we have device_data dir in the installation directory:
if (m_context->DataPath().empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/MainWindow/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MainWindow : public QMainWindow, public TopLevelInterface {
void newProjectDlg();
void openProjectDialog(const QString& dir = QString{});
void openExampleProject();
bool closeProject(bool force = false);
bool closeProject(bool force = false, bool skipWelcomePage = false);
void openFileSlot();
void openFilePath(const QString& filePath);
void newDesignCreated(const QString& design);
Expand Down
Loading

0 comments on commit 546be59

Please sign in to comment.