PandA-2024.02
SynthesisTool.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
42 #ifndef _SYNTHESIS_TOOL_HPP_
43 #define _SYNTHESIS_TOOL_HPP_
44 
45 #include "refcount.hpp"
46 #include <map>
47 #include <string>
48 #include <vector>
49 
59 class xml_element;
60 
61 #define ADD_RES_VAR(name) \
62  xml_reserved_vars.push_back(xml_set_variable_tRef(new xml_set_variable_t((name), nullptr, nullptr)))
63 
64 #define PARAM_top_id "top_id"
65 #define PARAM_target_device "target_device"
66 #define PARAM_target_family "target_family"
67 #define PARAM_HDL_files "HDL_files"
68 #define PARAM_clk_name "clk_name"
69 #define PARAM_clk_period "clk_period"
70 #define PARAM_clk_period_ps "clk_period_ps"
71 #define PARAM_clk_period_default (1.0 / 50)
72 #define PARAM_clk_freq "clk_freq"
73 #define PARAM_time_constrained "time_constrained"
74 #define PARAM_is_combinational "is_combinational"
75 #define PARAM_sdc_file "sdc_file"
76 #define PARAM_backend_script_extensions "backend_script_extensions"
77 #define PARAM_has_script_extensions "has_script_extensions"
78 #define PARAM_has_VHDL_library "has_VHDL_library"
79 #define PARAM_VHDL_library "VHDL_library"
80 #define PARAM_connect_iob "connect_iob"
81 #define PARAM_power_optimization "power_optimization"
82 #define PARAM_parallel_backend "parallel_backend"
83 
85 #define PARAM_fu "fu"
86 
88 {
89  public:
91  using type_t = enum {
92  UNKNOWN = 0,
93  XST,
94  NGDBUILD,
95  MAP,
96  PAR,
97  TRCE,
98  VIVADO_FLOW,
99  QUARTUS_13_FLOW,
100  QUARTUS_13_SETUP,
101  QUARTUS_13_STA,
102  QUARTUS_SETUP,
103  QUARTUS_FLOW,
104  QUARTUS_POW,
105  QUARTUS_STA,
106  LATTICE_FLOW,
107  NXPYTHON_FLOW,
108  BASH_FLOW
109  };
110 
111  protected:
114 
117 
120 
122  unsigned int output_level;
123 
126 
128  const std::string tool_exec;
129 
131  std::string output_dir;
132 
134  std::string script_name;
135 
137  std::map<unsigned int, std::string> script_map;
138 
142  void create_output_directory(const std::string& sub_dir);
143 
144  // Script from XML
145  std::vector<xml_parameter_tRef> xml_tool_options;
146  std::vector<xml_script_node_tRef> xml_script_nodes;
147  std::vector<xml_set_variable_tRef> xml_reserved_vars;
148 
152  virtual void init_reserved_vars();
153 
154  public:
158  SynthesisTool(const ParameterConstRef& Param, std::string tool_exec, const generic_deviceRef& device,
159  const std::string& _flow_name, std::string default_output_dir);
160 
164  virtual ~SynthesisTool();
165 
169  virtual void CheckExecution();
170 
174  virtual void EvaluateVariables(const DesignParametersRef dp);
175 
179  virtual void generate_synthesis_script(const DesignParametersRef& dp, const std::string& file_name) = 0;
180 
184  virtual std::string get_command_line(const DesignParametersRef& dp) const = 0;
185 
189  virtual std::string toString(const xml_script_node_tRef node, const DesignParametersRef dp) const = 0;
190 
194  virtual std::string getStringValue(const xml_script_node_tRef node, const DesignParametersRef& dp) const = 0;
195 
199  std::string get_output_directory() const;
200 
204  std::string generate_bare_script(const std::vector<xml_script_node_tRef>& nodes, const DesignParametersRef& dp);
205 
212  xml_set_variable_tRef get_reserved_parameter(const std::string& name);
213 
219  void replace_parameters(const DesignParametersRef& dp, std::string& script) const;
220 
225  const std::string& output_dir, const generic_deviceRef& device);
226 
230  void xload_scripts(const xml_element* child);
231 
235  void xload(const xml_element* node, const std::string& tool_config);
236 
240  xml_nodeRef xwrite() const;
241 
245  bool has_scripts() const;
246 
250  virtual std::string get_tool_exec() const;
251 };
254 
255 #endif
generic device description
struct Node nodes[7]
const ParameterConstRef Param
class containing all the parameters
Command line parameter.
static SynthesisToolRef create_synthesis_tool(type_t type, const ParameterConstRef &Param, const std::string &output_dir, const generic_deviceRef &device)
Factory method.
int debug_level
debug level of the class
const std::string tool_exec
name of the tool executable
virtual std::string toString(const xml_script_node_tRef node, const DesignParametersRef dp) const =0
Returns the string-based representation of the XML element.
void xload(const xml_element *node, const std::string &tool_config)
Method parsing the configuration file directly from an XML node.
virtual std::string getStringValue(const xml_script_node_tRef node, const DesignParametersRef &dp) const =0
Returns the string-based representation of the XML element.
virtual void init_reserved_vars()
Initializes the reserved variables.
std::string output_dir
the output directory
virtual ~SynthesisTool()
Destructor.
unsigned int output_level
verbosity level of the class
virtual void EvaluateVariables(const DesignParametersRef dp)
Evaluates the design variables.
void create_output_directory(const std::string &sub_dir)
Creates the directory to store the output files.
ToolManagerRef tool
utility class to manage the executable
std::vector< xml_script_node_tRef > xml_script_nodes
const generic_deviceRef device
class containing information about the target device
bool has_scripts() const
Checks if there is a configuration script loaded.
enum { UNKNOWN=0, XST, NGDBUILD, MAP, PAR, TRCE, VIVADO_FLOW, QUARTUS_13_FLOW, QUARTUS_13_SETUP, QUARTUS_13_STA, QUARTUS_SETUP, QUARTUS_FLOW, QUARTUS_POW, QUARTUS_STA, LATTICE_FLOW, NXPYTHON_FLOW, BASH_FLOW } type_t
supported synthesis tools
std::vector< xml_set_variable_tRef > xml_reserved_vars
std::string script_name
name of the script
std::string get_output_directory() const
Returns the path of the output directory.
xml_set_variable_tRef get_reserved_parameter(const std::string &name)
Gets a reserved (tool) parameter by name.
void replace_parameters(const DesignParametersRef &dp, std::string &script) const
Replaces occurrences of parameters inside a script.
std::vector< xml_parameter_tRef > xml_tool_options
Template definition of refcount.
This is the abstract class which describes a generic synthesis script node, and some static helper me...
Variable assignment, either single value or multiple entries set.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
virtual std::string get_tool_exec() const
Returns the name of the tool executable.
SynthesisTool(const ParameterConstRef &Param, std::string tool_exec, const generic_deviceRef &device, const std::string &_flow_name, std::string default_output_dir)
Constructor.
xml_nodeRef xwrite() const
Method writing the configuration file.
void xload_scripts(const xml_element *child)
Actual parsing of parameters and script nodes.
virtual void generate_synthesis_script(const DesignParametersRef &dp, const std::string &file_name)=0
Creates the proper configuration script.
CONSTREF_FORWARD_DECL(Parameter)
virtual std::string get_command_line(const DesignParametersRef &dp) const =0
REF_FORWARD_DECL(SynthesisTool)
virtual void CheckExecution()
Check if the tool can be really executed; i.e., it has been properly configured.
std::map< unsigned int, std::string > script_map
map between the identifier of the script and the corresponding stream
std::string generate_bare_script(const std::vector< xml_script_node_tRef > &nodes, const DesignParametersRef &dp)

Generated on Mon Feb 12 2024 13:02:56 for PandA-2024.02 by doxygen 1.8.13