PandA-2024.02
sv_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  */
44 #include "sv_writer.hpp"
45 
46 #include "HDL_manager.hpp"
47 
48 #include "technology_manager.hpp"
49 
50 #include "NP_functionality.hpp"
51 #include "dbgPrintHelper.hpp"
52 #include "exceptions.hpp"
53 #include "structural_objects.hpp"
54 
56 #include "Parameter.hpp"
57 
60 #include "string_manipulation.hpp" // for GET_CLASS
61 
63 {
64  auto* mod = GetPointer<module>(cir);
65  THROW_ASSERT(mod, "Expected a component object");
66  const NP_functionalityRef& np = mod->get_NP_functionality();
67  THROW_ASSERT(np, "NP Behavioral description is missing for module: " +
70  THROW_ASSERT(beh_desc != "", "SYSTEM VERILOG behavioral description is missing for module: " +
73  if(!parameters->getOption<bool>(OPT_reset_level))
74  {
75  boost::replace_all(beh_desc, "1RESET_EDGE_FORCE", "or negedge " + std::string(RESET_PORT_NAME));
76  if(parameters->getOption<std::string>(OPT_reset_type) == "async")
77  {
78  boost::replace_all(beh_desc, "1RESET_EDGE", "or negedge " + std::string(RESET_PORT_NAME));
79  }
80  else
81  {
82  boost::replace_all(beh_desc, "1RESET_EDGE", "");
83  }
84  boost::replace_all(beh_desc, "1RESET_VALUE", std::string(RESET_PORT_NAME) + " == 1'b0");
85  }
86  else
87  {
88  boost::replace_all(beh_desc, "1RESET_EDGE_FORCE", "or posedge " + std::string(RESET_PORT_NAME));
89  if(parameters->getOption<std::string>(OPT_reset_type) == "async")
90  {
91  boost::replace_all(beh_desc, "1RESET_EDGE", "or posedge " + std::string(RESET_PORT_NAME));
92  }
93  else
94  {
95  boost::replace_all(beh_desc, "1RESET_EDGE", "");
96  }
97  boost::replace_all(beh_desc, "1RESET_VALUE", std::string(RESET_PORT_NAME) + " == 1'b1");
98  }
99  if(parameters->getOption<bool>(OPT_reg_init_value))
100  {
101  boost::replace_all(beh_desc, "1INIT_ZERO_VALUE", "=0");
102  }
103  else
104  {
105  boost::replace_all(beh_desc, "1INIT_ZERO_VALUE", "");
106  }
107  indented_output_stream->Append(beh_desc);
108 }
109 
111 {
112  debug_level = parameters->get_class_debug_level(GET_CLASS(this));
113 }
114 
static std::string convert_to_identifier(const language_writer *writer, const std::string &id)
Converts a generic string to a language compliant identifier.
File containing functions and utilities to support the printing of debug messagges.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
int debug_level
debugging level of the class
std::string get_NP_functionality(NP_functionaly_type type) const
Return the description provided the type.
exceptions managed by PandA
Class to print indented code.
const IndentedOutputStreamRef indented_output_stream
Represents the stream we are currently writing to.
Class specification of the manager of the technology library data structures.
#define GET_TYPE_NAME(structural_obj)
Macro returning the string name of a type.
Auxiliary methods for manipulating string.
void Append(const std::string &str)
Append a string to the output.
~system_verilog_writer() override
Destructor.
This class describes all classes used to represent a structural object.
const ParameterConstRef parameters
the set of input parameters
system_verilog_writer(const ParameterConstRef parameters)
Constructor.
Definition: sv_writer.cpp:110
this class is used to manage the command-line or XML options.
Not parsed functionality manager.
#define RESET_PORT_NAME
This class writes different HDL based descriptions (VHDL, Verilog, SystemC) starting from a structura...
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...
Definition: sv_writer.cpp:62
#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