ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
vlg_mod.h
1 // ---Hongce Zhang (hongcez@princeton.edu)
9 
10 #ifndef ILANG_VTARGET_OUT_VLG_MOD_H__
11 #define ILANG_VTARGET_OUT_VLG_MOD_H__
12 
13 #include <map>
14 #include <string>
15 #include <vector>
16 
17 #include <ilang/verilog-in/verilog_analysis_wrapper.h>
18 
19 namespace ilang {
20 
23 public:
24  // ---------------------- TYPE ------------------------- //
26  typedef std::tuple<long, // lineno
27  std::string, // varname (short name)
28  bool>
31  typedef std::map<std::string, // file name
32  std::vector<info_t>>
35  typedef std::tuple<long, // lineno
36  // std::string, // module name
37  std::string, // varname to add a__DOT__b__DOT__ ...
38  unsigned> // width
40 
42  typedef std::tuple<long, // lineno
43  // std::string, // instance name
44  std::string, // varname to add a__DOT__b__DOT__ ...
45  unsigned> // width
47 
49  typedef std::tuple<long, // lineno
50  std::string, // varname
51  unsigned, // width
52  std::string> // short_sig_name;
54 
56  typedef std::tuple<long, // lineno
57  std::string> // stmt
59 
61  typedef std::map<std::string, // file name
62  std::vector<mod_decl_item_t>>
64 
66  typedef std::map<std::string, // file name
67  std::vector<mod_inst_item_t>>
69 
71  typedef std::map<std::string, // file name
72  std::vector<assign_item_t>>
74 
76  typedef std::map<std::string, // filename
77  std::vector<add_stmt_t>>
79 
81  typedef std::pair<std::string, unsigned> vlg_sig_t;
82 
84  typedef enum { AUTO = 0, NEW = 1, OLD = 2 } port_decl_style_t;
85 
86 public:
90  VerilogModifier(VerilogInfo* _vlg_info_ptr, port_decl_style_t port_decl_style,
91  bool add_keep_or_not,
92  const std::map<std::string, int>& _sup_width_info); //
97  void ReadModifyWrite(const std::string& filename, std::istream& fin,
98  std::ostream& fout);
100  void FinishRecording();
102  void RecordKeepSignalName(const std::string& vname);
104  vlg_sig_t RecordConnectSigName(const std::string& vlg_sig_name,
105  const std::string& suffix = "");
107  void RecordAdditionalVlgModuleStmt(const std::string& stmt,
108  const std::string& mod_instance_name);
109 
110 protected:
111  // --------------- MEMBERS ---------------------------- //
129  const std::map<std::string, int>& sup_width_info;
130 
131 protected:
132  // --------------- HELPERS --------------------------- //
133  static std::string add_keep_to_port(const std::string& line_in,
134  const std::string& vname);
135  static std::string add_keep_to_a_line(const std::string& line_in,
136  const std::string& vname);
137  static std::string
138  add_assign_wire_to_this_line(const std::string& line_in,
139  const std::string& vname, unsigned width,
140  const std::string& short_name);
141  bool add_mod_decl_wire_to_this_line(const std::string& line_in,
142  std::string& line_out,
143  const std::string& vname, unsigned width);
144  bool add_mod_inst_wire_to_this_line(const std::string& line_in,
145  std::string& line_out,
146  const std::string& vname, unsigned width);
147 
148 }; // class VerilogModifier
149 
150 }; // namespace ilang
151 
152 #endif // ILANG_VTARGET_OUT_VLG_MOD_H__
fn_l_map_t fn_l_map
the record of where to insert keep
Definition: vlg_mod.h:113
VerilogInfo * vlg_info_ptr
The pointer object so we can get verilog information of the implementation.
Definition: vlg_mod.h:123
void RecordKeepSignalName(const std::string &vname)
record the name to add a keep there
bool _add_keep_or_not
whether to add keep
Definition: vlg_mod.h:127
std::tuple< long, std::string, bool > info_t
a tuple to store all related info for modification
Definition: vlg_mod.h:29
mod_decl_map_t mod_decl_map
decl modification record
Definition: vlg_mod.h:115
port_decl_style_t
The style or port declaration.
Definition: vlg_mod.h:84
std::map< std::string, std::vector< assign_item_t > > assign_map_t
type of an wire assignment modification record
Definition: vlg_mod.h:73
port_decl_style_t _port_decl_style
cache the style
Definition: vlg_mod.h:125
~VerilogModifier()
Destructor:
assign_map_t assign_map
an wire assignment modification record
Definition: vlg_mod.h:119
vlg_sig_t RecordConnectSigName(const std::string &vlg_sig_name, const std::string &suffix="")
record the name to add related wires
VerilogModifier(VerilogInfo *_vlg_info_ptr, port_decl_style_t port_decl_style, bool add_keep_or_not, const std::map< std::string, int > &_sup_width_info)
Constructor:
std::map< std::string, std::vector< add_stmt_t > > add_stmt_map_t
type of additional stmt modification record
Definition: vlg_mod.h:78
void FinishRecording()
do some work (sorting)
the class for modification to verilog
Definition: vlg_mod.h:22
std::tuple< long, std::string, unsigned, std::string > assign_item_t
type of an wire assignment modification item
Definition: vlg_mod.h:53
std::map< std::string, std::vector< info_t > > fn_l_map_t
filename -&gt; (lineno, varname, is_port_sig) vec
Definition: vlg_mod.h:33
std::map< std::string, std::vector< mod_decl_item_t > > mod_decl_map_t
type of decl modification record
Definition: vlg_mod.h:63
mod_inst_map_t mod_inst_map
a module inst modification record
Definition: vlg_mod.h:117
void ReadModifyWrite(const std::string &filename, std::istream &fin, std::ostream &fout)
const std::map< std::string, int > & sup_width_info
the supplementary width info
Definition: vlg_mod.h:129
std::tuple< long, std::string, unsigned > mod_decl_item_t
type of a module decl modification item
Definition: vlg_mod.h:39
std::tuple< long, std::string > add_stmt_t
type of an additional statement of an module
Definition: vlg_mod.h:58
std::map< std::string, std::vector< mod_inst_item_t > > mod_inst_map_t
type of a module inst modification record
Definition: vlg_mod.h:68
add_stmt_map_t add_stmt_map
a additional stmt modification record
Definition: vlg_mod.h:121
The class that invoke the analyzer.
Definition: verilog_analysis_wrapper.h:173
std::tuple< long, std::string, unsigned > mod_inst_item_t
type of a module inst modification item
Definition: vlg_mod.h:46
std::pair< std::string, unsigned > vlg_sig_t
type of an wire name w. width
Definition: vlg_mod.h:81
void RecordAdditionalVlgModuleStmt(const std::string &stmt, const std::string &mod_instance_name)
record the stmt to be added to a module