Class: RubyHDL::High::RefRange

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

Overview

Describes a SW implementation of an range 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, rng) ⇒ RefRange

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



1872
1873
1874
1875
1876
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1872

def initialize(type,base,rng)
  super(type)
  @base = base.to_ref
  @rng = (rng.first.to_expr)..(rng.last.to_expr)
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



1868
1869
1870
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1868

def base
  @base
end

Instance Method Details

#final_baseObject

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



1884
1885
1886
1887
1888
1889
1890
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1884

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

#rangeObject

Get the access range.



1879
1880
1881
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1879

def range
  return @rng.first..@rng.last
end

#to_rubyObject

Convert to ruby code.



1920
1921
1922
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1920

def to_ruby
  return "#{@base.to_ruby}[#{@rng.first.to_ruby}..#{@rng.last.to_ruby}]"
end