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.



2151
2152
2153
2154
2155
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2151

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.



2147
2148
2149
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2147

def base
  @base
end

Instance Method Details

#final_baseObject

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



2158
2159
2160
2161
2162
2163
2164
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2158

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

#rangeObject

Get the access range.



2194
2195
2196
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2194

def range
  return @idx..@idx
end

#to_cObject

Convert to C code.



2204
2205
2206
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2204

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

#to_python(l = "") ⇒ Object

Convert to Python code.



2209
2210
2211
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2209

def to_python(l = "")
  return "#{@base.to_python}[#{@idx.to_python}]"
end

#to_rubyObject

Convert to Ruby code.



2199
2200
2201
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2199

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