PandA-2024.02
language_writer.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
45 #include "language_writer.hpp"
46 
48 #include "copyrights_strings.hpp"
49 
50 #include "VHDL_writer.hpp"
51 #include "structural_objects.hpp"
52 #include "sv_writer.hpp"
53 #include "verilog_writer.hpp"
54 
55 #include "exceptions.hpp"
56 
58 #include "Parameter.hpp"
59 
62 
63 language_writer::language_writer(char open_char, char close_char, const ParameterConstRef _parameters)
64  : indented_output_stream(new IndentedOutputStream(open_char, close_char, 2)),
65  parameters(_parameters),
66  debug_level(_parameters->getOption<int>(OPT_debug_level))
67 {
68 }
69 
71 
72 unsigned int language_writer::bitnumber(long long unsigned int n)
73 {
74  unsigned int count = 0;
75  while(n)
76  {
77  count++;
78  n >>= 1;
79  }
80  if(count == 0)
81  {
82  return 1;
83  }
84  return count;
85 }
86 
88  const technology_managerConstRef _TM,
89  const ParameterConstRef _parameters)
90 {
91  THROW_ASSERT(_parameters, "");
92  switch(language)
93  {
95  return language_writerRef(new verilog_writer(_parameters));
96  break;
98  return language_writerRef(new system_verilog_writer(_parameters));
99  break;
101  return language_writerRef(new VHDL_writer(_TM, _parameters));
102  break;
103  default:
104  THROW_ERROR("HDL backend language not supported");
105  }
106  return language_writerRef();
107 }
108 
109 void language_writer::write(const std::string& rawString)
110 {
111  indented_output_stream->Append(rawString);
112 }
113 
115 {
116 }
117 
118 const std::string language_writer::WriteString() const
119 {
121 }
122 
123 void language_writer::WriteFile(const std::string& filename) const
124 {
126 }
127 
129 {
131  ret.insert(RESET_PORT_NAME);
132  ret.insert(CLOCK_PORT_NAME);
133  ret.insert(DONE_PORT_NAME);
134  ret.insert(START_PORT_NAME);
135  ret.insert(WENABLE_PORT_NAME);
136  ret.insert(RETURN_PORT_NAME);
137  return ret;
138 }
139 
141 
143 {
144  for(auto& row : COPYING3_SHORT)
145  {
146  write_comment(std::string(row));
147  }
148 }
refcount< language_writer > language_writerRef
RefCount definition of the class.
void WriteFile(const std::string &filename) const
Write content to a file.
void WriteFile(const std::string &file_name)
Write the indented output on a file.
#define START_PORT_NAME
std::string filename
This class defines the methods to write VHDL descriptions.
exceptions managed by PandA
language_writer(char open_char, char close_char, const ParameterConstRef parameters)
Constructor.
static language_writerRef create_writer(HDLWriter_Language language, const technology_managerConstRef TM, const ParameterConstRef parameters)
Creates the specialization of the writer based on the desired language.
void WriteLicense()
Write the license.
Class to print indented code.
const IndentedOutputStreamRef indented_output_stream
Represents the stream we are currently writing to.
#define COPYING3_SHORT_MACRO
#define WENABLE_PORT_NAME
#define RETURN_PORT_NAME
virtual void write(const std::string &rawString)
Writes a raw string into the stream.
HDLWriter_Language
const std::string WriteString() const
Dump the content of the write as a string.
const std::string WriteString()
Write the indented output on a string.
#define CLOCK_PORT_NAME
standard name for ports
Class for system verilog writing.
#define DONE_PORT_NAME
virtual void write_header()
Writes the header part of the file.
void Append(const std::string &str)
Append a string to the output.
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
virtual ~language_writer()
Destructor.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
CustomSet< std::string > GetHDLReservedNames() const
Return the names of auxiliary signals which will be used by backend.
This class describes all classes used to represent a structural object.
static unsigned int bitnumber(unsigned long long n)
Counts the number of bits in an unsigned int.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
It collects all the common strings covering PandA copyrights issues.
this class is used to manage the command-line or XML options.
#define RESET_PORT_NAME
Class to print indented code.
virtual void write_comment(const std::string &comment_string)=0
Prints a comment.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

Generated on Mon Feb 12 2024 13:02:51 for PandA-2024.02 by doxygen 1.8.13