Class: BaseElm

Inherits:
Object
  • Object
show all
Includes:
TdlSpace::ExCreateTP
Defined in:
lib/tdl/exlib/test_point.rb,
lib/tdl/elements/originclass.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb

Direct Known Subclasses

CommCfgReg, InfElm, MailBox, Parameter, SignalElm

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TdlSpace::ExCreateTP

#create_tp, #root_ref

Instance Attribute Details

#belong_to_moduleObject

attr_accessor :belong_module



105
106
107
# File 'lib/tdl/elements/originclass.rb', line 105

def belong_to_module
  @belong_to_module
end

#nameObject

Returns the value of attribute name.



106
107
108
# File 'lib/tdl/elements/originclass.rb', line 106

def name
  @name
end

Class Method Details

.recfg_nc(new_nc) ⇒ Object

def signal

@name.to_s

end



143
144
145
146
147
148
149
# File 'lib/tdl/elements/originclass.rb', line 143

def self.recfg_nc(new_nc)
    new_nc.instance_variable_set("@_id",0)
    new_nc.define_singleton_method(:signal) do
        id = new_nc.instance_variable_get("@_id")
        new_nc.instance_variable_set("@_id",id+1).to_s
    end
end

Instance Method Details

#matrix(*indexs) ⇒ Object



130
131
132
133
134
135
136
137
# File 'lib/tdl/elements/originclass.rb', line 130

def matrix(*indexs)
    with_new_align(0) do
        str = indexs.map do |i|
            "[#{align_signal(i,q_mark=false)}]"
        end.join("")
        NqString.new("#{@name.to_s}#{str}")
    end
end

#name_copy(nstr) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/tdl/elements/originclass.rb', line 151

def name_copy(nstr)
    if nstr.is_a?(StringBandItegration) && true
        return nstr
    else
        if nstr.to_s.eql?(@name.to_s)
            @copy_id ||= 0
            str = "#{nstr.to_s}_copy_#{@copy_id}"
            @copy_id += 1
            str
        else
            nstr.to_s
        end
    end
end

#path_refs(&block) ⇒ Object

获取信号的绝对路径



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/tdl/exlib/test_point.rb', line 139

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 << signal
            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}.#{signal}".to_nq]
    end
    collects
end

#s(index = nil) ⇒ Object

def initialize

@belong_module =


110
111
112
# File 'lib/tdl/elements/originclass.rb', line 110

def s(index=nil)
    signal
end

#signal(index = nil) ⇒ Object

重覆盖掉



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/tdl/class_hdl/hdl_redefine_opertor.rb', line 446

def signal(index=nil)
    RedefOpertor.with_normal_operators do
        with_new_align(0) do
            unless index
                NqString.new(@name.to_s)
            else
                unless index.is_a? String
                    NqString.new("#{@name.to_s}[#{align_signal(index)}]")
                else
                    NqString.new("#{@name.to_s}[#{index.strip}]")
                end
            end
        end
    end
end