Class: ClassHDL::StructVar
- Inherits:
-
Object
- Object
- ClassHDL::StructVar
- Includes:
- AssignDefOpertor, TdlSpace::ExCreateTP
- Defined in:
- lib/tdl/exlib/test_point.rb,
lib/tdl/class_hdl/hdl_struct.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb
Constant Summary
Constants included from AssignDefOpertor
Instance Attribute Summary collapse
-
#belong_to_module ⇒ Object
include ClassHDL::AssignDefOpertor.
-
#dimension ⇒ Object
Returns the value of attribute dimension.
Instance Method Summary collapse
- #[](a) ⇒ Object
- #_inst_dimension ⇒ Object
-
#define_child_vars ⇒ Object
定义子变量.
-
#initialize(name, meta) ⇒ StructVar
constructor
A new instance of StructVar.
- #inst ⇒ Object
-
#path_refs(&block) ⇒ Object
获取信号的绝对路径.
- #to_s ⇒ Object
Methods included from AssignDefOpertor
curr_assign_block, curr_assign_block=, curr_assign_block_stack, curr_opertor_stack, included, init_op_methods, use_new_yield_opertors, use_old_cond_opertors, with_new_assign_block, with_new_opertor, with_normal_opertor, with_rollback_opertors
Methods included from TdlSpace::ExCreateTP
Constructor Details
#initialize(name, meta) ⇒ StructVar
Returns a new instance of StructVar.
139 140 141 142 143 144 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 139 def initialize(name,) @name = name @meta = define_child_vars @dimension = [] end |
Instance Attribute Details
#belong_to_module ⇒ Object
include ClassHDL::AssignDefOpertor
137 138 139 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 137 def belong_to_module @belong_to_module end |
#dimension ⇒ Object
Returns the value of attribute dimension.
138 139 140 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 138 def dimension @dimension end |
Instance Method Details
#[](a) ⇒ Object
159 160 161 162 163 164 165 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 159 def [](a) if dimension return TdlSpace::ArrayChain.new(self,[a]) else raise TdlError.new "#{@name} dimenson is nil " end end |
#_inst_dimension ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 146 def _inst_dimension return '' if @dimension.empty? str = @dimension.map do |e| "[#{e.to_s}-1:0]" end.join('') " #{str}" end |
#define_child_vars ⇒ Object
定义子变量
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 168 def define_child_vars # puts @meta.struct_slots @meta.struct_slots.each do |e| self.define_singleton_method(e.name) do # RedefOpertor.with_normal_operators do ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do TdlSpace::ArrayChain.new("#{@name}.#{e.to_s}".to_nq) end end end end |
#inst ⇒ Object
155 156 157 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 155 def inst "#{@meta.name} #{@name}#{_inst_dimension};".to_nq end |
#path_refs(&block) ⇒ Object
获取信号的绝对路径
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/tdl/exlib/test_point.rb', line 264 def path_refs(&block) collects = [] if @belong_to_module != TopModule.current.techbench @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 ll << self.to_s.to_nq new_name = ll.join('.').to_nq if block_given? if yield(new_name) collects << new_name end else collects << new_name end end else collects = ["$root.#{@belong_to_module.module_name}.#{self.to_s.to_nq}".to_nq] end collects end |
#to_s ⇒ Object
180 181 182 |
# File 'lib/tdl/class_hdl/hdl_struct.rb', line 180 def to_s @name.to_s end |