47 #include "config_PANDA_DATA_INSTALLDIR.hpp" 62 #define LATTICE_SLICE "LATTICE_SLICE" 63 #define LATTICE_DELAY "LATTICE_DELAY" 64 #define LATTICE_REGISTERS "LATTICE_REGISTERS" 65 #define LATTICE_IOPIN "LATTICE_IOPIN" 66 #define LATTICE_DSP "LATTICE_DSPS" 67 #define LATTICE_MEM "LATTICE_MEM" 78 if(
Param->isOption(OPT_target_device_script))
80 auto xml_file_path =
Param->getOption<std::string>(OPT_target_device_script);
81 if(!std::filesystem::exists(xml_file_path))
83 THROW_ERROR(
"File \"" + xml_file_path +
"\" does not exist!");
90 std::string device_string;
91 if(
device->has_parameter(
"family"))
93 device_string =
device->get_parameter<std::string>(
"family");
97 device_string =
"LatticeECP5";
101 THROW_ERROR(
"Device family \"" + device_string +
"\" not supported!");
104 "Importing default scripts for target device family: " + device_string);
127 for(
const auto& iter_int : list_int)
129 const auto* EnodeC = GetPointer<const xml_element>(iter_int);
135 if(EnodeC->get_name() ==
"application")
138 for(
const auto& iter_sec : list_sec)
140 const auto* nodeS = GetPointer<const xml_element>(iter_sec);
146 if(nodeS->get_name() ==
"section")
148 std::string stringID;
149 if(
CE_XVM(stringID, nodeS))
153 if(stringID ==
"LATTICE_SYNTHESIS_SUMMARY")
156 for(
const auto& it_item : list_item)
158 const auto* nodeIt = GetPointer<const xml_element>(it_item);
159 if(!nodeIt or nodeIt->get_name() !=
"item")
164 if(
CE_XVM(stringID, nodeIt))
173 boost::replace_all(value,
",",
"");
185 catch(
const char* msg)
187 std::cerr << msg << std::endl;
189 catch(
const std::string& msg)
191 std::cerr << msg << std::endl;
193 catch(
const std::exception& ex)
195 std::cout <<
"Exception caught: " << ex.what() << std::endl;
199 std::cerr <<
"unknown exception" << std::endl;
201 THROW_ERROR(
"Error during LATTICE report parsing: " + fn);
213 area_m->set_resource_value(area_info::SLICE,
design_values[LATTICE_SLICE]);
231 auto setupscr =
Param->isOption(OPT_lattice_settings) ?
Param->getOption<std::string>(OPT_lattice_settings) :
"";
232 if(setupscr.size() && setupscr !=
"0")
234 script <<
"#configuration" << std::endl;
237 script << setupscr +
" >& /dev/null; ";
241 script <<
". " << setupscr <<
" >& /dev/null; ";
243 script << std::endl << std::endl;
252 std::ofstream sdc_file(sdc_filename.c_str());
256 " [get_ports " + clock +
"]\n";
258 (
Param->IsParameter(
"profile-top") &&
Param->GetParameter<
int>(
"profile-top") == 1)) &&
259 !
Param->isOption(OPT_backend_sdc_extensions))
262 " -from [all_inputs] -to [all_outputs]\n";
269 if(
Param->isOption(OPT_backend_sdc_extensions))
271 sdc_file <<
"source " +
Param->getOption<std::string>(OPT_backend_sdc_extensions) +
"\n";
281 auto device_family =
device->get_parameter<std::string>(
"family");
282 if(device_family.find(
'-') != std::string::npos)
284 device_family = device_family.substr(0, device_family.find(
'-'));
289 const auto file_list = string_to_container<std::vector<std::filesystem::path>>(HDL_files,
";");
290 std::string sources_macro_list;
291 bool has_vhdl_library =
Param->isOption(OPT_VHDL_library);
292 std::string vhdl_library;
295 vhdl_library =
Param->getOption<std::string>(OPT_VHDL_library);
297 for(
const auto&
file : file_list)
299 const auto extension =
file.extension().string();
300 if(extension ==
".vhd" || extension ==
".vhdl" || extension ==
".VHD" || extension ==
".VHDL")
304 sources_macro_list +=
"prj_src add -format VHDL -work " + vhdl_library +
" " +
file.string() +
"\n";
308 sources_macro_list +=
"prj_src add -format VHDL " +
file.string() +
"\n";
311 else if(extension ==
".v" || extension ==
".V" || extension ==
".sv" || extension ==
".SV")
313 sources_macro_list +=
"prj_src add -format VERILOG " +
file.string() +
"\n";
317 THROW_ERROR(
"Extension not recognized! " + extension);
320 if(
Param->isOption(OPT_lattice_pmi_def))
322 sources_macro_list +=
"prj_src add -format VERILOG " +
Param->getOption<std::string>(OPT_lattice_pmi_def) +
"\n";
328 for(
auto& step :
steps)
#define PARAM_sources_macro_list
void ExecuteSynthesis() override
Checks if the execution can be performed and, in case, performs the synthesis.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
Collect information about resource area.
File containing functions and utilities to support the printing of debug messagges.
#define LATTICE_SLICE
Header include.
area_infoRef area_m
pointer to the data structure containing information about the resources
DesignParametersRef actual_parameters
set of design parameters with the actual values
Wrapper to implement a synthesis tools by Lattice.
void set_execution_time(double execution_time, unsigned int cycles=time_info::cycles_time_DEFAULT)
void InitDesignParameters() override
Initializes the parameters.
Collect information about resource performance.
#define CE_XVM(variable, node)
Check existence XML Value Macro. Check if an XML attribute is present in the XML tree.
void parse_flow(const XMLDomParserRef parser)
Creates the synthesis flow based on the user's requirements.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
time_infoRef time_m
pointer to the data structure containing timing information
const generic_deviceRef device
information about the target device
int debug_level
debugging level of the class
void xparse_utilization(const std::string &fn)
Parses device utilization.
#define LATTICE_REGISTERS
bool starts_with(const std::string &str, const std::string &pattern)
map_t parameter_values
Map between the name of the parameter and the corresponding string-based value.
std::string get_name() const
Get the name of this node.
std::vector< BackendStepRef > steps
ordered list of synthesis steps
std::map< std::string, double > design_values
design values reported by the tools
Wrapper to synthesis tools by Lattice.
This file contains the definition of the parameters for the synthesis tools.
~LatticeBackendFlow() override
Destructor.
refcount< XMLDomParser > XMLDomParserRef
utility function used to read files.
virtual void ExecuteSynthesis()
Executes the synthesis with the implemented flow.
This file collects some utility functions and macros.
void create_sdc(const DesignParametersRef dp)
Creates the constraint file.
void Exec()
Parse an XML document from a file.
const ParameterConstRef Param
class containing all the parameters
void CheckSynthesisResults() override
Checks the synthesis results and fills the corresponding data-structures.
void WriteFlowConfiguration(std::ostream &script) override
Writes the proper flow configuration in the output script.
std::list< xml_nodeRef > node_list
type for list of xml nodes
std::map< std::string, std::string > default_data
map between the identifiers of the synthesis flows and the corresponding implementations ...
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
std::string out_dir
name of the output directory
Classes for handling configuration files.
This class describes all classes used to represent a structural object.
static area_infoRef factory(const ParameterConstRef &Param)
Factory method.
std::string GetPath(std::filesystem::path path)
std::string component_name
Name of the component.
unsigned int output_level
verbosity level of the class
LatticeBackendFlow(const ParameterConstRef Param, const std::string &flow_name, const generic_deviceRef _device)
Constructor.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
xml_documentRef get_document()
Obtain the parsed document.
this class is used to manage the command-line or XML options.
#define LOAD_XVM(variable, node)
LOAD XML Value Macro. Set a variable starting from an XML value. Conversion is performed if needed...
#define PARAM_lattice_report
node_list const & get_children()
Obtain the list of child nodes.
Generic device description.
#define PRINT_OUT_MEX(profLevel, curprofLevel, mex)
#define OUTPUT_LEVEL_VERBOSE
verbose debugging print is performed.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
std::string relocate_compiler_path(const std::string &path, bool resolve_path=false)
static time_infoRef factory(const ParameterConstRef Param)
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...