81 #include <boost/graph/topological_sort.hpp> 83 #define PP_MAX_CYCLES_BOUNDED "max-cycles-bounded" 84 #define DEFAULT_MAX_CYCLES_BOUNDED (8) 90 _HLSMgr->CGetFunctionBehavior(_HLS->functionId)->CGetOpGraph(
FunctionBehavior::CFG))),
93 state_transition_graphs_collection,
TransitionInfo::StateTransitionType::ST_EDGE_NORMAL))),
95 state_transition_graphs_collection,
TransitionInfo::StateTransitionType::ST_EDGE_NORMAL |
98 state_transition_graphs_collection,
100 op_function_graph(_HLSMgr->CGetFunctionBehavior(_HLS->functionId)->CGetOpGraph(
FunctionBehavior::CFG)),
102 output_level(_Param->getOption<int>(OPT_output_level)),
103 debug_level(_Param->getOption<int>(OPT_debug_level)),
134 auto info =
STG_graph->GetStateTransitionGraphInfo();
135 if(info->is_a_dag && !
Param->getOption<
bool>(OPT_disable_bounded_function))
137 std::list<vertex> sorted_vertices;
140 bool has_dummy_state =
false;
141 for(
const auto v : sorted_vertices)
148 const auto ie_first = ie;
149 for(; ie != iend; ie++)
152 CSteps_max[v] =
std::max(CSteps_max[v], 1 + CSteps_max[src]);
155 CSteps_min[v] = 1 + CSteps_min[src];
159 CSteps_min[v] =
std::min(CSteps_min[v], 1 + CSteps_max[src]);
163 THROW_ASSERT(CSteps_min.find(info->exit_node) != CSteps_min.end(),
"Exit node not reachable");
164 THROW_ASSERT(CSteps_max.find(info->exit_node) != CSteps_max.end(),
"Exit node not reachable");
165 info->min_cycles = CSteps_min.find(info->exit_node)->second - 1;
166 info->max_cycles = CSteps_max.find(info->exit_node)->second - 1;
168 is_pipelined || (info->min_cycles == info->max_cycles && info->max_cycles <=
_max_cycles_bounded &&
169 info->min_cycles > 0 && !has_dummy_state);
173 THROW_ASSERT(
Param->getOption<
bool>(OPT_disable_bounded_function) || !is_pipelined,
174 "A pipelined function should always generate a DAG");
180 return STG_graph->CGetStateTransitionGraphInfo()->entry_node;
187 for(boost::tie(v, vend) = boost::vertices(*
STG_graph); v != vend; v++)
189 const std::list<vertex>* operations;
193 operations = &(
STG_graph->CGetStateInfo(*v)->executing_operations);
196 operations = &(
STG_graph->CGetStateInfo(*v)->starting_operations);
199 operations = &(
STG_graph->CGetStateInfo(*v)->ending_operations);
204 auto op_it_end = operations->end();
207 for(
auto op_it = operations->begin(); op_it != op_it_end && !stop_flag; ++op_it)
212 vertex_set.insert(*v);
223 return get_states(op, StateTransitionGraphManager::StateTypes::ENDING);
228 return get_states(op, StateTransitionGraphManager::StateTypes::STARTING);
238 return STG_graph->CGetStateTransitionGraphInfo()->exit_node;
243 return STG_graph->CGetStateInfo(state)->name;
270 "---" + std::string(
"Is a DAG: ") +
271 (
STG_graph->CGetStateTransitionGraphInfo()->is_a_dag ?
"T" :
"F"));
272 if(
STG_graph->CGetStateTransitionGraphInfo()->min_cycles != 0 &&
273 STG_graph->CGetStateTransitionGraphInfo()->max_cycles != 0)
276 "---Minimum number of cycles: " +
STR(
STG_graph->CGetStateTransitionGraphInfo()->min_cycles));
278 "---Maximum number of cycles " +
STR(
STG_graph->CGetStateTransitionGraphInfo()->max_cycles));
294 auto mut = GetPointer<multi_unbounded_obj>(mu);
297 auto* port = GetPointer<port_o>(inOps);
298 const auto& ops = mut->get_ops();
299 auto n_in_ports =
static_cast<unsigned int>(ops.size());
300 port->add_n_ports(n_in_ports, inOps);
306 const auto& circuit = SM->
get_circ();
310 auto mu = state2mu.second;
311 std::string name = mu->get_string();
314 HLS->
HLS_D->get_technology_manager());
318 SM->add_connection(clock_port, port_ck);
320 SM->add_connection(reset_port, port_rst);
321 mu->set_structural_obj(mu_mod);
323 mu->set_out_sign(p_obj);
Data structure representing the entire HLS information.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
StateTransitionGraphManager(const HLS_managerConstRef HLSMgr, hlsRef HLS, const ParameterConstRef _Param)
Constructor of the class.
File containing functions and utilities to support the printing of debug messagges.
Base class for all unbounded objects added to datapath.
const StateTransitionGraph_constructorRef STG_builder
reference to the class for building the graph
structural_managerRef datapath
Store the datapath description.
This file contains the structures needed to manage a graph that will represent the state transition g...
CustomOrderedSet< vertex > get_ending_states(const vertex &op) const
const StateTransitionGraphConstRef CGetEPPStg() const
Returns pointer to acyclic STG with additional edges for Efficient Path Profiling.
const structural_objectRef get_circ() const
Get a reference to circ field.
const StateTransitionGraphsCollectionRef state_transition_graphs_collection
The bulk graph.
vertex get_entry_state() const
Gets vertex that represents state that contains entry node.
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
StateTransitionGraphRef GetAstg()
Returns pointer to state transition graph created.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
hlsRef HLS
HLS data-structure.
const HLS_deviceRef HLS_D
reference to the information representing the target for the synthesis
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
This structure defines the bulk for the state transition graph.
void ComputeCyclesCount(bool is_pipelined)
Compute minimum and maximum number of cycles for bounded scheduling.
vertex get_exit_state() const
Gets vertex that represents state that contains exit node.
virtual structural_objectRef find_member(const std::string &id, so_kind type, const structural_objectRef owner) const =0
Return the object named id of a given type which belongs to or it is associated with the object...
Class specification of the manager of the technology library data structures.
const OpGraphConstRef op_function_graph
reference to operation graph
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
StateTransitionGraphRef GetEPPStg()
Returns pointer to acyclic STG with additional edges for Efficient Path Profiling.
const ParameterConstRef Param
class containing all the parameters
#define STR(s)
Macro which performs a lexical_cast to a string.
std::map< vertex, generic_objRef > multi_unbounded_table
map between state and multi-unbounded controllers
void print_statistics() const
#define CLOCK_PORT_NAME
standard name for ports
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
#define DEFAULT_MAX_CYCLES_BOUNDED
class modeling a register object
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
CustomOrderedSet< vertex > get_states(const vertex &op, StateTypes statetypes) const
Class used to describe a state transition graph.
unsigned int get_number_of_states() const
File contanining the structures necessary to manage a graph that will represent a state transition gr...
Class specification of the data structures used to manage technology information. ...
const std::string get_path() const
Return a unique identifier of the structural object.
const unsigned int _max_cycles_bounded
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
This file contains the structures needed to manage a graph that will represent the state transition g...
CustomOrderedSet< vertex > get_starting_states(const vertex &op) const
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
#define PP_MAX_CYCLES_BOUNDED
Header include.
const StateTransitionGraphRef STG_graph
The complete version of the STG.
const StateTransitionGraphConstRef CGetAstg() const
Returns pointer to state transition graph created.
const StateTransitionGraphRef EPP_STG_graph
The acyclic version of stg with additional edges necessary for Efficient Path Profiling.
void add_to_SM(structural_objectRef clock_port, structural_objectRef reset_port)
Add components to the datapath required by the FSM.
void specialise_mu(structural_objectRef &mu_mod, generic_objRef mu) const
#define OUTPUT_LEVEL_VERY_PEDANTIC
verbose debugging print is performed.
Data structure used to store the functional-unit binding of the vertexes.
const StateTransitionGraphRef ACYCLIC_STG_graph
The acyclic version of the STG.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
this class is used to manage the command-line or XML options.
StateTransitionGraphRef GetStg()
Returns pointer to state transition graph created.
~StateTransitionGraphManager()
Destructor.
int output_level
verbosity level
Class implementation of the structural_manager.
Generic device description.
Base class for all register into datapath.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
const StateTransitionGraphConstRef CGetStg() const
Returns pointer to state transition graph created.
Structure holding information about the whole graph.
CustomOrderedSet< vertex > get_execution_states(const vertex &op) const
int debug_level
debugging level of the class
Structure holding the information about an edge into the graph.
void add_multi_unbounded_obj(vertex s, const CustomOrderedSet< vertex > &ops)
int debug_level
debugging level
refcount< generic_obj > generic_objRef
RefCount definition for generic_obj class.
HLS specialization of generic_device.
A brief description of the C++ Header File.
std::string get_state_name(vertex state) const
Get the name of a state.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...