Class: TdlSpace::DefEleBaseArrayChain

Inherits:
DefArrayChain show all
Defined in:
lib/tdl/rebuild_ele/ele_base.rb

Overview

只能用于接口,dimension 和 DSIZE 并不共享空间

Instance Attribute Summary collapse

Attributes inherited from DefArrayChain

#belong_to_module, #chain

Instance Method Summary collapse

Methods inherited from DefArrayChain

#check_name, #check_topmodule_method, #method_missing, #to_inp

Constructor Details

#initialize(hash) ⇒ DefEleBaseArrayChain

Returns a new instance of DefEleBaseArrayChain.



697
698
699
700
701
702
703
704
705
706
707
# File 'lib/tdl/rebuild_ele/ele_base.rb', line 697

def initialize(hash)
    super(hash[:belong_to_module])
    # @dsize = dsize 
    # @freqM = freqM
    # @clock = clock 
    # @reset = reset
    @origin_hash = hash
    if hash[:dsize] && hash[:dsize].instance_of?(String)
        raise TdlError.new("DSIZE<#{hash[:dsize]}> Cant be String")
    end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TdlSpace::DefArrayChain

Instance Attribute Details

#modport_typeObject

DefArrayChain in sdlmodule_arratchain attr_accessor :dsize,:freqM,:clock,:reset



696
697
698
# File 'lib/tdl/rebuild_ele/ele_base.rb', line 696

def modport_type
  @modport_type
end

#tclassObject

DefArrayChain in sdlmodule_arratchain attr_accessor :dsize,:freqM,:clock,:reset



696
697
698
# File 'lib/tdl/rebuild_ele/ele_base.rb', line 696

def tclass
  @tclass
end

Instance Method Details

#-(xname) ⇒ Object



724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'lib/tdl/rebuild_ele/ele_base.rb', line 724

def - (xname)
    unless xname.is_a? Symbol
        name = to_inp(xname)
    else 
        name = to_inp(xname.to_s)
    end
    # belong_to_module.Def.datainf_c(name: name ,clock: clock||@clock,reset: reset||@reset ,dsize: dsize||@dsize ,dimension: @chain,freqM:freqM||@freqM)
    if @chain.length > 0
        dimension = @chain[0,@chain.length]
        @origin_hash[:dimension] = dimension
    end
    
    int = tclass.new(@origin_hash[:belong_to_module])
    int.inst_name = name
    int.dimension = @chian 
    if modport_type
        int.modport_type = modport_type
    end
    @origin_hash.each do |k,v| 
        ## 
        if int.respond_to? k 
            int.public_send("#{k}=",v)
        end
    end

    if @belong_to_module.respond_to?(name) 
        raise   TdlError.new("Cant redefine #{name} !!! ")
    end

    if name.to_s.strip.empty? 
        raise   TdlError.new("Name Cant empty !!! ")
    end

    ## 给sdlmodule添加直接调用 方法 
    @belong_to_module.define_singleton_method(name) { int }

    StringBandItegration.add_method_to_itgt(name,int)
    return int

end

#[](*a) ⇒ Object



709
710
711
712
713
714
715
716
717
718
719
720
721
722
# File 'lib/tdl/rebuild_ele/ele_base.rb', line 709

def [](*a)
    if a[0].is_a? Range
        a = a.to_a 
    end

    if a.empty?
        raise TdlError.new("参数不能为空")
    end
    new_dla = self.class.new(@origin_hash)
    new_dla.chain = @chain + a
    new_dla.tclass = self.tclass
    new_dla.modport_type = modport_type
    new_dla
end