OpenASIP
2.0
src
applibs
PIG
VhdlProgramImageWriter.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 VhdlProgramImageWriter.cc
26
*
27
* Implementation of VhdlProgramImageWriter class.
28
*
29
* @author Otto Esko 2010 (otto.esko-no.spam-tut.fi)
30
* @note rating: red
31
*/
32
33
#include <iostream>
34
#include "
InstructionBitVector.hh
"
35
#include "
ArrayProgramImageWriter.hh
"
36
#include "
VhdlProgramImageWriter.hh
"
37
using
std::endl;
38
39
/**
40
* The constructor.
41
*
42
* @param bits The bits to write.
43
* @param rowLength Length of the rows to write.
44
*/
45
VhdlProgramImageWriter::VhdlProgramImageWriter
(
46
const
InstructionBitVector
& bits,
const
std::string& entityName):
47
ArrayProgramImageWriter
(bits), entityName_(entityName) {
48
}
49
50
/**
51
* The destructor.
52
*/
53
VhdlProgramImageWriter::~VhdlProgramImageWriter
() {
54
}
55
56
57
/**
58
* Writes the bit image to the given stream.
59
*
60
* @param stream The stream to write.
61
*/
62
void
VhdlProgramImageWriter::writeImage
(std::ostream& stream)
const
{
63
writeHeader
(stream);
64
ArrayProgramImageWriter::writeImage
(stream);
65
writeEnding
(stream);
66
}
67
68
/**
69
* Writes the vhdl declaration stuff to the beginning of the stream
70
*/
71
void
VhdlProgramImageWriter::writeHeader
(std::ostream& stream)
const
{
72
stream <<
"library ieee;"
<< endl
73
<<
"use ieee.std_logic_1164.all;"
<< endl
74
<<
"use ieee.std_logic_arith.all;"
<< endl
75
<<
"use work."
;
76
if
(!
entityName_
.empty()) {
77
stream <<
entityName_
<<
"_"
;
78
}
79
stream <<
"imem_mau.all;"
<< endl << endl;
80
81
stream <<
"package "
<<
packageName
() <<
" is"
<< endl << endl
82
<<
" type std_logic_imem_matrix is array (natural range <>) of "
83
<<
"std_logic_vector(IMEMMAUWIDTH-1 downto 0);"
<< endl << endl;
84
85
stream <<
" constant imem_array : std_logic_imem_matrix := ("
<< endl;
86
}
87
88
/**
89
* Writes the end declarations to the stream
90
*/
91
void
VhdlProgramImageWriter::writeEnding
(std::ostream& stream)
const
{
92
stream <<
");"
<< endl << endl
93
<<
"end "
<<
packageName
() <<
";"
<< endl;
94
}
95
96
std::string
97
VhdlProgramImageWriter::packageName
()
const
{
98
99
std::string
package
= "imem_image";
100
if
(!
entityName_
.empty()) {
101
package
= entityName_ + "_" + package;
102
}
103
return
package;
104
}
VhdlProgramImageWriter::writeHeader
void writeHeader(std::ostream &stream) const
Definition:
VhdlProgramImageWriter.cc:71
InstructionBitVector.hh
VhdlProgramImageWriter::entityName_
std::string entityName_
Definition:
VhdlProgramImageWriter.hh:58
ArrayProgramImageWriter::writeImage
virtual void writeImage(std::ostream &stream) const
Definition:
ArrayProgramImageWriter.cc:60
VhdlProgramImageWriter::VhdlProgramImageWriter
VhdlProgramImageWriter(const InstructionBitVector &bits, const std::string &entityName)
Definition:
VhdlProgramImageWriter.cc:45
ArrayProgramImageWriter.hh
VhdlProgramImageWriter::writeEnding
void writeEnding(std::ostream &stream) const
Definition:
VhdlProgramImageWriter.cc:91
VhdlProgramImageWriter::~VhdlProgramImageWriter
virtual ~VhdlProgramImageWriter()
Definition:
VhdlProgramImageWriter.cc:53
ArrayProgramImageWriter
Definition:
ArrayProgramImageWriter.hh:44
VhdlProgramImageWriter.hh
VhdlProgramImageWriter::writeImage
virtual void writeImage(std::ostream &stream) const
Definition:
VhdlProgramImageWriter.cc:62
VhdlProgramImageWriter::packageName
std::string packageName() const
Definition:
VhdlProgramImageWriter.cc:97
InstructionBitVector
Definition:
InstructionBitVector.hh:50
Generated by
1.8.17