Class: ClassHDL::HDLAlwaysFFBlock

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

Direct Known Subclasses

HDLAlwaysSIMBlock

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHDLAlwaysFFBlock

Returns a new instance of HDLAlwaysFFBlock.



37
38
39
40
41
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 37

def initialize
    @opertor_chains = []
    @posedges = []
    @negedges = []
end

Instance Attribute Details

#negedgesObject

Returns the value of attribute negedges.



35
36
37
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 35

def negedges
  @negedges
end

#opertor_chainsObject

Returns the value of attribute opertor_chains.



35
36
37
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 35

def opertor_chains
  @opertor_chains
end

#posedgesObject

Returns the value of attribute posedges.



35
36
37
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 35

def posedges
  @posedges
end

Instance Method Details

#edge_instance(flag = 'posedge', edges = []) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 43

def edge_instance(flag='posedge',edges=[])
    unless edges.is_a? Array
        es = [edges]
    else 
        es = edges 
    end
    es.compact!
    return es.map{|e| "#{flag} #{e.to_s}"}
end

#instanceObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/tdl/class_hdl/hdl_always_ff.rb', line 53

def instance
    str = []

    pose_str = edge_instance('posedge',@posedges)
    nege_str = edge_instance('negedge',@negedges)
    pose_str.concat nege_str

    str.push "always_ff@(#{pose_str.join(",")}) begin "
    opertor_chains.each do |op|
        unless op.is_a? OpertorChain
            str.push op.instance(:always_ff).gsub(/^./){ |m| "    #{m}"}
        else 
            unless op.slaver
                rel_str = ClassHDL.compact_op_ch(op.instance(:always_ff))
                str.push "    #{rel_str};"
            end
        end
        
    end
    str.push "end\n"
    str.join("\n")
end