ilang  1.0.0
ILAng: A Modeling and Verification Platform for SoCs
var_extract.h
1 // --- Hongce Zhang
6 
7 #ifndef ILANG_VTARGET_OUT_VAR_EXTRACT_H__
8 #define ILANG_VTARGET_OUT_VAR_EXTRACT_H__
9 
10 #include <functional>
11 #include <string>
12 #include <vector>
13 
14 namespace ilang {
15 
16 class VarExtractor {
17 
18 public:
20  typedef enum { KEEP = 0, ILA_S, ILA_IN, VLG_S, UNKN_S, NUM } token_type;
22  typedef std::pair<token_type, std::string> token;
24  typedef std::function<bool(const std::string&)> str_j;
26  typedef std::function<std::string(const token&)> str_r;
27 
28 protected:
30  std::vector<token> _tokens;
36  str_j _is_vlg_sig;
37 
38 public:
39  // ---------------------- CONSTRUCTOR ----------------- //
40  VarExtractor(str_j is_ila_state, str_j is_ila_input, str_j is_vlg_sig);
41  // ---------------------- METHODS ----------------- //
44  void
45  ParseToExtract(const std::string& in,
46  bool force_vlg_statename =
47  false); // the later is only used in dealing w. invariants
50  str_r replacer); // you can return the same so it will not be replaced
52  std::string GenString() const;
54  std::string Replace(const std::string& in, bool force_vlg_statename,
55  str_r replacer) {
56  ParseToExtract(in, force_vlg_statename);
57  ForEachTokenReplace(replacer);
58  return GenString();
59  }
60  // ---------------------- HELPERS ----------------- //
61  static bool contains_mod_inst_name(const std::string& s,
62  const std::string& mi);
63 
64 }; // class VarExtractor
65 
66 }; // namespace ilang
67 
68 #endif // ILANG_VTARGET_OUT_VAR_EXTRACT_H__
std::function< std::string(const token &)> str_r
Type of function pointer of string replacer.
Definition: var_extract.h:26
std::pair< token_type, std::string > token
Tokens.
Definition: var_extract.h:22
str_j _is_ila_state
a pointer to string judger (is ila state?)
Definition: var_extract.h:32
Definition: var_extract.h:16
std::string GenString() const
Get back string.
str_j _is_ila_input
a pointer to string judge (is ila input?)
Definition: var_extract.h:34
void ParseToExtract(const std::string &in, bool force_vlg_statename=false)
std::string Replace(const std::string &in, bool force_vlg_statename, str_r replacer)
A shortcut to do all at once.
Definition: var_extract.h:54
std::vector< token > _tokens
token from parsed string
Definition: var_extract.h:30
std::function< bool(const std::string &)> str_j
Type of function pointer of string judger.
Definition: var_extract.h:24
str_j _is_vlg_sig
a pointer to string judger (is vlg signal?)
Definition: var_extract.h:36
void ForEachTokenReplace(str_r replacer)
Traverse the tokens, see if replace is needed.
token_type
Type of tokens.
Definition: var_extract.h:20