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, #scope

Constructor Details

#initialize(ref, index) ⇒ Configure

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



3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
# File 'lib/HDLRuby/hruby_low.rb', line 3838

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



3834
3835
3836
# File 'lib/HDLRuby/hruby_low.rb', line 3834

def index
  @index
end

#refObject (readonly)

attr_reader :systemI, :systemT, :index



3834
3835
3836
# File 'lib/HDLRuby/hruby_low.rb', line 3834

def ref
  @ref
end

Instance Method Details

#cloneObject

Clones (deeply)



3882
3883
3884
# File 'lib/HDLRuby/hruby_low.rb', line 3882

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.



3897
3898
3899
3900
3901
3902
# File 'lib/HDLRuby/hruby_low.rb', line 3897

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.



3867
3868
3869
3870
3871
3872
3873
3874
# File 'lib/HDLRuby/hruby_low.rb', line 3867

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.



3887
3888
3889
3890
3891
3892
3893
3894
# File 'lib/HDLRuby/hruby_low.rb', line 3887

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.



3905
3906
3907
3908
3909
3910
3911
3912
# File 'lib/HDLRuby/hruby_low.rb', line 3905

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)


3857
3858
3859
3860
3861
3862
# File 'lib/HDLRuby/hruby_low.rb', line 3857

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.



3877
3878
3879
# File 'lib/HDLRuby/hruby_low.rb', line 3877

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.



1478
1479
1480
1481
# File 'lib/HDLRuby/hruby_low2c.rb', line 1478

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