PandA-2024.02
verilog_writer.hpp
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  */
44 #ifndef VERILOG_WRITER_HPP
45 #define VERILOG_WRITER_HPP
46 
47 #include "language_writer.hpp"
48 
49 #include <list>
50 #include <map>
51 #include <set>
52 #include <string>
53 #include <vector>
54 
56 {
57  protected:
59  static const std::map<std::string, std::string> builtin_to_verilog_keyword;
60 
61  static const std::set<std::string> keywords;
62 
63  public:
64  static bool check_keyword_verilog(const std::string& word);
65 
69  std::string get_name() const override
70  {
71  return "verilog";
72  }
76  std::string get_extension() const override
77  {
78  return ".v";
79  }
84  void write_comment(const std::string& comment_string) override;
90  std::string type_converter(structural_type_descriptorRef Type) override;
96  std::string type_converter_size(const structural_objectRef& cir) override;
97 
103  std::string may_slice_string(const structural_objectRef& cir);
104 
109  void write_library_declaration(const structural_objectRef& cir) override;
114  void write_module_declaration(const structural_objectRef& cir) override;
124  void write_port_declaration(const structural_objectRef& cir, bool last_port_to_analyze) override;
129  void write_component_declaration(const structural_objectRef& cir) override;
134  void write_signal_declaration(const structural_objectRef& cir) override;
139  void write_module_definition_begin(const structural_objectRef& cir) override;
147  void write_module_instance_begin(const structural_objectRef& cir, const std::string& module_name,
148  bool write_parametrization) override;
149 
154  void write_module_instance_end(const structural_objectRef& cir) override;
160  void write_port_binding(const structural_objectRef& port, const structural_objectRef& object_bounded,
161  bool first_port_analyzed) override;
162  void write_vector_port_binding(const structural_objectRef& port, bool first_port_analyzed) override;
167  void write_module_definition_end(const structural_objectRef& cir) override;
181  void write_io_signal_post_fix(const structural_objectRef& port, const structural_objectRef& sig) override;
182  void write_io_signal_post_fix_vector(const structural_objectRef& port, const structural_objectRef& sig) override;
192  void write_module_parametrization(const structural_objectRef& cir) override;
197  void write_state_declaration(const structural_objectRef& cir, const std::list<std::string>& list_of_states,
198  const std::string& reset_port, const std::string& reset_state, bool one_hot) override;
206  void write_present_state_update(const structural_objectRef cir, const std::string& reset_state,
207  const std::string& reset_port, const std::string& clock_port,
208  const std::string& reset_type, bool connect_present_next_state_signals) override;
209 
220  bool single_proc, unsigned int output_index, const structural_objectRef& cir, const std::string& reset_state,
221  const std::string& reset_port, const std::string& start_port, const std::string& clock_port,
222  std::vector<std::string>::const_iterator& first, std::vector<std::string>::const_iterator& end, bool is_yosys,
223  const std::map<unsigned int, std::map<std::string, std::set<unsigned int>>>& bypass_signals) override;
224 
229  void write_NP_functionalities(const structural_objectRef& cir) override;
230 
234  void write_port_decl_header() override;
235 
239  void write_port_decl_tail() override;
240 
245 
250 
254  ~verilog_writer() override;
255 
256  void write_assign(const std::string& op0, const std::string& op1) override;
257 
258  bool has_output_prefix() const override
259  {
260  return true;
261  }
262 
263  bool check_keyword(const std::string& id) const override;
264 
265  void write_header() override;
266 
271  void WriteBuiltin(const structural_objectConstRef component) override;
272 };
273 
274 #endif
void write_port_decl_header() override
Write the header for port_decl.
void write_port_binding(const structural_objectRef &port, const structural_objectRef &object_bounded, bool first_port_analyzed) override
Write the binding of a port.
void write_signal_declaration(const structural_objectRef &cir) override
Write the declaration of a signal.
void write_assign(const std::string &op0, const std::string &op1) override
void WriteBuiltin(const structural_objectConstRef component) override
Write a builtin component.
std::string type_converter(structural_type_descriptorRef Type) override
Return a language based type string given a structural_type_descriptor.
void write_io_signal_post_fix_vector(const structural_objectRef &port, const structural_objectRef &sig) override
void write_vector_port_binding(const structural_objectRef &port, bool first_port_analyzed) override
void write_present_state_update(const structural_objectRef cir, const std::string &reset_state, const std::string &reset_port, const std::string &clock_port, const std::string &reset_type, bool connect_present_next_state_signals) override
write the present_state update process
void write_module_internal_declaration(const structural_objectRef &cir) override
Write the declaration of internal objects of the module.
bool check_keyword(const std::string &id) const override
std::string get_name() const override
Return the name of the language writer.
verilog_writer(const ParameterConstRef parameters)
Constructor.
void write_comment(const std::string &comment_string) override
Print a comment.
void write_header() override
Writes the header part of the file.
void write_module_parametrization(const structural_objectRef &cir) override
Module can be parameterized with respect different features.
void write_transition_output_functions(bool single_proc, unsigned int output_index, const structural_objectRef &cir, const std::string &reset_state, const std::string &reset_port, const std::string &start_port, const std::string &clock_port, std::vector< std::string >::const_iterator &first, std::vector< std::string >::const_iterator &end, bool is_yosys, const std::map< unsigned int, std::map< std::string, std::set< unsigned int >>> &bypass_signals) override
Write the transition and output functions.
void write_NP_functionalities(const structural_objectRef &cir) override
Write in the proper language the behavioral description of the module described in "Not Parsed" form...
unsigned map[NUM_VERTICES]
Definition: bfs.c:12
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
void write_module_definition_begin(const structural_objectRef &cir) override
Write the top constructor declaration.
void write_state_declaration(const structural_objectRef &cir, const std::list< std::string > &list_of_states, const std::string &reset_port, const std::string &reset_state, bool one_hot) override
write the declaration of all the states of the finite state machine.
void write_module_instance_end(const structural_objectRef &cir) override
Write the ending part of the instance of a module.
void write_io_signal_post_fix(const structural_objectRef &port, const structural_objectRef &sig) override
Write some code managing primary ports to signals connections.
static const std::map< std::string, std::string > builtin_to_verilog_keyword
map putting into relation standard gates with the corresponding built-in Verilog statements.
void write_module_definition_end(const structural_objectRef &cir) override
Write the end part in a module declaration.
void write_module_parametrization_decl(const structural_objectRef &cir) override
Write the declaration of the module parameters.
void write_port_decl_tail() override
Write the tail for port_decl.
std::string get_extension() const override
Return the filename extension associated with the verilog_writer.
bool has_output_prefix() const override
void write_component_declaration(const structural_objectRef &cir) override
Write the declaration of a component.
void write_module_declaration(const structural_objectRef &cir) override
Write the declaration of the module.
void write_module_instance_begin(const structural_objectRef &cir, const std::string &module_name, bool write_parametrization) override
Write the initial part of the instance of a module.
~verilog_writer() override
Destructor.
void write_library_declaration(const structural_objectRef &cir) override
Write the #include for each used library.
short word
Definition: private.h:30
std::string type_converter_size(const structural_objectRef &cir) override
Return a language based type string given a structural_type_descriptor for the range of the array...
const ParameterConstRef parameters
the set of input parameters
static bool check_keyword_verilog(const std::string &word)
HDL writer base class used to specify the interface of the different language writers.
std::string may_slice_string(const structural_objectRef &cir)
return the slice in case of a port owned by a port vector
static const std::set< std::string > keywords
void write_port_declaration(const structural_objectRef &cir, bool last_port_to_analyze) override
Write the port declaration starting from a port object.

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