Class: HDLRuby::High::Concat

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

Overview

Extends the Concat 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 included from HExpression

#systemT, #type

Attributes inherited from Low::Expression

#type

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods included from HExpression

#[], #as, #coerce, #constant?, #inout, #input, #ljust, #lr, #ls, #match_type, #mux, orig_operator, #orig_operator, #output, #rjust, #rr, #rs, #sext, #to_bit, #to_unsigned, #to_value, #to_value?, #zext

Methods inherited from Low::Concat

#add_expression, #boolean_in_assign2select, #casts_without_expression!, #clone, #delete_expression!, #each_deep, #each_expression, #each_node_deep, #eql?, #explicit_types, #hash, #immutable?, #initialize, #map_expressions!, #to_c, #to_hdr, #to_high, #to_verilog, #to_vhdl, #use_name?

Methods included from Low::MutableConcat

#replace_expressions!

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::Concat

Instance Method Details

#execute(mode, reverse = false) ⇒ Object

Execute the expression.



912
913
914
915
916
917
918
919
920
921
922
923
# File 'lib/HDLRuby/hruby_rsim.rb', line 912

def execute(mode, reverse=false)
    # Recurse on the children.
    tmpe = self.each_expression.map { |expr| expr.execute(mode) }
    # Ensure the order of the elements matches the type.
    if (self.type.direction == :little && !reverse) || 
       (self.type.direction == :big && reverse) then
        tmpe.reverse!
    end
    # puts "concat result=#{Vprocess.concat(*tmpe).to_bstr}"
    # Concatenate the result.
    return Vprocess.concat(*tmpe)
end

#to_exprObject

Converts to a new expression.



3196
3197
3198
3199
3200
3201
3202
# File 'lib/HDLRuby/hruby_high.rb', line 3196

def to_expr
    return Concat.new(self.type,
        self.each_expression.map do |expr|
            expr.to_expr
        end
    )
end

#to_lowObject

Converts the concatenation expression to HDLRuby::Low.



3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
# File 'lib/HDLRuby/hruby_high.rb', line 3205

def to_low
    # return HDLRuby::Low::Concat.new(self.type.to_low,
    #     self.each_expression.map do |expr|
    #         expr.to_low
    #     end
    # )
    concatL = HDLRuby::Low::Concat.new(self.type.to_low,
        self.each_expression.map do |expr|
            expr.to_low
        end
    )
    # # For debugging: set the source high object 
    # concatL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = concatL
    return concatL
end

#to_rcsimObject

Generate the C description of the concat operation.



859
860
861
862
863
864
865
866
867
868
869
870
871
872
# File 'lib/HDLRuby/hruby_rcsim.rb', line 859

def to_rcsim
    # Create the concat C object.
    rcexpression = RCSim.rcsim_make_concat(self.type.to_rcsim,
                                     self.type.direction)

    # Add the concatenated expressions. */
    # self.each_expression do |expr|
    #     RCSim.rcsim_add_concat_expression(rcexpression,expr.to_rcsim)
    # end
    RCSim.rcsim_add_concat_expressions(rcexpression,
                                 self.each_expression.map(&:to_rcsim))
    
    return rcexpression
end