Class: RubyHDL::High::RefIndex

Inherits:
Ref show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes a SW implementation of an index reference.

Instance Attribute Summary collapse

Attributes inherited from Expression

#type

Instance Method Summary collapse

Methods inherited from Ref

#to_ref

Methods inherited from Expression

#<=, #[], #mux, #sdownto, #seach, #stimes, #supto, #to_expr, #to_value

Constructor Details

#initialize(type, base, idx) ⇒ RefIndex

Create a new index reference with +type+ data type +base+ base reference and +idx+ index.



1813
1814
1815
1816
1817
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1813

def initialize(type,base,idx)
  super(type)
  @base = base.to_expr
  @idx = idx.to_expr
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



1809
1810
1811
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1809

def base
  @base
end

Instance Method Details

#final_baseObject

Get the final base object of the binary if it is an [] operator.



1820
1821
1822
1823
1824
1825
1826
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1820

def final_base
  if @base.is_a?(Ref) then
    return @base.final_base
  else
    return @base
  end
end

#rangeObject

Get the access range.



1856
1857
1858
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1856

def range
  return @idx..@idx
end

#to_rubyObject

Convert to ruby code.



1861
1862
1863
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1861

def to_ruby
  return "#{@base.to_ruby}[#{@idx.to_ruby}]"
end