Class: ClassHDL::BlockIF

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBlockIF

Returns a new instance of BlockIF.



5
6
7
8
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 5

def initialize
    @opertor_chains = []
    @cond = nil
end

Instance Attribute Details

#condObject

Returns the value of attribute cond.



4
5
6
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4

def cond
  @cond
end

#opertor_chainsObject

Returns the value of attribute opertor_chains.



4
5
6
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4

def opertor_chains
  @opertor_chains
end

#slaverObject

Returns the value of attribute slaver.



4
5
6
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4

def slaver
  @slaver
end

Instance Method Details

#instance(as_type = :cond) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 10

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

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

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

end