91 output_level(_Param->getOption<unsigned int>(OPT_output_level)),
92 flow_name(
std::move(_flow_name)),
93 out_dir(Param->getOption<
std::string>(OPT_output_directory) +
"/" + flow_name),
100 if(!std::filesystem::exists(
out_dir))
102 std::filesystem::create_directories(
out_dir);
116 if(!device->has_parameter(
"vendor"))
120 auto vendor = device->get_parameter<std::string>(
"vendor");
121 boost::algorithm::to_lower(vendor);
122 if(vendor ==
"xilinx")
125 if(
parameters->isOption(OPT_generate_taste_architecture) and
126 parameters->getOption<
bool>(OPT_generate_taste_architecture))
128 return XILINX_TASTE_FPGA;
133 else if(vendor ==
"altera")
137 else if(vendor ==
"lattice")
141 else if(vendor ==
"nanoxplore")
143 return NANOXPLORE_FPGA;
145 else if(vendor ==
"generic")
151 THROW_ERROR(
"Device vendor \"" + vendor +
"\" not supported");
166 case XILINX_TASTE_FPGA:
173 case NANOXPLORE_FPGA:
185 const std::list<std::string>& hdl_files,
186 const std::list<std::string>& aux_files)
189 auto resource_name =
"_" + fu_name;
190 std::string synthesis_file_list;
191 for(
const auto& hdl_file : hdl_files)
193 synthesis_file_list += hdl_file +
";";
203 for(
const auto& aux_file : aux_files)
205 synthesis_file_list += aux_file +
";";
209 std::string library = TM->
get_library(resource_name);
210 bool is_combinational =
false;
211 auto is_time_unit_PS =
212 device->has_parameter(
"USE_TIME_UNIT_PS") &&
device->get_parameter<
int>(
"USE_TIME_UNIT_PS") == 1;
217 STR((is_time_unit_PS ? 1000 : 1) * GetPointer<functional_unit>(tn)->get_clock_period());
219 STR(1000 * GetPointer<functional_unit>(tn)->get_clock_period());
220 if(GetPointer<functional_unit>(tn)->logical_type == functional_unit::COMBINATIONAL)
222 is_combinational =
true;
232 STR((is_time_unit_PS ? 1000 : 1) * GetPointer<functional_unit>(tn)->get_clock_period());
234 STR(1000 * GetPointer<functional_unit>(tn)->get_clock_period());
235 if(GetPointer<functional_unit>(tn)->logical_type == functional_unit::COMBINATIONAL)
237 is_combinational =
true;
239 if(GetPointer<functional_unit>(tn)->fu_template_name.size())
250 bool time_constrained =
false;
254 time_constrained =
true;
257 if(!time_constrained)
266 if(
Param->isOption(OPT_clock_name))
274 bool connect_iob =
false;
275 if(
Param->isOption(OPT_connect_iob) &&
Param->getOption<
bool>(OPT_connect_iob))
280 if(
Param->isOption(OPT_top_design_name))
288 if(
Param->isOption(OPT_backend_script_extensions))
292 Param->getOption<std::string>(OPT_backend_script_extensions);
298 if(
Param->isOption(OPT_VHDL_library))
307 if(
Param->isOption(OPT_parallel_backend))
309 if(
Param->getOption<
bool>(OPT_parallel_backend))
329 for(
auto& step :
steps)
331 step->tool->CheckExecution();
336 std::vector<std::string>
parameters, input_files, output_files;
337 const std::string synthesis_file_output =
338 Param->getOption<std::string>(OPT_output_temporary_directory) +
"/synthesis_output";
339 tool->
execute(parameters, input_files, output_files, synthesis_file_output,
false);
358 root = parser->get_document()->get_root_node();
361 for(
const auto& l : list)
363 const xml_element* child = GetPointer<xml_element>(l);
364 if(!child || child->
get_name() !=
"flow")
385 for(
const auto& l : list)
387 const xml_element* child = GetPointer<xml_element>(l);
407 if(!
CE_XVM(config, child))
409 THROW_ERROR(
"Missing configuration for component " +
id);
412 step->config_name = config;
414 std::string script_name;
415 if(
CE_XVM(script_name, child))
418 step->script_name = config;
424 type = SynthesisTool::XST;
425 if(step->script_name.size() == 0)
427 step->script_name =
"xst.tcl";
432 type = SynthesisTool::NGDBUILD;
436 type = SynthesisTool::MAP;
440 type = SynthesisTool::TRCE;
444 type = SynthesisTool::PAR;
448 type = SynthesisTool::VIVADO_FLOW;
449 if(step->script_name.size() == 0)
451 step->script_name =
"vivado.tcl";
456 type = SynthesisTool::QUARTUS_SETUP;
457 if(step->script_name.size() == 0)
459 step->script_name =
"quartus_setup.tcl";
464 type = SynthesisTool::QUARTUS_13_SETUP;
465 if(step->script_name.size() == 0)
467 step->script_name =
"quartus_setup.tcl";
472 type = SynthesisTool::QUARTUS_FLOW;
473 if(step->script_name.size() == 0)
475 step->script_name =
"quartus_flow.tcl";
480 type = SynthesisTool::QUARTUS_13_FLOW;
481 if(step->script_name.size() == 0)
483 step->script_name =
"quartus_flow.tcl";
488 type = SynthesisTool::QUARTUS_POW;
489 if(step->script_name.size() == 0)
491 step->script_name =
"quartus_pow_arguments";
496 type = SynthesisTool::QUARTUS_STA;
497 if(step->script_name.size() == 0)
499 step->script_name =
"report_sta.tcl";
504 type = SynthesisTool::QUARTUS_13_STA;
505 if(step->script_name.size() == 0)
507 step->script_name =
"report_sta.tcl";
512 type = SynthesisTool::LATTICE_FLOW;
513 if(step->script_name.size() == 0)
515 step->script_name =
"project.tcl";
520 type = SynthesisTool::NXPYTHON_FLOW;
521 if(step->script_name.size() == 0)
523 step->script_name =
"script.py";
528 type = SynthesisTool::BASH_FLOW;
529 if(step->script_name.size() == 0)
531 step->script_name =
"bash_script.sh";
536 THROW_ERROR(
"Step <" +
id +
"> is currently not supported");
541 step->out_dir = step->tool->get_output_directory();
544 step->tool->xload(
root, step->config_name);
559 steps.push_back(step);
571 "Mismatching!! exec = \"" + exec_params->
chain_name +
"\" vs. dp = \"" + dp->
chain_name +
"\"");
577 "-->setting parameter \"" + p->first +
"\" to value \"" + p->second +
"\"");
578 if(module_undefined_parameters.find(p->first) != module_undefined_parameters.end())
581 "---removed parameter \"" + p->first +
"\" from undefined parameters");
582 module_undefined_parameters.erase(p->first);
587 if(module_undefined_parameters.size() > 0)
589 for(
const auto& module_undefined_parameter : module_undefined_parameters)
591 PRINT_MSG(
"missing definition for parameter " + module_undefined_parameter);
593 THROW_ERROR(
"Some parameters still need to be defined: " +
STR(module_undefined_parameters.size()));
615 std::filesystem::perms::owner_exec | std::filesystem::perms::group_exec |
616 std::filesystem::perms::others_exec,
618 script <<
"#!/bin/bash" << std::endl;
619 script <<
"##########################################################" << std::endl;
620 script <<
"# Automatically generated by the PandA framework #" << std::endl;
621 script <<
"##########################################################" << std::endl << std::endl;
622 script <<
"# Synthesis script for COMPONENT: " << exec_params->
component_name << std::endl << std::endl;
626 for(
const auto& step :
steps)
628 THROW_ASSERT(step->tool,
"Tool not valid for step: " + step->name);
629 script <<
"# STEP: " << step->name << std::endl;
632 if(!std::filesystem::exists(step->out_dir))
634 THROW_ERROR(
"Output directory \"" + step->out_dir +
"\" has not been created!");
636 std::filesystem::create_directory(step->out_dir);
641 std::string script_path;
642 if(step->script_name.size())
644 script_path = step->tool->get_output_directory() +
"/" + step->script_name;
646 step->tool->generate_synthesis_script(exec_params, script_path);
648 script << step->tool->get_command_line(exec_params) << std::endl;
656 "<--Completed the generation of scripts for module \"" + exec_params->
component_name +
657 "\" on chain \"" + exec_params->
chain_name +
"\"");
676 for(
const auto& step :
steps)
678 THROW_ASSERT(step->tool,
"Tool not valid for step: " + step->name);
Wrapper to trce by XILINX.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#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.
void add_backend_step(const BackendStepRef &step)
Adds a backend step to the list of the ones to be performed.
area_infoRef area_m
pointer to the data structure containing information about the resources
Wrapper to invoke a generic bash script.
Wrapper to NanoXplore synthesis tools *.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
technology_nodeRef get_fu(const std::string &fu_name, const std::string &Library) const
Return the reference to a component given its name.
const std::string & get_id() const
Return the identifier associated with the structural_object.
void create_xml_scripts(const std::string &xml_file)
Creates the XML script containing all the steps.
DesignParametersRef actual_parameters
set of design parameters with the actual values
#define GET_CLASS(obj)
Macro returning the actual type of an object.
const structural_objectRef get_circ() const
Get a reference to circ field.
#define QUARTUS_13_FLOW_TOOL_ID
Wrapper to implement a synthesis tools by Lattice.
Wrapper to invoke vivado_flow tool by XILINX.
exceptions managed by PandA
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.
Definition of hash function for EdgeDescriptor.
CustomOrderedSet< std::string > undefined_parameters
list of undefined parameters
std::string flow_name
string-based identifier of the flow
Class specification of the manager of the technology library data structures.
void parse_flow(const XMLDomParserRef parser)
Creates the synthesis flow based on the user's requirements.
#define QUARTUS_SETUP_TOOL_ID
superclass include
#define QUARTUS_POWER_TOOL_ID
time_infoRef time_m
pointer to the data structure containing timing information
const generic_deviceRef device
information about the target device
Include a set of utilities used to manage CPU time measures.
static type_t DetermineBackendFlowType(const generic_deviceRef device, const ParameterConstRef parameters)
Determines the type of the backend flow based on the target device.
int debug_level
debugging level of the class
Wrapper to implement a synthesis tools by Xilinx.
#define STR(s)
Macro which performs a lexical_cast to a string.
#define BASH_FLOW_TOOL_ID
#define CLOCK_PORT_NAME
standard name for ports
std::string CreateScripts(const DesignParametersRef dp)
Creates the scripts for the specified tools in the right order, along with the overall configuration...
Wrapper to invoke nxpython_flow tool by NANOXPLORE.
virtual ~BackendFlow()
Destructor.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
map_t parameter_values
Map between the name of the parameter and the corresponding string-based value.
Backend based on a simple bash script.
virtual std::string GenerateSynthesisScripts(const std::string &fu_name, const structural_managerRef SM, const std::list< std::string > &hdl_files, const std::list< std::string > &aux_files)
Generates the synthesis scripts for the specified design.
std::string get_name() const
Get the name of this node.
void set_name(const std::string &_name)
Set the name of this node.
std::vector< BackendStepRef > steps
ordered list of synthesis steps
Class specification of the data structures used to manage technology information. ...
This file contains the definition of the parameters for the synthesis tools.
xml_element * root
root node of the configuration device
#define LOAD_XVFM(variable, node, field)
LOAD XML Value for field Macro. Set a variable starting from an XML value. Conversion is performed if...
void set_initial_parameters(const DesignParametersRef &flow_parameters, const CustomOrderedSet< std::string > &undefined_parameters)
Sets parameters.
void write_to_file_formatted(const std::filesystem::path &filename)
Write the document to a file.
Wrapper to XST by XILINX.
#define LATTICE_FLOW_TOOL_ID
utility function used to read files.
static BackendFlowRef CreateFlow(const ParameterConstRef Param, const std::string &flow_name, const generic_deviceRef _device)
Creates the flow specification based on the given parameters.
virtual void ExecuteSynthesis()
Executes the synthesis with the implemented flow.
const ParameterConstRef Param
class containing all the parameters
Wrapper to par by XILINX.
std::list< xml_nodeRef > node_list
type for list of xml nodes
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Wrapper to invoke quartus_report tool by Altera.
void xload(const xml_element *node)
Loads the backend flow from an XML node.
BackendFlow(const ParameterConstRef Param, std::string flow_name, const generic_deviceRef _device)
Constructor.
virtual void CheckSynthesisResults()=0
Checks the synthesis results and fills the corresponding data structures.
void set_encoding(const std::string &_encoding)
#define QUARTUS_FLOW_TOOL_ID
std::string out_dir
name of the output directory
This file contains the definition of the configurable flow for generating and executing synthesis scr...
Wrapper to ngdbuild by XILINX.
Wrapper to invoke quartus_report tool by Altera.
void add(int accelnum, int startidx, int endidx)
#define NXPYTHON_FLOW_TOOL_ID
refcount< BackendStep > BackendStepRef
This class describes all classes used to represent a structural object.
virtual void InitDesignParameters()
Initializes the parameters.
std::string GetPath(std::filesystem::path path)
std::string component_name
Name of the component.
Wrapper to invoke lattice_flow tool by Lattice.
std::string get_flow_name() const
Returns the name of the flow.
#define QUARTUS_13_REPORT_TOOL_ID
Superclass include.
refcount< BackendFlow > BackendFlowRef
refcount definition of the class
std::string generated_synthesis_script
name of the synthesis script
Wrapper to implement a synthesis tools by Xilinx targeting Taste architecture.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
virtual void WriteFlowConfiguration(std::ostream &script)=0
Writes the proper flow configuration in the output script.
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...
Wrapper to map by XILINX.
Some macro used to interface with the XML library.
node_list const & get_children()
Obtain the list of child nodes.
DesignParametersRef default_flow_parameters
set of design parameters to be set
std::string GetCurrentPath()
Class implementation of the structural_manager.
time_infoRef get_timing_results() const
Returns the timing information.
Generic device description.
enum { UNKNOWN, XILINX_FPGA, ALTERA_FPGA, LATTICE_FPGA, NANOXPLORE_FPGA, GENERIC, } type_t
implemented flow
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
#define VIVADO_FLOW_TOOL_ID
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
area_infoRef get_used_resources() const
Returns the list of used resources.
DesignParametersRef clone() const
Returns a clone of the current parameter configuration.
refcount< DesignParameters > DesignParametersRef
refcount definition of the class
xml_element * add_child_element(const std::string &name)
Add a child element to this node.
Wrapper to implement a synthesis tools by Altera.
Wrapper to quartus 14.0 and newer.
#define QUARTUS_REPORT_TOOL_ID
Superclass include.
std::string get_library(const std::string &Name) const
Return the higher priority library where the given component is stored.
Wrapper to quartus 13.x and newer.
std::string chain_name
Name of the flow.
#define QUARTUS_13_SETUP_TOOL_ID
superclass include
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...