Class: HDLRuby::Low::Configure

Inherits:
Statement
  • Object
show all
Defined in:
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low_fix_types.rb

Overview

Extends the Configure class with fixing of types and constants.

Direct Known Subclasses

High::Configure

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary collapse

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Statement

#add_blocks_code, #add_make_block, #behavior, #block, #blocks2seq!, #break_types!, #delete_related!, #delete_unless!, #each_statement, #extract_declares!, #mix?, #par_in_seq2seq!, #parent_system, #replace_expressions!, #replace_names!, #scope, #to_ch, #to_hdr, #to_high, #to_seq!, #to_upper_space!, #to_vhdl, #top_block, #top_scope, #use_name?, #with_boolean!

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

#initialize(ref, index) ⇒ Configure

Creates a new (re)configure statement of system instance refered by +ref+ with system number +index+



3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
# File 'lib/HDLRuby/hruby_low.rb', line 3872

def initialize(ref,index)
    super()
    # Process the arguments.
    index = index.to_i
    unless ref.is_a?(Ref) then
        raise "Invalid class for a reference: #{ref.class}."
    end
    # Sets the arguments.
    @ref = ref
    ref.parent = self
    @index = index
    # @systemT = systemI.each_systemT.to_a[index]
    # # Check the systemT is valid.
    # unless @systemT then
    #     raise "Invalid configuration index: #{index}."
    # end
end

Instance Attribute Details

#indexObject (readonly)

attr_reader :systemI, :systemT, :index



3868
3869
3870
# File 'lib/HDLRuby/hruby_low.rb', line 3868

def index
  @index
end

#refObject (readonly)

attr_reader :systemI, :systemT, :index



3868
3869
3870
# File 'lib/HDLRuby/hruby_low.rb', line 3868

def ref
  @ref
end

Instance Method Details

#cloneObject

Clones (deeply)



3916
3917
3918
# File 'lib/HDLRuby/hruby_low.rb', line 3916

def clone
    return Configure.new(@ref.clone,@index)
end

#each_block_deep(&ruby_block) ⇒ Object

Iterates over all the blocks contained in the current block.



3931
3932
3933
3934
3935
3936
# File 'lib/HDLRuby/hruby_low.rb', line 3931

def each_block_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_block_deep) unless ruby_block
    # A ruby block?
    # Nothing more to do anyway.
end

#each_deep(&ruby_block) ⇒ Object

Iterates over each object deeply.

Returns an enumerator if no ruby block is given.



3901
3902
3903
3904
3905
3906
3907
3908
# File 'lib/HDLRuby/hruby_low.rb', line 3901

def each_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    # Then apply on the reference.
    @ref.each_deep(&ruby_block)
end

#each_node_deep(&ruby_block) ⇒ Object

Iterates over the nodes deeply if any.



3921
3922
3923
3924
3925
3926
3927
3928
# File 'lib/HDLRuby/hruby_low.rb', line 3921

def each_node_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    # And recurse on the reference.
    @ref.each_node_deep(&ruby_block)
end

#each_statement_deep(&ruby_block) ⇒ Object

Iterates over all the statements contained in the current block.



3939
3940
3941
3942
3943
3944
3945
3946
# File 'lib/HDLRuby/hruby_low.rb', line 3939

def each_statement_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_statement_deep) unless ruby_block
    # A ruby block?
    # Apply it on self.
    ruby_block.call(self)
    # And that's all.
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


3891
3892
3893
3894
3895
3896
# File 'lib/HDLRuby/hruby_low.rb', line 3891

def eql?(obj)
    return false unless obj.is_a?(Configure)
    return false unless @ref.eql?(obj.ref)
    return false unless @index.eql?(obj.index)
    return true
end

#explicit_types!Object

Explicit the types conversions in the statement.



107
108
109
110
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 107

def explicit_types!
    # Nothing to do.
    return self
end

#hashObject

Hash function.



3911
3912
3913
# File 'lib/HDLRuby/hruby_low.rb', line 3911

def hash
    return (@ref.hash + @index.hash).hash
end

#to_c(res, level = 0) ⇒ Object

Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object.



1483
1484
1485
1486
# File 'lib/HDLRuby/hruby_low2c.rb', line 1483

def to_c(res,level = 0)
    # Save the value pool state.
    res << (" " * (level*3)) << "configure(#{Low2C.obj_name(self.ref.resolve)},#{self.index});\n"
end