PandA-2024.02
controller_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  */
43 #include "controller_cs.hpp"
44 
45 #include "BambuParameter.hpp"
46 #include "dbgPrintHelper.hpp"
47 #include "hls.hpp"
48 #include "hls_manager.hpp"
49 #include "math.h"
50 #include "math_function.hpp"
51 #include "omp_functions.hpp"
52 #include "structural_manager.hpp"
53 #include "structural_objects.hpp"
54 #include "utility.hpp"
55 
56 controller_cs::controller_cs(const ParameterConstRef _Param, const HLS_managerRef _HLSMgr, unsigned int _funId,
57  const DesignFlowManagerConstRef _design_flow_manager,
58  const HLSFlowStep_Type _hls_flow_step_type)
59  : fsm_controller(_Param, _HLSMgr, _funId, _design_flow_manager, _hls_flow_step_type)
60 {
61 }
62 
64 
66 {
68  auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
69  bool found = false;
70  if(omp_functions->kernel_functions.find(funId) != omp_functions->kernel_functions.end())
71  {
72  found = true;
73  }
74  if(omp_functions->parallelized_functions.find(funId) != omp_functions->parallelized_functions.end())
75  {
76  found = true;
77  }
78  if(omp_functions->atomic_functions.find(funId) != omp_functions->atomic_functions.end())
79  {
80  found = true;
81  }
82  if(found) // function with selector
83  {
84  PRINT_DBG_MEX(DEBUG_LEVEL_PEDANTIC, debug_level, "Adding the selector port...");
85  this->add_selector_register_file_port(circuit, SM);
86  }
87 }
88 
90 {
91  auto num_slots = ceil_log2(parameters->getOption<unsigned long long int>(OPT_context_switch));
92  if(!num_slots)
93  {
94  num_slots = 1;
95  }
97  structural_type_descriptorRef(new structural_type_descriptor("bool", static_cast<unsigned>(num_slots)));
98  PRINT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, " * Start adding Selector signal...");
100  SM->add_port(STR(SELECTOR_REGISTER_FILE), port_o::IN, circuit, port_type);
101  PRINT_DBG_MEX(DEBUG_LEVEL_PEDANTIC, debug_level, " - Selector signal added!");
102 }
103 
104 void controller_cs::add_correct_transition_memory(const std::string& state_representation, structural_managerRef SM)
105 {
106  structural_objectRef circuit = SM->get_circ();
107  auto omp_functions = GetPointer<OmpFunctions>(HLSMgr->Rfuns);
108  bool found = false;
109  if(omp_functions->kernel_functions.find(funId) != omp_functions->kernel_functions.end())
110  {
111  found = true;
112  }
113  if(omp_functions->parallelized_functions.find(funId) != omp_functions->parallelized_functions.end())
114  {
115  found = true;
116  }
117  if(omp_functions->atomic_functions.find(funId) != omp_functions->atomic_functions.end())
118  {
119  found = true;
120  }
121  if(found)
122  { // function with selector
123  SM->add_NP_functionality(circuit, NP_functionality::FSM_CS, state_representation);
124  }
125  else
126  {
127  SM->add_NP_functionality(circuit, NP_functionality::FSM, state_representation);
128  }
129 }
#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.
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.
Base class for all the controller creation algorithms.
#define PRINT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
Structure representing the most relevant information about the type of a structural object...
controller_cs(const ParameterConstRef Param, const HLS_managerRef HLSMgr, unsigned int funId, const DesignFlowManagerConstRef design_flow_manager, const HLSFlowStep_Type hls_flow_step_type)
Constructor.
void add_selector_register_file_port(structural_objectRef circuit, structural_managerRef SM)
const structural_objectRef get_circ() const
Get a reference to circ field.
void add_common_ports(structural_objectRef circuit, structural_managerRef SM) override
This member function adds the standard ports (clock, reset, done and command ones) to a circuit...
virtual void add_common_ports(structural_objectRef circuit, structural_managerRef SM)
This member function adds the standard ports (clock, reset, done and command ones) to a circuit...
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)
~controller_cs() override
Destructor.
#define STR(s)
Macro which performs a lexical_cast to a string.
T ceil_log2(T x)
Return the smallest n such that 2**n >= X.
static void add_NP_functionality(structural_objectRef cir, NP_functionality::NP_functionaly_type dt, std::string functionality_description)
Add a not-parsed functionality.
void add_correct_transition_memory(const std::string &state_representation, structural_managerRef SM) override
Set the correct NP functionality.
HLSFlowStep_Type
Definition: hls_step.hpp:95
static structural_objectRef add_port(const std::string &id, port_o::port_direction pdir, structural_objectRef owner, structural_type_descriptorRef type_descr, unsigned int treenode=0)
Create a new port.
const ParameterConstRef parameters
Set of input parameters.
This file collects some utility functions and macros.
This class describes all classes used to represent a structural object.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
#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.
Data structure definition for high-level synthesis flow.

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