Class: ClassHDL::HDLInitialBlock

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(belong_to_module) ⇒ HDLInitialBlock

Returns a new instance of HDLInitialBlock.



7
8
9
10
11
12
13
# File 'lib/tdl/class_hdl/hdl_initial.rb', line 7

def initialize(belong_to_module)
    @opertor_chains = []
    @belong_to_module = belong_to_module
    unless @belong_to_module 
        raise TdlError.new("HDLInitialBlock must have belong_to_module")
    end
end

Instance Attribute Details

#belong_to_moduleObject (readonly)

Returns the value of attribute belong_to_module.



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

def belong_to_module
  @belong_to_module
end

#opertor_chainsObject

Returns the value of attribute opertor_chains.



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

def opertor_chains
  @opertor_chains
end

Instance Method Details

#instance(block_name = nil) ⇒ Object



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

def instance(block_name=nil)
    str = []
    str.push "initial begin#{block_name ? ':'.concat(block_name.to_s) : ''}"
    opertor_chains.each do |op|
        unless op.is_a? OpertorChain
            str.push op.instance(:assign).gsub(/^./){ |m| "    #{m}"}
        else 
            unless op.slaver
                rel_str = ClassHDL.compact_op_ch(op.instance(:assign, belong_to_module))
                str.push "    #{rel_str};"
            end
        end
        
    end
    str.push "end\n"
    str.join("\n")
end

#instance_inspectObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/tdl/class_hdl/hdl_initial.rb', line 33

def instance_inspect()
    str = []
    block_name=nil
    str.push "initial begin#{block_name ? ':'.concat(block_name.to_s) : ''}"
    opertor_chains.each do |op|
        unless op.is_a? OpertorChain
            str.push op.instance(:assign).gsub(/^./){ |m| "    #{m}"}
        else 
            unless op.slaver
                rel_str = ClassHDL.compact_op_ch(op.instance(:assign,belong_to_module))
                str.push "    #{rel_str};"
            end
        end
        
    end
    str.push "end\n"
    str.join("\n")
end