PandA-2024.02
datapath_cs.cpp
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) 2016-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  */
41 #include "datapath_cs.hpp"
42 #include "Parameter.hpp"
43 #include "hls.hpp"
44 #include "hls_manager.hpp"
45 #include "omp_functions.hpp"
46 #include "structural_manager.hpp"
47 #include "structural_objects.hpp"
48 
50 #include <cmath>
51 
53 #include "dbgPrintHelper.hpp"
54 #include "math_function.hpp"
55 #include "utility.hpp"
56 
57 datapath_cs::datapath_cs(const ParameterConstRef _parameters, const HLS_managerRef _HLSMgr, unsigned int _funId,
58  const DesignFlowManagerConstRef _design_flow_manager,
59  const HLSFlowStep_Type _hls_flow_step_type)
60  : classic_datapath(_parameters, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
61 {
62  debug_level = _parameters->get_class_debug_level(GET_CLASS(*this));
63 }
64 
65 datapath_cs::~datapath_cs() = default;
66 
68 {
69  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Starting " + GET_CLASS(*this) + "::" + __func__);
70  classic_datapath::add_ports(); // add standard port
71  auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
72  const structural_managerRef& SM = this->HLS->datapath;
73  const structural_objectRef circuit = SM->get_circ();
74  bool found = false;
75  if(omp_functions->parallelized_functions.find(funId) != omp_functions->parallelized_functions.end())
76  {
77  found = true;
78  }
79  if(omp_functions->atomic_functions.find(funId) != omp_functions->atomic_functions.end())
80  {
81  found = true;
82  }
83  if(found) // function with selector
84  {
85  INDENT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "---Adding ports selector and suspension");
86  auto num_slots = ceil_log2(parameters->getOption<unsigned long long int>(OPT_context_switch));
87  if(!num_slots)
88  {
89  num_slots = 1;
90  }
92  structural_type_descriptorRef(new structural_type_descriptor("bool", static_cast<unsigned>(num_slots)));
93  SM->add_port(STR(SELECTOR_REGISTER_FILE), port_o::IN, circuit, port_type);
96  SM->add_port(STR(SUSPENSION), port_o::OUT, circuit, bool_type);
97  }
98  if(omp_functions->kernel_functions.find(funId) != omp_functions->kernel_functions.end())
99  {
100  THROW_ASSERT(!found, "unexpected condition");
101  INDENT_DBG_MEX(DEBUG_LEVEL_VERBOSE, debug_level, "---Adding ports for kernel module");
102  auto num_slots = ceil_log2(parameters->getOption<unsigned long long int>(OPT_context_switch));
103  if(!num_slots)
104  {
105  num_slots = 1;
106  }
108  structural_type_descriptorRef(new structural_type_descriptor("bool", static_cast<unsigned>(num_slots)));
111  SM->add_port(STR(SELECTOR_REGISTER_FILE), port_o::OUT, circuit, port_type);
112  SM->add_port(STR(TASKS_POOL_END), port_o::IN, circuit, bool_type);
113  SM->add_port(STR(DONE_SCHEDULER), port_o::IN, circuit, bool_type);
114  SM->add_port(STR(START_PORT_NAME) + "_task", port_o::IN, circuit, bool_type);
115  SM->add_port(STR(DONE_REQUEST), port_o::OUT, circuit, bool_type);
116  circuit->AddParameter("KERN_NUM", "0");
117  }
118  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Ended " + GET_CLASS(*this) + "::" + __func__);
119 }
#define TASKS_POOL_END
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
const HLS_managerRef HLSMgr
information about all the HLS synthesis
Definition: hls_step.hpp:205
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;.
#define DONE_SCHEDULER
refcount< structural_type_descriptor > structural_type_descriptorRef
RefCount type definition of the structural_type_descriptor class structure.
File containing functions and utilities to support the printing of debug messagges.
#define DONE_REQUEST
structural_managerRef datapath
Store the datapath description.
Definition: hls.hpp:155
#define START_PORT_NAME
Structure representing the most relevant information about the type of a structural object...
virtual void add_ports()
Adds the input/output ports of the module.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
mathematical utility function not provided by standard libraries
const unsigned int funId
identifier of the function to be processed (0 means that it is a global step)
#define STR(s)
Macro which performs a lexical_cast to a string.
virtual void AddParameter(const std::string &name, const std::string &default_value)
Add a parameter.
T ceil_log2(T x)
Return the smallest n such that 2**n >= X.
HLSFlowStep_Type
Definition: hls_step.hpp:95
~datapath_cs() override
Destructor.
const ParameterConstRef parameters
Set of input parameters.
This file collects some utility functions and macros.
void add_ports() override
Adds the input/output ports of the module.
Definition: datapath_cs.cpp:67
This class describes all classes used to represent a structural object.
hlsRef HLS
HLS data structure of the function to be analyzed.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
this class is used to manage the command-line or XML options.
datapath_cs(const ParameterConstRef _parameters, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type)
Constructor.
Definition: datapath_cs.cpp:57
#define SELECTOR_REGISTER_FILE
Class implementation of the structural_manager.
int debug_level
The debug level.
Datastructure to describe functions allocation in high-level synthesis.
#define DEBUG_LEVEL_VERBOSE
verbose debugging print is performed.
Data structure definition for high-level synthesis flow.
#define SUSPENSION
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

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