Skip to content

Commit

Permalink
Merge branch 'develop' into 375-qaction-new-project-is-not-active-aft…
Browse files Browse the repository at this point in the history
…er-we-create-the-new-project
  • Loading branch information
coolbreeze413 committed Sep 26, 2023
2 parents 146e0db + ee0774d commit f2f4640
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 58 deletions.
23 changes: 13 additions & 10 deletions src/Compiler/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,11 @@ bool Compiler::RegisterCommands(TclInterpreter* interp, bool batchMode) {
compiler->Message(std::string("Reading ") + actualType + " " +
expandedFile + std::string("\n"));
std::ostringstream out;
bool isFileCopy = true;
bool localToProject = true;
if(compiler->copyFilesOnAdd() == false) {
isFileCopy = false;
localToProject = false;
bool isFileCopy = false;
bool localToProject = false;
if(compiler->copyFilesOnAdd() == true) {
isFileCopy = true;
localToProject = true;
}
bool ok = compiler->m_tclCmdIntegration->TclAddDesignFiles(
{}, {}, origPathFileList.c_str(), language, isFileCopy, localToProject, out);
Expand Down Expand Up @@ -2737,6 +2737,9 @@ int Compiler::add_files(Compiler* compiler, Tcl_Interp* interp, int argc,
} else if (type == "-CPP") {
language = Design::Language::CPP;
actualType = "C++";
} else if (type == "-OTHER") {
language = Design::Language::OTHER;
actualType = "OTHER";
} else if (type.find("-D") != std::string::npos) {
fileList += type + " ";
} else {
Expand Down Expand Up @@ -2795,11 +2798,11 @@ int Compiler::add_files(Compiler* compiler, Tcl_Interp* interp, int argc,
bool ok{true};
// check additionally, if user *does not* want to copy files from TCL script path to project dir?
// user can set this using: `copy_files_on_add off` in the TCL script
bool isFileCopy = true;
bool localToProject = true;
if(compiler->copyFilesOnAdd() == false) {
isFileCopy = false;
localToProject = false;
bool isFileCopy = false;
bool localToProject = false;
if(compiler->copyFilesOnAdd() == true) {
isFileCopy = true;
localToProject = true;
}
if (filesType == Design) {
ok = compiler->m_tclCmdIntegration->TclAddDesignFiles(
Expand Down
7 changes: 4 additions & 3 deletions src/Compiler/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ class Compiler {
std::string m_output;
bool m_useVerific = false;
// on calling 'add_file' from TCL, should we copy them into the project dir?
// default is set to true, so they will be copied unless user does not want this.
// call set
bool m_copyFilesWhileAdding = true;
// default is set to false, so they will be copied only when user want to do this.
// call 'copy_files_on_add on' to enable this feature.
// this will apply to all file types as of now.
bool m_copyFilesWhileAdding = false;

// Tasks generic options
IPGenerateOpt m_ipGenerateOpt = IPGenerateOpt::None;
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/CompilerDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ FOEDAG::Design::Language FOEDAG::FromFileType(const QString &type,
if (QtUtils::IsEqual(type, "c") || QtUtils::IsEqual(type, "cc"))
return Design::Language::C;
if (QtUtils::IsEqual(type, "cpp")) return Design::Language::CPP;
if (QtUtils::IsEqual(type, "txt")) return Design::Language::OTHER;
return postSynth ? Design::Language::VERILOG_NETLIST
: Design::Language::VERILOG_2001;
: Design::Language::OTHER;
}

int FOEDAG::read_sdc(const QString &file) {
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/CompilerDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum Language {
C,
CPP,
VHDL_2019,
EDIF
EDIF,
OTHER
};
} // namespace Design

Expand Down
58 changes: 29 additions & 29 deletions src/Compiler/CompilerOpenFPGA_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void CompilerOpenFPGA_ql::Help(std::ostream* out) {
(*out) << " --verific : Uses Verific parser" << std::endl;
(*out) << "Tcl commands:" << std::endl;
(*out) << " help : This help" << std::endl;
(*out) << " copy_files_on_add <on/off> : sets whether to copy all the "
"design files into the generated project directory"
<< std::endl;
(*out) << " create_design <name> ?-type <project type>? : Creates a design "
"with <name> name"
<< std::endl;
Expand Down Expand Up @@ -1646,34 +1649,22 @@ bool CompilerOpenFPGA_ql::RegisterCommands(TclInterpreter* interp,
auto list_devices = [](void* clientData, Tcl_Interp* interp, int argc,
const char* argv[]) -> int {

#if 0
CompilerOpenFPGA_ql* compiler = (CompilerOpenFPGA_ql*)clientData;


std::vector<std::string> device_list = compiler->ListDevices();

// save std::ios settings.
std::ios ios_default_state(nullptr);
ios_default_state.copyfmt(std::cout);

std::cout << std::endl;
std::cout << "devices available:" << std::endl;
std::cout << "<family>,<foundry>,<node>,[voltage_threshold],[p_v_t_corner]" << std::endl;
int index = 1;
for (auto device_variant: device_list) {
std::cout << std::setw(4)
<< std::setfill(' ')
<< index;
// restore cout state
std::cout.copyfmt(ios_default_state);
std::cout << ". "
<< device_variant
<< std::endl;
index++;
}
std::cout << std::endl;
#endif
return TCL_OK;
std::vector <QLDeviceType>device_list = QLDeviceManager::getInstance(true)->device_list;

for (QLDeviceType device: device_list) {
for (QLDeviceVariant device_variant: device.device_variants) {
for (QLDeviceVariantLayout device_variant_layout: device_variant.device_variant_layouts) {
std::cout << device_variant.family << ","
<< device_variant.foundry << ","
<< device_variant.node << ","
<< device_variant.voltage_threshold << ","
<< device_variant.p_v_t_corner << ","
<< device_variant_layout.name << std::endl;
}
}
}

return TCL_OK;
};
interp->registerCmd("list_devices", list_devices, this, 0);

Expand Down Expand Up @@ -2190,6 +2181,9 @@ std::string CompilerOpenFPGA_ql::InitAnalyzeScript() {
lang = "BLIF";
ErrorMessage("Unsupported file format:" + lang);
return "";
case Design::Language::OTHER:
// don't include it in the compilation process
continue;
}
if (filesIndex < commandsLibs.size()) {
const auto& filesCommandsLibs = commandsLibs[filesIndex];
Expand Down Expand Up @@ -2569,6 +2563,9 @@ bool CompilerOpenFPGA_ql::Synthesize() {
lang = "BLIF";
ErrorMessage("Unsupported file format:" + lang);
return false;
case Design::Language::OTHER:
// don't include it in the compilation process
continue;
}
if (filesIndex < commandsLibs.size()) {
const auto& filesCommandsLibs = commandsLibs[filesIndex];
Expand Down Expand Up @@ -2656,8 +2653,11 @@ bool CompilerOpenFPGA_ql::Synthesize() {
case Design::Language::EBLIF:
ErrorMessage("Unsupported language (Yosys default parser)");
break;
case Design::Language::OTHER:
// don't include it in the compilation process
continue;
}
std::string options = lang;
std::string options = lang;
options += " -nolatches";
filesScript = ReplaceAll(filesScript, "${READ_VERILOG_OPTIONS}", options);
filesScript = ReplaceAll(filesScript, "${INCLUDE_PATHS}", includes);
Expand Down
35 changes: 30 additions & 5 deletions src/Compiler/QLDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,18 @@ QWidget* QLDeviceManager::createDeviceSelectionWidget(bool newProjectMode) {
m_combobox_layout->setSizeAdjustPolicy(QComboBox::AdjustToContents);

families.clear();
singularity.clear();
m_combobox_family->clear();
for (QLDeviceType device: this->device_list) {
families.push_back(device.family);
// ensure that the item being added has not been added before using std::set
// for performance reasons, keeping a vector as final container for future need of sorting.
if(singularity.insert(device.family).second == true) {
families.push_back(device.family);
}
}

for (std::string family: families) {
m_combobox_family->addItem(QString::fromStdString(family));
m_combobox_family->addItem(QString::fromStdString(family));
}

// connect( m_combobox_family, SIGNAL(currentTextChanged(const QString&)), this, SLOT(familyChanged(const QString&)) );
Expand Down Expand Up @@ -396,6 +401,7 @@ void QLDeviceManager::familyChanged(const QString& family_qstring)

// std::cout << "familychanged: " << family_qstring.toStdString() << std::endl;
foundrynodes.clear();
singularity.clear();
m_combobox_foundry_node->blockSignals(true);
m_combobox_foundry_node->clear();

Expand All @@ -405,7 +411,11 @@ void QLDeviceManager::familyChanged(const QString& family_qstring)
if(device.family == family) {

std::string _foundrynode = convertToFoundryNode(device.foundry, device.node);
foundrynodes.push_back(_foundrynode);
// ensure that the item being added has not been added before using std::set
// for performance reasons, keeping a vector as final container for future need of sorting.
if(singularity.insert(_foundrynode).second == true) {
foundrynodes.push_back(_foundrynode);
}
}
}

Expand Down Expand Up @@ -444,6 +454,7 @@ void QLDeviceManager::foundrynodeChanged(const QString& foundrynode_qstring)
foundry = foundrynode_vector[0];
node = foundrynode_vector[1];
voltage_thresholds.clear();
singularity.clear();
m_combobox_voltage_threshold->blockSignals(true);
m_combobox_voltage_threshold->clear();

Expand All @@ -452,7 +463,11 @@ void QLDeviceManager::foundrynodeChanged(const QString& foundrynode_qstring)
std::string _foundrynode = convertToFoundryNode(device.foundry, device.node);
if (_foundrynode == foundrynode) {
for (QLDeviceVariant variant : device.device_variants) {
// ensure that the item being added has not been added before using std::set
// for performance reasons, keeping a vector as final container for future need of sorting.
if(singularity.insert(variant.voltage_threshold).second == true) {
voltage_thresholds.push_back(variant.voltage_threshold);
}
}
}
}
Expand Down Expand Up @@ -485,6 +500,7 @@ void QLDeviceManager::voltage_thresholdChanged(const QString& voltage_threshold_

voltage_threshold = voltage_threshold_qstring.toStdString();
p_v_t_corners.clear();
singularity.clear();
m_combobox_p_v_t_corner->blockSignals(true);
m_combobox_p_v_t_corner->clear();

Expand All @@ -494,7 +510,11 @@ void QLDeviceManager::voltage_thresholdChanged(const QString& voltage_threshold_
if (_foundrynode == foundrynode) {
for (QLDeviceVariant variant : device.device_variants) {
if (variant.voltage_threshold == voltage_threshold) {
p_v_t_corners.push_back(variant.p_v_t_corner);
// ensure that the item being added has not been added before using std::set
// for performance reasons, keeping a vector as final container for future need of sorting.
if(singularity.insert(variant.p_v_t_corner).second == true) {
p_v_t_corners.push_back(variant.p_v_t_corner);
}
}
}
}
Expand Down Expand Up @@ -528,6 +548,7 @@ void QLDeviceManager::p_v_t_cornerChanged(const QString& p_v_t_corner_qstring)

p_v_t_corner = p_v_t_corner_qstring.toStdString();
layouts.clear();
singularity.clear();
m_combobox_layout->blockSignals(true);
m_combobox_layout->clear();

Expand All @@ -539,7 +560,11 @@ void QLDeviceManager::p_v_t_cornerChanged(const QString& p_v_t_corner_qstring)
if (variant.voltage_threshold == voltage_threshold) {
if(variant.p_v_t_corner == p_v_t_corner) {
for(QLDeviceVariantLayout _layout : variant.device_variant_layouts) {
layouts.push_back(_layout.name);
// ensure that the item being added has not been added before using std::set
// for performance reasons, keeping a vector as final container for future need of sorting.
if(singularity.insert(_layout.name).second == true) {
layouts.push_back(_layout.name);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/QLDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class QLDeviceManager : public QObject {
std::string p_v_t_corner;
std::vector <std::string> layouts;
std::string layout;
std::set <std::string> singularity;

QComboBox* m_combobox_family;
QComboBox* m_combobox_foundry_node;
Expand Down
38 changes: 38 additions & 0 deletions src/Compiler/QLSettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ void QLSettingsManager::parseSDCFilePath() {
}
}



// final: check if we have a valid sdc file path:
if(!sdc_file_path_absolute.empty()) {
// assign the absolute path to the sdc_file_path variable:
Expand Down Expand Up @@ -371,6 +373,28 @@ std::filesystem::path QLSettingsManager::getTCLScriptDirPath() {
}


std::filesystem::path QLSettingsManager::getCurrentDirPath() {

std::filesystem::path current_dir_path_c;

std::error_code ec;

current_dir_path_c = std::filesystem::canonical(".", ec);

if(!ec) {
// path exists, and can be used
}
else {
// no tcl script was used.
current_dir_path_c.clear();
}

// std::cout << "current_dir_path_c() : " << current_dir_path_c.string() << std::endl;

return current_dir_path_c;
}


QWidget* QLSettingsManager::createSettingsWidget(bool newProjectMode) {

// whenever a new GUI Widget is created, we mark the mode of operation of this widget:
Expand Down Expand Up @@ -1279,6 +1303,13 @@ void QLSettingsManager::parseJSONSettings() {
}
}

// 4. convert to canonical path:
// if(!settings_json_filepath.empty()) {
// std::error_code ec;
// settings_json_filepath = std::filesystem::canonical(settings_json_filepath, ec);
// if(!ec) settings_json_filepath.clear();
// }

// final: check we have a valid settings json:
if(!settings_json_filepath.empty()) {
try {
Expand Down Expand Up @@ -1329,6 +1360,13 @@ void QLSettingsManager::parseJSONSettings() {
}
}

// 4. convert to canonical path:
// if(!power_estimation_json_filepath.empty()) {
// std::error_code ec;
// power_estimation_json_filepath = std::filesystem::canonical(power_estimation_json_filepath, ec);
// if(!ec) power_estimation_json_filepath.clear();
// }

// final: check we have a valid settings json:
if(!power_estimation_json_filepath.empty()) {
try {
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/QLSettingsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class QLSettingsManager : public QObject {
static const json* getJson(std::string category);
static std::filesystem::path getSDCFilePath();
static std::filesystem::path getTCLScriptDirPath();
static std::filesystem::path getCurrentDirPath();

~QLSettingsManager();

Expand Down
Loading

0 comments on commit f2f4640

Please sign in to comment.