Class: HDLRuby::Low::Configure

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

Overview

Describes a system instance (re)configuration statement: not synthesizable!

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!, #fix_scope_refnames!, #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

#absolute_ref, #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+



4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
# File 'lib/HDLRuby/hruby_low.rb', line 4204

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



4200
4201
4202
# File 'lib/HDLRuby/hruby_low.rb', line 4200

def index
  @index
end

#refObject (readonly)

attr_reader :systemI, :systemT, :index



4200
4201
4202
# File 'lib/HDLRuby/hruby_low.rb', line 4200

def ref
  @ref
end

Instance Method Details

#cloneObject

Clones (deeply)



4248
4249
4250
# File 'lib/HDLRuby/hruby_low.rb', line 4248

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.



4263
4264
4265
4266
4267
4268
# File 'lib/HDLRuby/hruby_low.rb', line 4263

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.



4233
4234
4235
4236
4237
4238
4239
4240
# File 'lib/HDLRuby/hruby_low.rb', line 4233

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.



4253
4254
4255
4256
4257
4258
4259
4260
# File 'lib/HDLRuby/hruby_low.rb', line 4253

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.



4271
4272
4273
4274
4275
4276
4277
4278
# File 'lib/HDLRuby/hruby_low.rb', line 4271

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)


4223
4224
4225
4226
4227
4228
# File 'lib/HDLRuby/hruby_low.rb', line 4223

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.



115
116
117
118
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 115

def explicit_types!
    # Nothing to do.
    return self
end

#hashObject

Hash function.



4243
4244
4245
# File 'lib/HDLRuby/hruby_low.rb', line 4243

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.



1559
1560
1561
1562
# File 'lib/HDLRuby/hruby_low2c.rb', line 1559

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