Class: ClassHDL::EnumStruct
- Inherits:
-
AxiTdl::SdlModuleActiveBaseElm
- Object
- AxiTdl::SdlModuleActiveBaseElm
- ClassHDL::EnumStruct
- Includes:
- TdlSpace::ExCreateTP
- Defined in:
- lib/tdl/exlib/test_point.rb,
lib/tdl/class_hdl/hdl_block_ifelse.rb
Instance Attribute Summary collapse
-
#belong_to_module ⇒ Object
attr_accessor :sdl_m.
Instance Method Summary collapse
- #-(defname) ⇒ Object
- #cstate ⇒ Object (also: #C)
- #enum_inst(name, *args) ⇒ Object
-
#initialize(sdl_m, *args) ⇒ EnumStruct
constructor
A new instance of EnumStruct.
- #nstate ⇒ Object (also: #N)
-
#path_refs(nstateq = true, &block) ⇒ Object
获取信号的绝对路径.
- #root_ref(nstateq = true, &block) ⇒ Object
- #typedef_name ⇒ Object
Methods included from AxiTdl::TestUnitTrack
Constructor Details
#initialize(sdl_m, *args) ⇒ EnumStruct
Returns a new instance of EnumStruct.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 188 def initialize(sdl_m,*args) args.each do |e| unless e.is_a? String raise TdlError.new("Enum Def element[#{e}] must be String") end define_singleton_method(e) do |&block| unless block_given? e.to_nq else WHEN(e.to_nq,&block) end end end @args = args @sdl_m = sdl_m @belong_to_module = sdl_m # @name = name end |
Instance Attribute Details
#belong_to_module ⇒ Object
attr_accessor :sdl_m
187 188 189 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 187 def belong_to_module @belong_to_module end |
Instance Method Details
#-(defname) ⇒ Object
228 229 230 231 232 233 234 235 236 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 228 def -(defname) @name = defname.to_s @sdl_m.Logic_inst.push(enum_inst(defname.to_s,*@args)) _self = self @sdl_m.define_singleton_method(defname.to_s) do _self end self end |
#cstate ⇒ Object Also known as: C
209 210 211 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 209 def cstate "CSTATE_#{@name}".to_nq end |
#enum_inst(name, *args) ⇒ Object
220 221 222 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 220 def enum_inst(name,*args) str = "typedef enum { \n#{args.map{|e| " #{e}" }.join(",\n")}\n} SE_STATE_#{name};\nSE_STATE_#{name} CSTATE_#{name},NSTATE_#{name};\n" end |
#nstate ⇒ Object Also known as: N
213 214 215 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 213 def nstate "NSTATE_#{@name}".to_nq end |
#path_refs(nstateq = true, &block) ⇒ Object
获取信号的绝对路径
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/tdl/exlib/test_point.rb', line 226 def path_refs(nstateq=true,&block) collects = [] @belong_to_module.parents_inst_tree do |tree| ll = ["$root"] rt = tree.reverse rt.each_index do |index| if rt[index].respond_to? :module_name ll << rt[index].module_name else ll << rt[index].inst_name end end if nstateq ll << nstate else ll << cstate end new_name = ll.join('.').to_nq if block_given? if yield(new_name) collects << new_name end else collects << new_name end end collects end |
#root_ref(nstateq = true, &block) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/tdl/exlib/test_point.rb', line 212 def root_ref(nstateq=true,&block) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do rels = path_refs(nstateq,&block) if rels.size == 1 rels[0] elsif rels.size == 0 raise TdlError.new "#{self} Cant find root ref" else raise TdlError.new "#{self} Find multi root refs \n#{rels.join("\n")}\n" end end end |
#typedef_name ⇒ Object
224 225 226 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 224 def typedef_name "SE_STATE_#{@name}".to_nq end |