OpenASIP  2.0
ProGeScriptGenerator.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file ProGeScriptGenerator.hh
26  *
27  * Declaration of ProGeScriptGenerator class.
28  *
29  * @author Esa Määttä 2007 (esa.maatta-no.spam-tut.fi)
30  * @author Vinogradov Viacheslav(added Verilog generating) 2012
31  * @note rating: red
32  */
33 
34 #ifndef TTA_PROGE_SCRIPT_GENERATOR_HH
35 #define TTA_PROGE_SCRIPT_GENERATOR_HH
36 
37 #include <list>
38 #include "Exception.hh"
39 #include "ProGeTypes.hh"
40 
41 namespace IDF {
42  class MachineImplementation;
43 }
44 
45 /**
46  * Class for script generating objects.
47  *
48  * Base class for script generating.
49  * simulationRuntime defaults to 52390ns, can be changed in generateprocessor
50  * with a command line parameter, but not in ProDe yet. TODO.
51  */
53 public:
55  const ProGe::HDL language,
56  const IDF::MachineImplementation& idf,
57  const std::string& dstDir,
58  const std::string& progeOutDir,
59  const std::string& sharedOutDir,
60  const std::string& testBenchDir,
61  const std::string& toplevelEntity,
62  const std::string& simulationRuntime = "52390");
63 
64  virtual ~ProGeScriptGenerator();
65 
66  void generateAll();
67 
68  void generateModsimCompile();
69 
70  void generateGhdlCompile();
71 
73 
75 
76  void generateGhdlSimulate();
77 
79 
80 private:
81  void generateCompileStart(std::ostream& stream);
82  void generateSimulationStart(std::ostream& stream);
83  void createExecutableFile(const std::string& fileName);
85  std::ostream& stream,
86  const std::list<std::string>& files,
87  const std::string& cmdPrefix,
88  const std::string& cmdPostfix);
90  std::ostream& stream,
91  const std::string& file,
92  const std::string& cmdPrefix,
93  const std::string& cmdPostfix);
94  template<typename T>
95  void findFiles(
96  const std::string& perlre,
97  T files,
98  std::list<std::string>& found);
99  template<typename T>
100  void findFiles(const std::string& perlre, T& files);
101  void findText(
102  const std::string& perlre,
103  const unsigned int& matchRegion,
104  const std::string& fileName,
105  std::list<std::string>& found);
106  void getBlockOrder(
107  std::list<std::string>& order);
108  void sortFilesFirst(
109  std::list<std::string>& toSort,
110  std::list<std::string>& acSort);
111  void sortFilesLast(
112  std::list<std::string>& toSort,
113  std::list<std::string>& acSort);
114  template <typename CONT>
115  void uniqueFileNames(
116  CONT& files,
117  const std::string& rootDirectory);
118  void prefixStrings(
119  std::list<std::string>& tlist,
120  const std::string& prefix,
121  int start = 0,
122  int end = -1);
123  void fetchFiles();
124  void packageFilesFirst();
125  void prepareFiles();
126 
127  // destination directory where scripts are generated.
128  std::string dstDir_;
129  // directory where processor generators output vhdl files are
130  std::string progeOutDir_;
131  // directory where processor generators shared HDL files are
132  std::string sharedOutDir_;
133  // directories where to read test bench vhdl files.
134  std::string testBenchDir_;
135 
136  // lists for file names
137  std::list<std::string> vhdlFiles_;
138  std::list<std::string> gcuicFiles_;
139  std::list<std::string> testBenchFiles_;
140 
141  // directory used by ghdl/modelsim as work directory when compiling
142  const std::string workDir_;
143  const std::string vhdlDir_;
144  const std::string verDir_;
145  const std::string gcuicDir_;
146  const std::string tbDir_;
147 
148  // file names for scripts to be generated
149  const std::string modsimCompileScriptName_;
150  const std::string ghdlCompileScriptName_;
151  const std::string iverilogCompileScriptName_;
152  const std::string modsimSimulateScriptName_;
153  const std::string ghdlSimulateScriptName_;
154  const std::string iverilogSimulateScriptName_;
155 
156  // test bench name
157  const std::string testbenchName_;
158  const std::string toplevelEntity_;
161 
162  // HDL simulation runtime in nanoseconds
163  const std::string simulationRuntime_;
164 };
165 
166 #include "ProGeScriptGenerator.icc"
167 
168 #endif
169 
ProGeScriptGenerator::ProGeScriptGenerator
ProGeScriptGenerator(const ProGe::HDL language, const IDF::MachineImplementation &idf, const std::string &dstDir, const std::string &progeOutDir, const std::string &sharedOutDir, const std::string &testBenchDir, const std::string &toplevelEntity, const std::string &simulationRuntime="52390")
Definition: ProGeScriptGenerator.cc:86
ProGeScriptGenerator::toplevelEntity_
const std::string toplevelEntity_
Definition: ProGeScriptGenerator.hh:158
ProGeScriptGenerator::idf_
const IDF::MachineImplementation & idf_
Definition: ProGeScriptGenerator.hh:159
ProGeScriptGenerator::generateModsimCompile
void generateModsimCompile()
Definition: ProGeScriptGenerator.cc:158
ProGeScriptGenerator::fetchFiles
void fetchFiles()
Definition: ProGeScriptGenerator.cc:716
ProGeScriptGenerator::gcuicFiles_
std::list< std::string > gcuicFiles_
Definition: ProGeScriptGenerator.hh:138
ProGeScriptGenerator::outputScriptCommands
void outputScriptCommands(std::ostream &stream, const std::list< std::string > &files, const std::string &cmdPrefix, const std::string &cmdPostfix)
Definition: ProGeScriptGenerator.cc:469
Exception.hh
ProGeScriptGenerator::generateIverilogSimulate
void generateIverilogSimulate()
Definition: ProGeScriptGenerator.cc:374
ProGeScriptGenerator::generateGhdlCompile
void generateGhdlCompile()
Definition: ProGeScriptGenerator.cc:226
ProGeScriptGenerator::findText
void findText(const std::string &perlre, const unsigned int &matchRegion, const std::string &fileName, std::list< std::string > &found)
Definition: ProGeScriptGenerator.cc:515
ProGeScriptGenerator::testbenchName_
const std::string testbenchName_
Definition: ProGeScriptGenerator.hh:157
ProGeScriptGenerator::findFiles
void findFiles(const std::string &perlre, T files, std::list< std::string > &found)
ProGeScriptGenerator::generateIverilogCompile
void generateIverilogCompile()
Definition: ProGeScriptGenerator.cc:271
ProGeScriptGenerator::generateSimulationStart
void generateSimulationStart(std::ostream &stream)
Definition: ProGeScriptGenerator.cc:442
ProGeScriptGenerator::gcuicDir_
const std::string gcuicDir_
Definition: ProGeScriptGenerator.hh:145
ProGeScriptGenerator::getBlockOrder
void getBlockOrder(std::list< std::string > &order)
Definition: ProGeScriptGenerator.cc:644
ProGeScriptGenerator::vhdlDir_
const std::string vhdlDir_
Definition: ProGeScriptGenerator.hh:143
ProGeScriptGenerator::generateCompileStart
void generateCompileStart(std::ostream &stream)
Definition: ProGeScriptGenerator.cc:419
ProGeScriptGenerator::sortFilesLast
void sortFilesLast(std::list< std::string > &toSort, std::list< std::string > &acSort)
Definition: ProGeScriptGenerator.cc:606
ProGeScriptGenerator::ghdlSimulateScriptName_
const std::string ghdlSimulateScriptName_
Definition: ProGeScriptGenerator.hh:153
ProGeScriptGenerator::modsimCompileScriptName_
const std::string modsimCompileScriptName_
Definition: ProGeScriptGenerator.hh:149
ProGeScriptGenerator::sharedOutDir_
std::string sharedOutDir_
Definition: ProGeScriptGenerator.hh:132
ProGeScriptGenerator::ghdlCompileScriptName_
const std::string ghdlCompileScriptName_
Definition: ProGeScriptGenerator.hh:150
ProGeScriptGenerator::language_
const ProGe::HDL language_
Definition: ProGeScriptGenerator.hh:160
ProGeScriptGenerator::iverilogCompileScriptName_
const std::string iverilogCompileScriptName_
Definition: ProGeScriptGenerator.hh:151
ProGeScriptGenerator::dstDir_
std::string dstDir_
Definition: ProGeScriptGenerator.hh:128
ProGeScriptGenerator
Definition: ProGeScriptGenerator.hh:52
ProGeScriptGenerator::packageFilesFirst
void packageFilesFirst()
Definition: ProGeScriptGenerator.cc:774
ProGeScriptGenerator::iverilogSimulateScriptName_
const std::string iverilogSimulateScriptName_
Definition: ProGeScriptGenerator.hh:154
ProGeScriptGenerator::progeOutDir_
std::string progeOutDir_
Definition: ProGeScriptGenerator.hh:130
ProGeScriptGenerator::~ProGeScriptGenerator
virtual ~ProGeScriptGenerator()
Definition: ProGeScriptGenerator.cc:125
ProGeScriptGenerator::verDir_
const std::string verDir_
Definition: ProGeScriptGenerator.hh:144
ProGeTypes.hh
ProGeScriptGenerator::tbDir_
const std::string tbDir_
Definition: ProGeScriptGenerator.hh:146
ProGeScriptGenerator::generateAll
void generateAll()
Definition: ProGeScriptGenerator.cc:136
ProGeScriptGenerator::prepareFiles
void prepareFiles()
Definition: ProGeScriptGenerator.cc:796
ProGeScriptGenerator::createExecutableFile
void createExecutableFile(const std::string &fileName)
Definition: ProGeScriptGenerator.cc:403
ProGeScriptGenerator::simulationRuntime_
const std::string simulationRuntime_
Definition: ProGeScriptGenerator.hh:163
ProGeScriptGenerator.icc
ProGeScriptGenerator::generateModsimSimulate
void generateModsimSimulate()
Definition: ProGeScriptGenerator.cc:303
ProGeScriptGenerator::prefixStrings
void prefixStrings(std::list< std::string > &tlist, const std::string &prefix, int start=0, int end=-1)
Definition: ProGeScriptGenerator.cc:693
ProGeScriptGenerator::outputScriptCommand
void outputScriptCommand(std::ostream &stream, const std::string &file, const std::string &cmdPrefix, const std::string &cmdPostfix)
Definition: ProGeScriptGenerator.cc:493
ProGeScriptGenerator::sortFilesFirst
void sortFilesFirst(std::list< std::string > &toSort, std::list< std::string > &acSort)
Definition: ProGeScriptGenerator.cc:561
ProGeScriptGenerator::uniqueFileNames
void uniqueFileNames(CONT &files, const std::string &rootDirectory)
ProGe::HDL
HDL
HDLs supported by ProGe.
Definition: ProGeTypes.hh:40
ProGeScriptGenerator::testBenchFiles_
std::list< std::string > testBenchFiles_
Definition: ProGeScriptGenerator.hh:139
ProGeScriptGenerator::workDir_
const std::string workDir_
Definition: ProGeScriptGenerator.hh:142
ProGeScriptGenerator::testBenchDir_
std::string testBenchDir_
Definition: ProGeScriptGenerator.hh:134
ProGeScriptGenerator::vhdlFiles_
std::list< std::string > vhdlFiles_
Definition: ProGeScriptGenerator.hh:137
IDF::MachineImplementation
Definition: MachineImplementation.hh:54
IDF
Definition: DSDBManager.hh:54
ProGeScriptGenerator::generateGhdlSimulate
void generateGhdlSimulate()
Definition: ProGeScriptGenerator.cc:344
ProGeScriptGenerator::modsimSimulateScriptName_
const std::string modsimSimulateScriptName_
Definition: ProGeScriptGenerator.hh:152