class ClassHDL::EnumStruct

Attributes

belong_to_module[RW]

attr_accessor :sdl_m

Public Class Methods

new(sdl_m,*args) click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 188
def initialize(sdl_m,*args)
    args.each do |e|
        unless e.is_a? String 
            raise TdlError.new("Enum Def element[#{e}] must be String")
        end 

        define_singleton_method(e) do |&block|
            unless block_given?
                e.to_nq
            else
                WHEN(e.to_nq,&block) 
            end
        end
    end
    @args = args
    @sdl_m = sdl_m
    @belong_to_module = sdl_m
    # @name = name
    
end

Public Instance Methods

-(defname) click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 228
def -(defname)
    @name = defname.to_s
    @sdl_m.Logic_inst.push(enum_inst(defname.to_s,*@args))
    _self = self
    @sdl_m.define_singleton_method(defname.to_s) do 
        _self 
    end
    self
end
C()
Alias for: cstate
N()
Alias for: nstate
cstate() click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 209
def cstate
    "CSTATE_#{@name}".to_nq
end
Also aliased as: C
enum_inst(name,*args) click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 220
def enum_inst(name,*args)
    str = "typedef enum { \n#{args.map{|e| "    #{e}" }.join(",\n")}\n} SE_STATE_#{name};\nSE_STATE_#{name} CSTATE_#{name},NSTATE_#{name};\n"
end
nstate() click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 213
def nstate
    "NSTATE_#{@name}".to_nq
end
Also aliased as: N
path_refs(nstateq=true) { |new_name| ... } click to toggle source

获取信号的绝对路径

# File lib/tdl/exlib/test_point.rb, line 226
def path_refs(nstateq=true,&block)
    collects = []
    @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
        if nstateq
            ll << nstate
        else
            ll << cstate
        end
        new_name = ll.join('.').to_nq
        if block_given?
            if yield(new_name)
                collects << new_name
            end 
        else
            collects << new_name
        end
    end
    collects
end
root_ref(nstateq=true,&block) click to toggle source
# File lib/tdl/exlib/test_point.rb, line 212
def root_ref(nstateq=true,&block)
    ClassHDL::AssignDefOpertor.with_rollback_opertors(:old) do 
        rels = path_refs(nstateq,&block)
        if rels.size == 1
            rels[0]
        elsif rels.size == 0
            raise TdlError.new "#{self} Cant find root ref"
        else
            raise TdlError.new "#{self} Find multi root refs \n#{rels.join("\n")}\n"
        end
    end
end
typedef_name() click to toggle source
# File lib/tdl/class_hdl/hdl_block_ifelse.rb, line 224
def typedef_name
    "SE_STATE_#{@name}".to_nq
end