PandA-2024.02
eucalyptus.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) 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 #include "EucalyptusParameter.hpp"
43 #include "RTL_characterization.hpp"
44 #include "cpu_time.hpp"
45 #include "design_flow_graph.hpp"
46 #include "design_flow_manager.hpp"
47 #include "design_flow_step.hpp"
48 #include "generic_device.hpp"
51 #include "parse_technology.hpp"
53 #include "technology_manager.hpp"
54 #include "utility.hpp"
55 #include <filesystem>
56 
57 int main(int argc, char* argv[])
58 {
59  // Program name
60 
62 
63  try
64  {
65  // ---------- General options ------------ //
66  // Synthesis cpu time
67  long total_time;
68  START_TIME(total_time);
69  // General options register
70 
71  // ---------- Initialization ------------ //
72 
73  // ---------- Parameter parsing ------------ //
74  long cpu_time;
75  START_TIME(cpu_time);
76  parameters = ParameterRef(new EucalyptusParameter(argv[0], argc, argv));
77 
78  switch(parameters->Exec())
79  {
81  {
83  throw "Bad Parameters format";
84  }
85  case EXIT_SUCCESS:
86  {
87  if(not(parameters->getOption<bool>(OPT_no_clean)))
88  {
89  std::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
90  }
91  return EXIT_SUCCESS;
92  }
93  case PARAMETER_PARSED:
94  {
95  exit_code = EXIT_FAILURE;
96  break;
97  }
98  default:
99  {
100  THROW_ERROR("Bad Parameters parsing");
101  }
102  }
103 
104  auto output_level = parameters->getOption<int>(OPT_output_level);
105  STOP_TIME(cpu_time);
106  if(output_level >= OUTPUT_LEVEL_MINIMUM)
107  {
108  parameters->PrintFullHeader(std::cerr);
109  }
110 
112  if(!parameters->isOption(OPT_clock_period))
113  {
114  parameters->setOption(OPT_clock_period, 0.0);
115  }
116 
117  // Technology library manager
119 
121  generic_deviceRef device = generic_device::factory(parameters, TM);
122  device->set_parameter("clock_period", parameters->getOption<double>(OPT_clock_period));
123  const DesignFlowManagerRef design_flow_manager(new DesignFlowManager(parameters));
124  const DesignFlowGraphConstRef design_flow_graph = design_flow_manager->CGetDesignFlowGraph();
125 
126  const DesignFlowStepFactoryConstRef technology_flow_step_factory(
127  new TechnologyFlowStepFactory(TM, device, design_flow_manager, parameters));
128  design_flow_manager->RegisterFactory(technology_flow_step_factory);
129 
130  const std::string technology_flow_signature =
132  const vertex technology_flow_step = design_flow_manager->GetDesignFlowStep(technology_flow_signature);
133  const DesignFlowStepRef technology_design_flow_step =
134  technology_flow_step ? design_flow_graph->CGetDesignFlowStepInfo(technology_flow_step)->design_flow_step :
135  GetPointer<const TechnologyFlowStepFactory>(technology_flow_step_factory)
136  ->CreateTechnologyFlowStep(TechnologyFlowStep_Type::LOAD_TECHNOLOGY);
137  design_flow_manager->AddStep(technology_design_flow_step);
138 
139  if(parameters->isOption(OPT_component_name))
140  {
141  const DesignFlowStepRef design_flow_step(new RTLCharacterization(
142  device, parameters->getOption<std::string>(OPT_component_name), design_flow_manager, parameters));
143  design_flow_manager->AddStep(design_flow_step);
144  }
145  design_flow_manager->Exec();
146 
147  STOP_TIME(total_time);
148  PRINT_MSG(" ==== Total Execution Time: " + print_cpu_time(total_time) + " seconds; ====\n");
149 
150  if(not(parameters->getOption<bool>(OPT_no_clean)))
151  {
152  std::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
153  }
154  return EXIT_SUCCESS; // Eucalyptus tool has completed execution without errors
155  }
156 
157  // exception catching
158  catch(const char* str)
159  {
160  std::cerr << str << std::endl;
161  }
162  catch(const std::string& str)
163  {
164  std::cerr << str << std::endl;
165  }
166  catch(std::exception& e)
167  {
168  std::cerr << e.what() << std::endl;
169  }
170  catch(...)
171  {
172  std::cerr << "Unknown error type" << std::endl;
173  }
174 
175  switch(exit_code)
176  {
177  case PARAMETER_NOTPARSED:
178  {
179  parameters->PrintUsage(std::cout);
180  break;
181  }
182  case EXIT_FAILURE:
183  {
184  parameters->PrintBugReport(std::cout);
185  break;
186  }
187  default:
188  {
189  }
190  }
191  if(parameters and not(parameters->getOption<bool>(OPT_no_clean)))
192  {
193  std::filesystem::remove_all(parameters->getOption<std::string>(OPT_output_temporary_directory));
194  }
195  return exit_code;
196 }
Input function used to read the technology data structures.
int exit_code
NOTE: this file must be included only by source code of the executable (i.e., the file with the main)...
Class specification of the manager of the technology library data structures.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
Include a set of utilities used to manage CPU time measures.
#define START_TIME(time_var)
Macro used to store the start time into time_var.
Definition: cpu_time.hpp:133
static generic_deviceRef factory(const ParameterConstRef &Param, const technology_managerRef &TM)
Factory method.
Base class for step of design flow.
This class manages the technology library structures.
int main(int argc, char *argv[])
Definition: eucalyptus.cpp:57
Classes to describe design flow graph.
#define PARAMETER_PARSED
An integer value to return if parameters have been right parsed.
Definition: Parameter.hpp:93
static const std::string ComputeSignature(const TechnologyFlowStep_Type technology_flow_step_type)
Compute the signature of a technology flow step.
#define STOP_TIME(time_var)
Macro used to store the elapsed time into time_var.
Definition: cpu_time.hpp:136
Factory for technology flow step.
refcount< Parameter > ParameterRef
Definition: Parameter.hpp:758
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
Class for performing RTL characterization.
This file collects some utility functions and macros.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
Wrapper of design_flow.
std::string print_cpu_time(long int t)
massage a long which represents a time interval in milliseconds, into a string suitable for output ...
Definition: cpu_time.hpp:110
This class loads default technology libraries.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
char str[25]
Definition: fixedptc.c:8
refcount< technology_manager > technology_managerRef
This class load builtin components in technology manager.
Generic device description.
#define PRINT_MSG(mex)
#define PARAMETER_NOTPARSED
Definition: Parameter.hpp:94

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