class BaseElm
Attributes
belong_to_module[RW]
attr_accessor :belong_module
name[RW]
Public Class Methods
recfg_nc(new_nc)
click to toggle source
def signal
@name.to_s
end
# File lib/tdl/elements/originclass.rb, line 118 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
Private Class Methods
define_arraychain_tail_method(name,width=1,rv=false,&block)
click to toggle source
ArrayChain 相关
# File lib/tdl/class_hdl/hdl_redefine_opertor.rb, line 570 def self.define_arraychain_tail_method(name,width=1,rv=false,&block) self.define_method(name) do ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do if @dimension.empty? NqString.new(signal.concat ".#{name}") else @_array_chain_hash_ ||= {} unless @_array_chain_hash_[name.to_s] if width.is_a? Proc r_width = width.call(self) else r_width = width end rel = generate_inf_to_signals(name.to_s,width=r_width,rv=rv) @_array_chain_hash_[name.to_s] = rel end TdlSpace::ArrayChain.create(obj: @_array_chain_hash_[name.to_s], lchain:[], belong_to_module: self.belong_to_module) end end end end
Public Instance Methods
matrix(*indexs)
click to toggle source
# File lib/tdl/elements/originclass.rb, line 105 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)
click to toggle source
# File lib/tdl/elements/originclass.rb, line 126 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() { |new_name| ... }
click to toggle source
获取信号的绝对路径
# File lib/tdl/exlib/test_point.rb, line 141 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 << @name 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}.#{@name}".to_nq] end collects end
s(index=nil)
click to toggle source
def initialize
@belong_module =
# File lib/tdl/elements/originclass.rb, line 85 def s(index=nil) signal end
signal(index=nil)
click to toggle source
重覆盖掉
# File lib/tdl/class_hdl/hdl_redefine_opertor.rb, line 552 def signal(index=nil) ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) 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
Private Instance Methods
array_inst()
click to toggle source
def array_inst
(msb_high:true)
# File lib/tdl/elements/originclass.rb, line 143 def array_inst return "" if @dimension.empty? m = @dimension.map do |e| if e.respond_to? signal "[#{e.signal}-1:0]" elsif (e.is_a? Numeric) && e < 0 "[0:#{-e}-1]" else "[#{e}-1:0]" end end return m.join("") end
name_legal?(name)
click to toggle source
# File lib/tdl/elements/originclass.rb, line 158 def name_legal?(name) if (name.to_s !~ /^[a-zA-Z]/ || name.to_s !~ /([a-zA-Z0-9]|_)+/) # puts "===#{name.to_s}===" # puts name.to_s !~ /^[a-zA-Z]/ # puts name.to_s !~ /([a-zA-Z0-9]|_)+/ raise TdlError.new(" Name << #{name.to_s[0,31]} class[#{name.class}]>> Illegal") end end