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+



4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
# File 'lib/HDLRuby/hruby_low.rb', line 4036

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



4032
4033
4034
# File 'lib/HDLRuby/hruby_low.rb', line 4032

def index
  @index
end

#refObject (readonly)

attr_reader :systemI, :systemT, :index



4032
4033
4034
# File 'lib/HDLRuby/hruby_low.rb', line 4032

def ref
  @ref
end

Instance Method Details

#cloneObject

Clones (deeply)



4080
4081
4082
# File 'lib/HDLRuby/hruby_low.rb', line 4080

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.



4095
4096
4097
4098
4099
4100
# File 'lib/HDLRuby/hruby_low.rb', line 4095

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.



4065
4066
4067
4068
4069
4070
4071
4072
# File 'lib/HDLRuby/hruby_low.rb', line 4065

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.



4085
4086
4087
4088
4089
4090
4091
4092
# File 'lib/HDLRuby/hruby_low.rb', line 4085

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.



4103
4104
4105
4106
4107
4108
4109
4110
# File 'lib/HDLRuby/hruby_low.rb', line 4103

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)


4055
4056
4057
4058
4059
4060
# File 'lib/HDLRuby/hruby_low.rb', line 4055

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.



4075
4076
4077
# File 'lib/HDLRuby/hruby_low.rb', line 4075

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.



1552
1553
1554
1555
# File 'lib/HDLRuby/hruby_low2c.rb', line 1552

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