ilang  1.1.4
ILAng: A Modeling and Verification Platform for SoCs
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros
directive.h
1 // --- Hongce Zhang
5 #ifndef ILANG_VTARGET_OUT_DIRECTIVE_H__
6 #define ILANG_VTARGET_OUT_DIRECTIVE_H__
7 
8 #include <functional>
9 #include <map>
10 #include <string>
11 #include <tuple>
12 
13 #include <ilang/verilog-in/verilog_analysis_wrapper.h>
15 #include <ilang/vtarget-out/absmem.h>
16 
17 namespace ilang {
18 
21 /*
22 **CLOCK**
23 **RESET**
24 **KEEP**
25 **NC**
26 **MEM** rdata/raddr/ren/wdata/waddr/wen.?
27 */
29 public:
31  typedef enum {
32  KEEP = 0,
33  NC /*not connected*/,
34  SO /*state out*/,
35  INPUT /*general input*/,
36  RESET,
37  CLOCK,
38  MEM_R_A,
39  MEM_R_D,
40  MEM_R_EN,
41  MEM_W_A,
42  MEM_W_D,
43  MEM_W_EN,
44  START
45  } inf_dir_t;
47  typedef std::pair<inf_dir_t, std::string> inf_connector_t;
49  typedef std::map<std::string, inf_connector_t> mod_inst_rec_t;
55  typedef std::function<bool(const std::string&, const SignalInfoBase&)>
58  typedef std::function<std::pair<unsigned, unsigned>(const std::string&)>
61  typedef std::function<void(const std::string&)> assmpt_inserter_t;
66 
67 public:
69  static bool beginsWith(const std::string& c, const std::string& s);
71  static bool isSpecialInputDir(const std::string& c);
73  static bool isSpecialInputDirCompatibleWith(const std::string& c,
74  const SignalInfoBase& vlg_sig);
76  // static bool interfaceDeclareTop(const std::string & c);
77  // --- more to added
78  // -------------------- CONSTRUCTOR ---------------------------- //
81  IntefaceDirectiveRecorder(bool reset_vlg) : _reset_vlg(reset_vlg) {}
82 
83  // ------------------------ MEMBERS ------------------------ //
85  void Clear(bool reset_vlg);
87  std::string GetVlgModInstString(VerilogGeneratorBase& gen) const;
89  void VlgAddTopInteface(VerilogGeneratorBase& gen) const;
91  void RegisterInterface(const SignalInfoBase& vlg_sig,
92  const std::string& refstr, ila_input_checker_t chk,
93  ila_mem_checker_t mget);
95  void RegisterExtraWire(const std::string& io_name,
96  const std::string& outside_name);
98  std::string ConnectMemory(const std::string& directive,
99  const std::string& ila_state_name,
100  const std::map<unsigned, rport_t>& rports,
101  const std::map<unsigned, wport_t>& wports,
102  int ila_addr_width, int ila_data_width,
103  bool abs_read);
105  void InsertAbsMemAssmpt(assmpt_inserter_t inserter);
106 
109  void SetMemName(const std::string& directive,
110  const std::string& ila_state_name, bool abs_read);
111 
115  void SetMemNameAndWidth(const std::string& directive,
116  const std::string& ila_state_name, bool abs_read, int,
117  int);
118 
120  std::string GetAbsMemInstString(VerilogGeneratorBase& gen,
121  const std::string& endCond);
127  std::pair<std::string, unsigned int>
128  KeepMemoryPorts(const std::string& mem_name, const std::string& port_name,
129  bool caller_build_wire);
130 
131 protected:
136  void ConnectModuleInputAddWire(const std::string& short_name, unsigned width);
138  void ConnectModuleOutputAddWire(const std::string& short_name,
139  unsigned width);
140 
141 protected:
144  // a wire will not appear in two or more of the category
152  std::map<std::string, VlgAbsMem> abs_mems;
155 
156 }; // class IntefaceDirectiveRecorder
157 
158 /*
159 **MEM**.?
160 */
161 
165 public:
166  // ------------------------------ HELPER
167  // ------------------------------------//
169  static bool isSpecialStateDir(const std::string& c);
171  static bool isSpecialStateDirMem(const std::string& c);
173  static bool isSpecialUnknownFunctionName(const std::string &funcname);
175  static bool isSpecialUnknownFunction(const FuncPtr &func_ptr);
176 }; // class StateMappingDirectiveRecorder
177 
178 }; // namespace ilang
179 
180 #endif // ILANG_VTARGET_OUT_DIRECTIVE_H__
type of write port
Definition: verilog_gen.h:57
bool _reset_vlg
whether to reset this vlg (reset to rst or dummy_reset)
Definition: directive.h:154
Used in Verilog Verification Target Generation for dealing with interface directives.
Definition: directive.h:28
void VlgAddTopInteface(VerilogGeneratorBase &gen) const
Add signals to the wrapper_generator.
void RegisterExtraWire(const std::string &io_name, const std::string &outside_name)
Register the extra wire to connect (for extra wire)
std::vector< vlg_sig_t > vlg_sigs_t
Type of Verilog signals (a vector)
Definition: verilog_gen.h:83
std::function< void(const std::string &)> assmpt_inserter_t
Type of call back function to insert assumptions.
Definition: directive.h:61
mod_inst_rec_t mod_inst_rec
a map of port-name -&gt; (tp, signal name)
Definition: directive.h:143
void SetMemName(const std::string &directive, const std::string &ila_state_name, bool abs_read)
type of read port
Definition: verilog_gen.h:48
void RegisterInterface(const SignalInfoBase &vlg_sig, const std::string &refstr, ila_input_checker_t chk, ila_mem_checker_t mget)
Used to tell this module about the refinement relations.
void SetMemNameAndWidth(const std::string &directive, const std::string &ila_state_name, bool abs_read, int, int)
vlg_sig_vec_t output_wires
wires to be declared as output and wire
Definition: directive.h:148
vlg_sig_vec_t input_wires
wires to be declared as input and wire
Definition: directive.h:146
static bool isSpecialUnknownFunction(const FuncPtr &func_ptr)
a function to determine if a function (no arg) is an unknown special directive
static bool isSpecialStateDirMem(const std::string &c)
a function to determine if a state map refstr is special directie (**???)
std::pair< inf_dir_t, std::string > inf_connector_t
Type of interface connector.
Definition: directive.h:47
std::function< std::pair< unsigned, unsigned >const std::string &)> ila_mem_checker_t
Type of call back function to find information about a memory.
Definition: directive.h:59
void ConnectModuleInputAddWire(const std::string &short_name, unsigned width)
a shortcut to connect module and add wire
VerilogGeneratorBase::vlg_sig_t vlg_sig_t
Using vlg-out&#39;s signal type.
Definition: directive.h:51
std::map< std::string, VlgAbsMem > abs_mems
ila-mem-name -&gt; abs
Definition: directive.h:152
std::string GetAbsMemInstString(VerilogGeneratorBase &gen, const std::string &endCond)
Return the memory instantiation string.
Func::FuncPtr FuncPtr
Pointer type for normal use of Func.
Definition: func.h:83
void ModuleInstSanityCheck(VerilogGeneratorBase &gen) const
static bool isSpecialUnknownFunctionName(const std::string &funcname)
a function to determine if a function name is an unknown special directive
IntefaceDirectiveRecorder(bool reset_vlg)
Check if an interface needs to be declare as top module I/O.
Definition: directive.h:81
static bool beginsWith(const std::string &c, const std::string &s)
Return if a string &#39;c&#39; begins with string &#39;s&#39;.
std::string GetVlgModInstString(VerilogGeneratorBase &gen) const
Return a string used for instantiating.
static bool isSpecialInputDir(const std::string &c)
Return true if &#39;c&#39; is special input directive.
void Clear(bool reset_vlg)
clear all internal storage
void ConnectModuleOutputAddWire(const std::string &short_name, unsigned width)
a shortcut to connect module and add wire
Class to hold signal info.
Definition: verilog_analysis_wrapper.h:112
Base class of VerilogGenerator.
Definition: verilog_gen.h:31
std::function< bool(const std::string &, const SignalInfoBase &)> ila_input_checker_t
ILA input compatible checker type.
Definition: directive.h:56
static bool isSpecialInputDirCompatibleWith(const std::string &c, const SignalInfoBase &vlg_sig)
Check for compatibility.
void InsertAbsMemAssmpt(assmpt_inserter_t inserter)
Insert memory abstractions&#39; assumptions.
std::pair< std::string, unsigned int > KeepMemoryPorts(const std::string &mem_name, const std::string &port_name, bool caller_build_wire)
std::string ConnectMemory(const std::string &directive, const std::string &ila_state_name, const std::map< unsigned, rport_t > &rports, const std::map< unsigned, wport_t > &wports, int ila_addr_width, int ila_data_width, bool abs_read)
Register the connection of signals related to a memory.
inf_dir_t
Type interface directives.
Definition: directive.h:31
std::map< std::string, inf_connector_t > mod_inst_rec_t
Type of interface connector storage.
Definition: directive.h:49
vlg_sig_vec_t internal_wires
wires to be declared as just wire
Definition: directive.h:150
std::pair< vlg_name_t, int > vlg_sig_t
Type of Verilog signal, name &amp; bw.
Definition: verilog_gen.h:81
a class to handle state-mapping directives in the refinement relations
Definition: directive.h:164
VerilogGeneratorBase::vlg_sigs_t vlg_sig_vec_t
Using vlg-out&#39;s signal vector type.
Definition: directive.h:53
static bool isSpecialStateDir(const std::string &c)
a function to determine if a state map refstr is special directie (**???)