Class: ClassHDL::BlockCASEWHEN

Inherits:
BlockIF
  • Object
show all
Defined in:
lib/tdl/class_hdl/hdl_block_ifelse.rb

Instance Attribute Summary

Attributes inherited from BlockIF

#cond, #opertor_chains, #slaver

Instance Method Summary collapse

Methods inherited from BlockIF

#initialize

Constructor Details

This class inherits a constructor from ClassHDL::BlockIF

Instance Method Details

#cond_to_hdlObject



150
151
152
153
154
155
156
157
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 150

def cond_to_hdl
    if @cond.is_a? Array
        csl = @cond.compact
    else
        csl = [@cond].compact
    end 
    return csl.map{|e| e.to_s }.join(",")
end

#instance(as_type = :cond) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 158

def instance(as_type= :cond)
    if cond.is_a? ClassHDL::OpertorChain
        head_str = "#{cond.instance(:cond)}:begin "
    else 
        head_str = "#{cond_to_hdl}:begin "
    end

    sub_str = []
    opertor_chains.each do |oc|
        unless oc.is_a? BlockIF
            unless oc.slaver
                sub_str.push "    #{oc.instance(as_type)};"
            end
        else 
            sub_str.push( oc.instance(as_type).gsub(/^./){ |m| "    #{m}"} )
        end
    end

    return "#{head_str}\n#{sub_str.join("\n")}\nend"

end