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.
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1042 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).
1062 1063 1064 1065 1066 1067 1068 1069 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1062 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.
1034 1035 1036 1037 1038 1039 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1034 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+.
1029 1030 1031 |
# File 'lib/HDLRuby/hruby_rsim.rb', line 1029 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.
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'lib/HDLRuby/hruby_rcsim.rb', line 938 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 if self.each_ref.any? then RCSim.rcsim_add_refConcat_refs(rcref,self.each_ref(&:to_rcsim)) end return rcref end |