OpenASIP  2.0
ProgramImageGenerator.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 ProgramImageGenerator.hh
26  *
27  * Declaration of ProgramImageGenerator class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @author Otto Esko 2008 (otto.esko-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_PROGRAM_IMAGE_GENERATOR_HH
35 #define TTA_PROGRAM_IMAGE_GENERATOR_HH
36 
37 #include <iostream>
38 #include <set>
39 #include <string>
40 
41 #include "CodeCompressorPlugin.hh"
42 #include "BaseType.hh"
43 #include "PluginTools.hh"
44 #include "Exception.hh"
45 #include "TCEString.hh"
46 
47 namespace TPEF {
48  class Binary;
49  class InstructionElement;
50  class DataSection;
51  class Section;
52 }
53 
54 namespace TTAMachine {
55  class Machine;
56 }
57 
58 class BinaryEncoding;
60 
61 /**
62  * The main class of program image generator module.
63  *
64  * This class provides the interface that is available to different user
65  * interfaces.
66  */
68 public:
69 
70  /// Different output formats of images.
71  enum OutputFormat {
72  BINARY, ///< Real binary format.
73  ASCII, ///< ASCII 1's and 0's.
74  ARRAY, ///< ASCII 1's and 0's in array form.
75  MIF, ///< MIF Memory Initialization File
76  VHDL, ///< Array as a Vhdl package
77  COE, ///< COE memory initialization format
78  HEX, ///< HEX memory initialization format
79  BIN2N /// Binary format padded to 2**n
80  };
81  typedef std::map<std::string, TPEF::Binary*> TPEFMap;
82 
84  virtual ~ProgramImageGenerator();
85 
86 
87  void loadCompressorPlugin(const std::string& fileName);
90  void loadPrograms(TPEFMap programs);
92  void loadBEM(const BinaryEncoding& bem);
93 
95  const std::string& programName,
96  std::ostream& stream,
97  OutputFormat format,
98  int mausPerLine = 0);
99  void generateDataImage(
100  const std::string& programName, TPEF::Binary& program,
101  const std::string& addressSpace, std::ostream& stream,
102  OutputFormat format, int mausPerLine, bool usePregeneratedImage);
103  void generateDecompressor(std::ostream& stream, TCEString entityStr);
104 
105  int imemMauWidth() const;
107 
108  void setEntityName(const std::string& entity);
109 
110  static std::vector<std::string> availableCompressors();
111  static void printCompressorDescription(
112  const std::string& fileName, std::ostream& stream);
113 
115  BitVector& bitVector,
116  const std::string& addressSpace,
117  TPEF::Section& section);
118 
119 private:
120  /// Typedef for program set.
121  typedef std::set<TPEF::Binary*> ProgramSet;
122 
124  const std::string& fileName, PluginTools& pluginTool);
126  const TPEF::Binary& program,
127  const TPEF::DataSection& dataSection,
128  Word dataSectionOffset) const;
129 
130  /// The code compressor.
132  /// Toplevel entity name
133  std::string entityName_;
134  /// The plugin tool.
136 
137 };
138 
139 #endif
ProgramImageGenerator::generateProgramImage
void generateProgramImage(const std::string &programName, std::ostream &stream, OutputFormat format, int mausPerLine=0)
Definition: ProgramImageGenerator.cc:185
BinaryEncoding
Definition: BinaryEncoding.hh:61
ProgramImageGenerator::availableCompressors
static std::vector< std::string > availableCompressors()
Definition: ProgramImageGenerator.cc:609
BaseType.hh
ProgramImageGenerator::loadBEM
void loadBEM(const BinaryEncoding &bem)
Definition: ProgramImageGenerator.cc:162
ProgramImageGenerator::loadCompressorParameters
void loadCompressorParameters(CodeCompressorPlugin::ParameterTable parameters)
Definition: ProgramImageGenerator.cc:127
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
Exception.hh
PluginTools
Definition: PluginTools.hh:53
TPEF::InstructionElement
Definition: InstructionElement.hh:77
BitVector
Definition: BitVector.hh:44
ProgramImageGenerator::ProgramSet
std::set< TPEF::Binary * > ProgramSet
Typedef for program set.
Definition: ProgramImageGenerator.hh:121
TPEF::Binary
Definition: Binary.hh:49
ProgramImageGenerator::ASCII
@ ASCII
ASCII 1's and 0's.
Definition: ProgramImageGenerator.hh:73
ProgramImageGenerator::~ProgramImageGenerator
virtual ~ProgramImageGenerator()
Definition: ProgramImageGenerator.cc:99
ProgramImageGenerator::createCompressor
static CodeCompressorPlugin * createCompressor(const std::string &fileName, PluginTools &pluginTool)
Definition: ProgramImageGenerator.cc:666
TPEF::DataSection
Definition: DataSection.hh:52
ProgramImageGenerator::loadPrograms
void loadPrograms(TPEFMap programs)
Definition: ProgramImageGenerator.cc:140
ProgramImageGenerator::loadCompressorPlugin
void loadCompressorPlugin(const std::string &fileName)
Definition: ProgramImageGenerator.cc:114
ProgramImageGenerator::printCompressorDescription
static void printCompressorDescription(const std::string &fileName, std::ostream &stream)
Definition: ProgramImageGenerator.cc:645
ProgramImageGenerator::relocTarget
TPEF::InstructionElement * relocTarget(const TPEF::Binary &program, const TPEF::DataSection &dataSection, Word dataSectionOffset) const
Definition: ProgramImageGenerator.cc:694
ProgramImageGenerator::MIF
@ MIF
MIF Memory Initialization File.
Definition: ProgramImageGenerator.hh:75
TPEF::Section
Definition: Section.hh:64
ProgramImageGenerator::HEX
@ HEX
HEX memory initialization format.
Definition: ProgramImageGenerator.hh:78
TCEString.hh
ProgramImageGenerator::imemMauWidth
int imemMauWidth() const
Definition: ProgramImageGenerator.cc:739
CodeCompressorPlugin::ParameterTable
std::vector< Parameter > ParameterTable
Table for passing plugin parameters.
Definition: CodeCompressorPlugin.hh:94
ProgramImageGenerator::loadMachine
void loadMachine(const TTAMachine::Machine &machine)
Definition: ProgramImageGenerator.cc:151
ProgramImageGenerator::generateDataImage
void generateDataImage(const std::string &programName, TPEF::Binary &program, const std::string &addressSpace, std::ostream &stream, OutputFormat format, int mausPerLine, bool usePregeneratedImage)
Definition: ProgramImageGenerator.cc:404
ProgramImageGenerator::entityName_
std::string entityName_
Toplevel entity name.
Definition: ProgramImageGenerator.hh:133
ProgramImageGenerator::setEntityName
void setEntityName(const std::string &entity)
Definition: ProgramImageGenerator.cc:746
ProgramImageGenerator
Definition: ProgramImageGenerator.hh:67
ProgramImageGenerator::VHDL
@ VHDL
Array as a Vhdl package.
Definition: ProgramImageGenerator.hh:76
PluginTools.hh
ProgramImageGenerator::writeDataSection
void writeDataSection(TPEF::Binary &program, BitVector &bitVector, const std::string &addressSpace, TPEF::Section &section)
Definition: ProgramImageGenerator.cc:510
ProgramImageGenerator::BINARY
@ BINARY
Real binary format.
Definition: ProgramImageGenerator.hh:72
ProgramImageGenerator::compressor_
CodeCompressorPlugin * compressor_
The code compressor.
Definition: ProgramImageGenerator.hh:131
CodeCompressorPlugin
Definition: CodeCompressorPlugin.hh:84
TCEString
Definition: TCEString.hh:53
ProgramImageGenerator::generateDecompressor
void generateDecompressor(std::ostream &stream, TCEString entityStr)
Definition: ProgramImageGenerator.cc:592
ProgramImageGenerator::BIN2N
@ BIN2N
Binary format padded to 2**n.
Definition: ProgramImageGenerator.hh:79
ProgramImageGenerator::pluginTool_
PluginTools pluginTool_
The plugin tool.
Definition: ProgramImageGenerator.hh:135
ProgramImageGenerator::ProgramImageGenerator
ProgramImageGenerator()
Definition: ProgramImageGenerator.cc:91
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
CodeCompressorPlugin.hh
TTAMachine
Definition: Assembler.hh:48
ProgramImageGenerator::compressor
CodeCompressorPlugin & compressor()
Definition: ProgramImageGenerator.hh:106
ProgramImageGenerator::OutputFormat
OutputFormat
Different output formats of images.
Definition: ProgramImageGenerator.hh:71
ProgramImageGenerator::COE
@ COE
COE memory initialization format.
Definition: ProgramImageGenerator.hh:77
ProgramImageGenerator::ARRAY
@ ARRAY
ASCII 1's and 0's in array form.
Definition: ProgramImageGenerator.hh:74
ProgramImageGenerator::TPEFMap
std::map< std::string, TPEF::Binary * > TPEFMap
Definition: ProgramImageGenerator.hh:81
TPEF
Definition: Assembler.hh:43
TTAMachine::Machine
Definition: Machine.hh:73