class ClassHDL::StructVar

Attributes

belong_to_module[RW]
dimension[RW]

Public Class Methods

new(name,meta) click to toggle source
# File lib/tdl/class_hdl/hdl_struct.rb, line 139
def initialize(name,meta)
    @name = name 
    @meta = meta 
    define_child_vars
    @dimension = []
end

Public Instance Methods

[](a) click to toggle source
# File lib/tdl/class_hdl/hdl_struct.rb, line 159
def [](a)
    if dimension
        return TdlSpace::ArrayChain.create(obj:self,lchain:[a],belong_to_module: belong_to_module)
    else  
        raise TdlError.new "#{@name} dimenson is nil "
    end
end
_inst_dimension() click to toggle source
# 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() click to toggle source

定义子变量

# 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.create(obj:"#{@name}.#{e.to_s}".to_nq, belong_to_module: self.belong_to_module)
            end
        end
    end
end
inst() click to toggle source
# File lib/tdl/class_hdl/hdl_struct.rb, line 155
def inst 
    "#{@meta.name} #{@name}#{_inst_dimension};".to_nq
end
path_refs() { |new_name| ... } click to toggle source

获取信号的绝对路径

# File lib/tdl/exlib/test_point.rb, line 266
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() click to toggle source
# File lib/tdl/class_hdl/hdl_struct.rb, line 180
def to_s 
    @name.to_s
end