Class: HDLRuby::High::RefConcat
- Inherits:
-
Low::RefConcat
- Object
- Base::Expression
- Low::Expression
- Low::Ref
- Low::RefConcat
- HDLRuby::High::RefConcat
- Includes:
- HRef
- Defined in:
- lib/HDLRuby/hruby_high.rb,
lib/HDLRuby/hruby_rsim.rb,
lib/HDLRuby/hruby_rcsim.rb
Overview
Extends the RefConcat 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::Expression
Attributes included from Low::Hparent
Instance Method Summary collapse
-
#assign(mode, value) ⇒ Object
Assigns +value+ the the reference.
-
#assign_at(mode, value, index) ⇒ Object
Assigns +value+ at +index+ (integer or range).
-
#execute(mode) ⇒ Object
Execute the expression.
-
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
-
#to_low ⇒ Object
Converts the concat reference to HDLRuby::Low.
-
#to_rcsim ⇒ Object
Generate the C description of the reference concat.
-
#to_ref ⇒ Object
Converts to a new reference.
Methods included from HRef
Methods inherited from Low::RefConcat
#add_ref, #boolean_in_assign2select, #casts_without_expression!, #clone, #delete_ref!, #each_deep, #each_node_deep, #each_ref, #eql?, #explicit_types, #hash, #immutable?, #initialize, #map_refs!, #to_c, #to_c_signal, #to_hdr, #to_high, #to_verilog, #to_vhdl, #use_name?
Methods included from Low::MutableConcat
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
Methods included from Low::Hparent
#hierarchy, #no_parent!, #scope
Constructor Details
This class inherits a constructor from HDLRuby::Low::RefConcat
Instance Method Details
#assign(mode, value) ⇒ Object
Assigns +value+ the the reference.
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 967 def assign(mode,value) # puts "self.type=#{self.type}" # Flatten the value type. value.type = [value.type.width].to_type pos = 0 width = 0 # Recurse on the children. @refs.reverse_each do |ref| # puts "ref.type=#{ref.type}" width = ref.type.width # puts "pos=#{pos} width=#{width}, pos+width-1=#{pos+width-1}" # puts "value.content=#{value.content}" # puts "value[(pos+width-1).to_expr..pos.to_expr].content=#{value[(pos+width-1).to_expr..pos.to_expr].content}" ref.assign(mode,value[(pos+width-1).to_expr..pos.to_expr]) # Prepare for the next reference. pos += width end end |
#assign_at(mode, value, index) ⇒ Object
Assigns +value+ at +index+ (integer or range).
987 988 989 990 991 992 993 994 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 987 def assign_at(mode,value,index) # Get the refered value. refv = self.execute(mode,value) # Assign to it. refv.assign_at(mode,value,index) # Update the reference. self.assign(mode,refv) end |
#execute(mode) ⇒ Object
Execute the expression.
959 960 961 962 963 964 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 959 def execute(mode) # Recurse on the children. tmpe = self.each_ref.map { |ref| ref.execute(mode) } # Concatenate the result. return tmpe.reduce(:concat) end |
#init_sim(systemT) ⇒ Object
Initialize the simulation for system +systemT+.
954 955 956 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 954 def init_sim(systemT) self.each_ref { |ref| ref.init_sim(systemT) } end |
#to_low ⇒ Object
Converts the concat reference to HDLRuby::Low.
3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 |
# File 'lib/HDLRuby/hruby_high.rb', line 3404 def to_low # return HDLRuby::Low::RefConcat.new(self.type.to_low, # self.each_ref.map do |ref| # ref.to_low # end # ) refConcatL = HDLRuby::Low::RefConcat.new(self.type.to_low, self.each_ref.map do |ref| ref.to_low end ) # # For debugging: set the source high object # refConcatL.properties[:low2high] = self.hdr_id # self.properties[:high2low] = refConcatL return refConcatL end |
#to_rcsim ⇒ Object
Generate the C description of the reference concat.
895 896 897 898 899 900 901 902 903 904 905 906 907 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 895 def to_rcsim # Create the reference concat C object. rcref = RCSim.rcsim_make_refConcat(self.type.to_rcsim, self.type.direction) # Add the concatenated expressions. */ # self.each_ref do |ref| # RCSim.rcsim_add_refConcat_ref(rcref,ref.to_rcsim) # end RCSim.rcsim_add_refConcat_refs(rcref,self.each_ref(&:to_rcsim)) return rcref end |