Class: HDLRuby::High::RefIndex

Inherits:
Low::RefIndex show all
Includes:
HRef
Defined in:
lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb

Overview

Extends the RefIndex class for hybrid Ruby-C simulation.

Constant Summary

Constants included from Low::Low2Symbol

Low::Low2Symbol::Low2SymbolPrefix, Low::Low2Symbol::Low2SymbolTable, Low::Low2Symbol::Symbol2LowTable

Instance Attribute Summary

Attributes inherited from Low::RefIndex

#index, #ref

Attributes inherited from Low::Expression

#type

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods included from HRef

#each, included, #to_event

Methods inherited from Low::RefIndex

#boolean_in_assign2select, #casts_without_expression!, #clone, #each_deep, #each_node, #each_node_deep, #eql?, #explicit_types, #from_systemI?, #hash, #immutable?, #initialize, #map_nodes!, #path_each, #replace_expressions!, #resolve, #set_index!, #set_ref!, #to_c, #to_c_signal, #to_hdr, #to_high, #to_verilog, #to_vhdl, #use_name?

Methods inherited from Low::Ref

#each_node, #each_node_deep, #eql?, #explicit_types, #hash, #map_nodes!, #path_each, #resolve, #to_c, #to_hdr, #to_vhdl

Methods inherited from Low::Expression

#boolean?, #break_types!, #clone, #each_node, #each_node_deep, #each_ref_deep, #eql?, #explicit_types, #extract_selects_to!, #hash, #immutable?, #initialize, #leftvalue?, #map_nodes!, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #statement, #to_c, #to_c_expr, #to_hdr, #to_high, #to_vhdl, #use_name?

Methods included from Low::Low2Symbol

#to_sym

Methods included from Low::Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

This class inherits a constructor from HDLRuby::Low::RefIndex

Instance Method Details

#assign(mode, value) ⇒ Object

Assigns +value+ the the reference.



1091
1092
1093
1094
1095
1096
# File 'lib/HDLRuby/hruby_rsim.rb', line 1091

def assign(mode,value)
    # Compute the index.
    idx = self.index.execute(mode).to_i
    # Assigns.
    self.ref.assign_at(mode,value,idx)
end

#assign_at(mode, value, index) ⇒ Object

Assigns +value+ at +index+ (integer or range).



1099
1100
1101
1102
1103
1104
1105
1106
# File 'lib/HDLRuby/hruby_rsim.rb', line 1099

def assign_at(mode,value,index)
    # Get the refered value.
    refv = self.execute(mode)
    # Assign to it.
    refv = refv.assign_at(mode,value,index)
    # Update the refered value.
    self.assign(mode,refv)
end

#execute(mode) ⇒ Object

Execute the expression.



1082
1083
1084
1085
1086
1087
1088
# File 'lib/HDLRuby/hruby_rsim.rb', line 1082

def execute(mode)
    # Recurse on the children.
    tmpr = self.ref.execute(mode)
    idx = self.index.execute(mode)
    # puts "tmpr=#{tmpr} idx=#{idx} tmpr[idx]=#{tmpr[idx]}"
    return tmpr[idx]
end

#init_sim(systemT) ⇒ Object

Initialize the simulation for system +systemT+.



1077
1078
1079
# File 'lib/HDLRuby/hruby_rsim.rb', line 1077

def init_sim(systemT)
    self.ref.init_sim(systemT)
end

#to_lowObject

Converts the index reference to HDLRuby::Low.



3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
# File 'lib/HDLRuby/hruby_high.rb', line 3435

def to_low
    # return HDLRuby::Low::RefIndex.new(self.type.to_low,
    #                                 self.ref.to_low,self.index.to_low)
    refIndexL = HDLRuby::Low::RefIndex.new(self.type.to_low,
                                    self.ref.to_low,self.index.to_low)
    # # For debugging: set the source high object 
    # refIndexL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = refIndexL
    return refIndexL
end

#to_rcsimObject

Generate the C description of the reference index.



962
963
964
965
966
# File 'lib/HDLRuby/hruby_rcsim.rb', line 962

def to_rcsim
    # Create the reference index C object.
    return RCSim.rcsim_make_refIndex(self.type.to_rcsim,
                               self.index.to_rcsim,self.ref.to_rcsim)
end

#to_refObject

Converts to a new reference.



3428
3429
3430
3431
3432
# File 'lib/HDLRuby/hruby_high.rb', line 3428

def to_ref
    return RefIndex.new(self.type,
                        # self.ref.to_ref,self.index.to_expr)
                        self.ref.to_expr,self.index.to_expr)
end