OpenASIP  2.0
ImplementationSimulator.cc
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 ImplementationSimulator.cc
26  *
27  * Implementation of ImplementationSimulator
28  *
29  * @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include <string>
34 #include <vector>
35 
37 #include "FileSystem.hh"
38 
39 using std::string;
40 using std::vector;
41 
43  std::string tbFile,
44  std::vector<std::string> hdlFiles,
45  bool verbose,
46  bool leaveDirty):
47  tbFile_(tbFile),
48  hdlFiles_(hdlFiles), baseDir_(""), workDir_(""), oldCwd_(""),
49  verbose_(verbose), leaveDirty_(leaveDirty) {
50 
53 }
54 
56  if (!workDir_.empty() && FileSystem::fileExists(workDir_)) {
57  if (!leaveDirty_) {
59  }
60  }
61  if (!oldCwd_.empty()) {
63  }
64 }
65 
67  string work = baseDir_ + FileSystem::DIRECTORY_SEPARATOR + "work";
68  if (!FileSystem::createDirectory(work)) {
69  work = "";
70  }
71  workDir_ = work;
72  return workDir_;
73 }
74 
75 void ImplementationSimulator::setWorkDir(std::string dir) {
76  workDir_ = dir;
77 }
78 
79 std::string ImplementationSimulator::workDir() const {
80  return workDir_;
81 }
82 
84  return baseDir_;
85 }
86 
87 std::string ImplementationSimulator::tbFile() const {
88  return tbFile_;
89 }
90 
92  return hdlFiles_.size();
93 }
94 
95 std::string ImplementationSimulator::file(int index) const {
96  return hdlFiles_.at(index);
97 }
98 
100  return verbose_;
101 }
102 
103 void
105  std::vector<std::string>& inputMsg, std::vector<std::string>& errors) {
106  string tag = "TCE Assert";
107  for (unsigned int i = 0; i < inputMsg.size(); i++) {
108  string::size_type loc = inputMsg.at(i).find(tag, 0);
109  if (loc != string::npos) {
110  string errorMsg = FileSystem::fileOfPath(tbFile_) + ": "
111  + inputMsg.at(i);
112  errors.push_back(errorMsg);
113  }
114  }
115 }
ImplementationSimulator::hdlFiles_
std::vector< std::string > hdlFiles_
Vector containing other vhdl files needed to compile testbench.
Definition: ImplementationSimulator.hh:80
FileSystem.hh
FileSystem::removeFileOrDirectory
static bool removeFileOrDirectory(const std::string &path)
Definition: FileSystem.cc:493
ImplementationSimulator::verbose
bool verbose()
Definition: ImplementationSimulator.cc:99
ImplementationSimulator::tbDirectory
std::string tbDirectory() const
Definition: ImplementationSimulator.cc:83
FileSystem::createDirectory
static bool createDirectory(const std::string &path)
Definition: FileSystem.cc:400
ImplementationSimulator::parseErrorMessages
void parseErrorMessages(std::vector< std::string > &inputMsg, std::vector< std::string > &errors)
Definition: ImplementationSimulator.cc:104
ImplementationSimulator::file
std::string file(int index) const
Definition: ImplementationSimulator.cc:95
ImplementationSimulator::createWorkDir
virtual std::string createWorkDir()
Definition: ImplementationSimulator.cc:66
ImplementationSimulator::workDir_
std::string workDir_
Working directory where testbench is compiled and simulated.
Definition: ImplementationSimulator.hh:84
FileSystem::fileOfPath
static std::string fileOfPath(const std::string pathName)
Definition: FileSystem.cc:101
ImplementationSimulator::tbFile
std::string tbFile() const
Definition: ImplementationSimulator.cc:87
ImplementationSimulator::hdlFileCount
int hdlFileCount() const
Definition: ImplementationSimulator.cc:91
ImplementationSimulator::baseDir_
std::string baseDir_
Directory path of testbench file.
Definition: ImplementationSimulator.hh:82
ImplementationSimulator.hh
FileSystem::directoryOfPath
static std::string directoryOfPath(const std::string fileName)
Definition: FileSystem.cc:79
ImplementationSimulator::workDir
std::string workDir() const
Definition: ImplementationSimulator.cc:79
ImplementationSimulator::leaveDirty_
bool leaveDirty_
Don't delete work dir.
Definition: ImplementationSimulator.hh:90
ImplementationSimulator::oldCwd_
std::string oldCwd_
Old current working directory (before changing to workDir_)
Definition: ImplementationSimulator.hh:86
ImplementationSimulator::tbFile_
std::string tbFile_
Testbench file name with path.
Definition: ImplementationSimulator.hh:78
ImplementationSimulator::verbose_
bool verbose_
Enable verbose output.
Definition: ImplementationSimulator.hh:88
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
FileSystem::changeWorkingDir
static bool changeWorkingDir(const std::string &path)
Definition: FileSystem.cc:185
ImplementationSimulator::setWorkDir
void setWorkDir(std::string dir)
Definition: ImplementationSimulator.cc:75
FileSystem::fileExists
static bool fileExists(const std::string fileName)
FileSystem::currentWorkingDir
static std::string currentWorkingDir()
Definition: FileSystem.cc:142
ImplementationSimulator::~ImplementationSimulator
virtual ~ImplementationSimulator()
Definition: ImplementationSimulator.cc:55
ImplementationSimulator::ImplementationSimulator
ImplementationSimulator()