OpenASIP  2.0
TestbenchGenerator.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 TestbenchGenerator.hh
26  *
27  * Declaration of TestbenchGenerator class
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_TESTBENCH_GENERATOR_HH
34 #define TTA_TESTBENCH_GENERATOR_HH
35 
36 #include <string>
37 #include <sstream>
38 #include <fstream>
39 #include <vector>
40 #include <map>
41 #include <stdint.h>
42 
43 namespace HDB {
44  class HWBlockImplementation;
45 }
46 
48 public:
50 
51  virtual ~TestbenchGenerator();
52 
53  virtual void generateTestbench(std::ofstream& file) = 0;
54 
55 protected:
56  typedef std::map<std::string, std::vector<uint32_t> > PortDataArray;
57 
58  virtual void writeStimulusArray(
59  std::ostringstream& stream,
60  std::vector<uint32_t>& dataArray,
61  std::string portName,
62  int portWidth);
63 
64  void writeTbConstants(int totalCycles, int outputIgnoreCycles);
65 
66  void writeTestbench(
67  std::ofstream& file, HDB::HWBlockImplementation* impl);
68 
69  std::ostringstream& declarationStream();
70  std::ostringstream& bindingStream();
71  std::ostringstream& signalStream();
72  std::ostringstream& instantiationStream();
73  std::ostringstream& inputArrayStream();
74  std::ostringstream& opcodeArrayStream();
75  std::ostringstream& loadArrayStream();
76  std::ostringstream& outputArrayStream();
77  std::ostringstream& tbCodeStream();
78 
79 private:
80  std::string findVhdlTemplate() const;
81 
82  void loadVhdlTemplate(
83  const std::string& fileName, std::string& vhdlTemplate) const;
84 
85  std::ostringstream componentDeclaration_;
86  std::ostringstream componentBinding_;
87  std::ostringstream signalDeclaration_;
88  std::ostringstream componentInstantiation_;
89  std::ostringstream inputArrays_;
90  std::ostringstream opcodeArrays_;
91  std::ostringstream loadSignalArrays_;
92  std::ostringstream outputArrays_;
93  std::ostringstream testbenchCode_;
94 
95  static const std::string TB_TEMPLATE_;
96 };
97 
98 #endif
TestbenchGenerator::bindingStream
std::ostringstream & bindingStream()
Definition: TestbenchGenerator.cc:188
TestbenchGenerator::tbCodeStream
std::ostringstream & tbCodeStream()
Definition: TestbenchGenerator.cc:223
TestbenchGenerator::writeTestbench
void writeTestbench(std::ofstream &file, HDB::HWBlockImplementation *impl)
Definition: TestbenchGenerator.cc:116
TestbenchGenerator::opcodeArrayStream
std::ostringstream & opcodeArrayStream()
Definition: TestbenchGenerator.cc:208
HDB
Definition: CostDatabase.hh:49
TestbenchGenerator::instantiationStream
std::ostringstream & instantiationStream()
Definition: TestbenchGenerator.cc:198
TestbenchGenerator::writeTbConstants
void writeTbConstants(int totalCycles, int outputIgnoreCycles)
Definition: TestbenchGenerator.cc:104
TestbenchGenerator::componentDeclaration_
std::ostringstream componentDeclaration_
Definition: TestbenchGenerator.hh:85
TestbenchGenerator::inputArrays_
std::ostringstream inputArrays_
Definition: TestbenchGenerator.hh:89
TestbenchGenerator::inputArrayStream
std::ostringstream & inputArrayStream()
Definition: TestbenchGenerator.cc:203
TestbenchGenerator::writeStimulusArray
virtual void writeStimulusArray(std::ostringstream &stream, std::vector< uint32_t > &dataArray, std::string portName, int portWidth)
Definition: TestbenchGenerator.cc:68
TestbenchGenerator::TB_TEMPLATE_
static const std::string TB_TEMPLATE_
Definition: TestbenchGenerator.hh:95
TestbenchGenerator::componentBinding_
std::ostringstream componentBinding_
Definition: TestbenchGenerator.hh:86
TestbenchGenerator::declarationStream
std::ostringstream & declarationStream()
Definition: TestbenchGenerator.cc:183
TestbenchGenerator::loadSignalArrays_
std::ostringstream loadSignalArrays_
Definition: TestbenchGenerator.hh:91
TestbenchGenerator::TestbenchGenerator
TestbenchGenerator()
Definition: TestbenchGenerator.cc:57
TestbenchGenerator::signalStream
std::ostringstream & signalStream()
Definition: TestbenchGenerator.cc:193
TestbenchGenerator::componentInstantiation_
std::ostringstream componentInstantiation_
Definition: TestbenchGenerator.hh:88
HDB::HWBlockImplementation
Definition: HWBlockImplementation.hh:49
TestbenchGenerator::opcodeArrays_
std::ostringstream opcodeArrays_
Definition: TestbenchGenerator.hh:90
TestbenchGenerator::~TestbenchGenerator
virtual ~TestbenchGenerator()
Definition: TestbenchGenerator.cc:63
TestbenchGenerator::findVhdlTemplate
std::string findVhdlTemplate() const
Definition: TestbenchGenerator.cc:142
TestbenchGenerator
Definition: TestbenchGenerator.hh:47
TestbenchGenerator::PortDataArray
std::map< std::string, std::vector< uint32_t > > PortDataArray
Definition: TestbenchGenerator.hh:56
TestbenchGenerator::loadArrayStream
std::ostringstream & loadArrayStream()
Definition: TestbenchGenerator.cc:213
TestbenchGenerator::loadVhdlTemplate
void loadVhdlTemplate(const std::string &fileName, std::string &vhdlTemplate) const
Definition: TestbenchGenerator.cc:163
TestbenchGenerator::signalDeclaration_
std::ostringstream signalDeclaration_
Definition: TestbenchGenerator.hh:87
TestbenchGenerator::generateTestbench
virtual void generateTestbench(std::ofstream &file)=0
TestbenchGenerator::outputArrayStream
std::ostringstream & outputArrayStream()
Definition: TestbenchGenerator.cc:218
TestbenchGenerator::outputArrays_
std::ostringstream outputArrays_
Definition: TestbenchGenerator.hh:92
TestbenchGenerator::testbenchCode_
std::ostringstream testbenchCode_
Definition: TestbenchGenerator.hh:93