Class: RubyHDL::High::RefIndex
- Inherits:
-
Ref
- Object
- Expression
- Ref
- RubyHDL::High::RefIndex
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes a SW implementation of an index reference.
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Attributes inherited from Expression
Instance Method Summary collapse
-
#final_base ⇒ Object
Get the final base object of the binary if it is an [] operator.
-
#initialize(type, base, idx) ⇒ RefIndex
constructor
Create a new index reference with +type+ data type +base+ base reference and +idx+ index.
-
#range ⇒ Object
Get the access range.
-
#to_c ⇒ Object
Convert to C code.
-
#to_python(l = "") ⇒ Object
Convert to Python code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
-
#to_tf(l = "") ⇒ Object
Convert to TensorFlow code.
Methods inherited from Ref
Methods inherited from Expression
#<=, #[], #heach, #mux, #sdownto, #seach, #stimes, #supto, #to_expr, #to_value
Methods included from HEnumerable
#hall?, #hany?, #hchain, #hchunk, #hchunk_while, #hcompact, #hcount, #hcycle, #hdrop, #hdrop_while, #heach_cons, #heach_entry, #heach_range, #heach_slice, #heach_with_index, #heach_with_object, #hfind, #hfind_index, #hfirst, #hflat_map, #hgrep, #hgrep_v, #hgroup_by, #hinclude?, #hinject, #hlazy, #hmap, #hmax, #hmax_by, #hmin, #hmin_by, #hminmax, #hminmax_by, #hnone?, #hone?, #hpartition, #hreduce, #hreject, #hreverse_each, #hselect, #hslice_after, #hslice_before, #hslice_when, #hsort, #hsort_by, #hsum, #htake, #htake_while, #htally, #hto_a, #hto_h, #huniq, #hzip
Constructor Details
#initialize(type, base, idx) ⇒ RefIndex
Create a new index reference with +type+ data type +base+ base reference and +idx+ index.
2611 2612 2613 2614 2615 2616 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2611 def initialize(type,base,idx) super(type) @base = base.to_expr @idx = idx.to_expr @npow = 2 ** @idx.type.width end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
2607 2608 2609 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2607 def base @base end |
Instance Method Details
#final_base ⇒ Object
Get the final base object of the binary if it is an [] operator.
2619 2620 2621 2622 2623 2624 2625 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2619 def final_base if @base.is_a?(Ref) then return @base.final_base else return @base end end |
#range ⇒ Object
Get the access range.
2655 2656 2657 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2655 def range return @idx..@idx end |
#to_c ⇒ Object
Convert to C code.
2665 2666 2667 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2665 def to_c return "#{@base.to_c}[(#{@idx.to_c}) % #{@npow}]" end |
#to_python(l = "") ⇒ Object
Convert to Python code.
2670 2671 2672 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2670 def to_python(l = "") return "#{@base.to_python}[(#{@idx.to_python}) % #{@npow}]" end |
#to_ruby ⇒ Object
Convert to Ruby code.
2660 2661 2662 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2660 def to_ruby return "#{@base.to_ruby}[(#{@idx.to_ruby}) % #{@npow}]" end |
#to_tf(l = "") ⇒ Object
Convert to TensorFlow code.
2675 2676 2677 |
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2675 def to_tf(l = "") return "#{@base.to_tf}[#{@idx.to_tf} % #{@npow}]" end |