OpenASIP 2.2
Loading...
Searching...
No Matches
VerilogNetlistWriter.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2012-2015 Vinogradov Viacheslav.
3
4 This file is going to be a 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 VerilogNetlistWriter.hh
26 *
27 * Declaration of VerilogNetlistWriter class based on VHDLnetlistWriter
28 *
29 * @author Vinogradov Viacheslav 2012
30 * @author Henry Linjamäki 2015 (henry.linjamaki-no.spam.tut.fi)
31 * @note rating: red
32 */
33
34#ifndef TTA_VERILOG_NETLIST_WRITER_HH
35#define TTA_VERILOG_NETLIST_WRITER_HH
36
37#include <map>
38#include <string>
39#include <boost/graph/graph_traits.hpp>
40
41#include "NetlistWriter.hh"
42#include "Netlist.hh"
43#include "ProGeTypes.hh"
44
45namespace ProGe {
46
47class BaseNetlistBlock;
48
49/**
50 * Writes Verilog files which implement the given netlist.
51 */
53public:
54 VerilogNetlistWriter(const BaseNetlistBlock& targetBlock);
55 virtual ~VerilogNetlistWriter();
56
57 virtual void write(const std::string& dstDirectory);
58
59 static void writeGenericDeclaration(
60 const BaseNetlistBlock& block,
61 unsigned int indentationLevel,
62 const std::string& indentation,
63 std::ostream& stream);
64 static void writePortDeclaration(
65 const BaseNetlistBlock& block,
66 unsigned int indentationLevel,
67 const std::string& indentation,
68 std::ostream& stream);
69
70private:
71 typedef boost::graph_traits<Netlist>::vertex_descriptor
73 typedef boost::graph_traits<Netlist>::edge_descriptor
75 typedef boost::graph_traits<Netlist>::out_edge_iterator
77
78 void writeNetlistParameterPackage(const std::string& dstDirectory) const;
79 std::string netlistParameterPkgName() const;
80 void writeBlock(
81 const BaseNetlistBlock& block, const std::string& dstDirectory);
83 const BaseNetlistBlock& block,
84 std::ofstream& stream);
86 const BaseNetlistBlock& block,
87 std::ofstream& stream) const;
88
90 const BaseNetlistBlock& block,
91 std::ofstream& stream) const;
93 const BaseNetlistBlock& block,
94 std::ofstream& stream) const;
95 std::string indentation(unsigned int level) const;
96
97 /**
98 * Tries to determine whether the string generic needs quot marks for
99 * generic mapping
100 *
101 * If string literal contains '.', or "__" it cannot be a valid
102 * Verilog label (i.e. another generic), thus it needs quotation marks.
103 *
104 * @param generic String generic value
105 * @return Generic mapping string
106 */
107 TCEString genericMapStringValue(const TCEString& generic) const;
108
109 static std::string directionString(Direction direction);
110 static std::string generateIndentation(
111 unsigned int level, const std::string& indentation);
112 static bool isNumber(const std::string& formula);
113 static std::string portSignalName(const NetlistPort& port);
114 static std::string portSignalType(const NetlistPort& port);
115
116 /// Width of the ground signal.
118
119};
120}
121
122#endif
void writeSignalDeclarations(const BaseNetlistBlock &block, std::ofstream &stream)
std::string indentation(unsigned int level) const
void writePortMappings(const BaseNetlistBlock &block, std::ofstream &stream) const
static std::string portSignalName(const NetlistPort &port)
boost::graph_traits< Netlist >::out_edge_iterator out_edge_iterator
static std::string portSignalType(const NetlistPort &port)
virtual void write(const std::string &dstDirectory)
static void writeGenericDeclaration(const BaseNetlistBlock &block, unsigned int indentationLevel, const std::string &indentation, std::ostream &stream)
void writeBlock(const BaseNetlistBlock &block, const std::string &dstDirectory)
boost::graph_traits< Netlist >::vertex_descriptor vertex_descriptor
int groundWidth_
Width of the ground signal.
TCEString genericMapStringValue(const TCEString &generic) const
static std::string generateIndentation(unsigned int level, const std::string &indentation)
static std::string directionString(Direction direction)
static void writePortDeclaration(const BaseNetlistBlock &block, unsigned int indentationLevel, const std::string &indentation, std::ostream &stream)
void writeComponentDeclarations(const BaseNetlistBlock &block, std::ofstream &stream) const
void writeNetlistParameterPackage(const std::string &dstDirectory) const
void writeSignalAssignments(const BaseNetlistBlock &block, std::ofstream &stream) const
std::string netlistParameterPkgName() const
boost::graph_traits< Netlist >::edge_descriptor edge_descriptor
static bool isNumber(const std::string &formula)
Definition FUGen.hh:54
Direction
Direction of the port.
Definition ProGeTypes.hh:52