Class: HDLRuby::High::Binary

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

Overview

Extends the Binary 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::Binary

#left, #right

Attributes inherited from Low::Operation

#operator

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

#boolean?, #boolean_in_assign2select, #casts_without_expression!, #clone, #each_deep, #each_node, #each_node_deep, #each_ref_deep, #eql?, #explicit_types, #hash, #immutable?, #initialize, #map_nodes!, #replace_expressions!, #set_left!, #set_right!, #to_c, #to_change, #to_hdr, #to_high, #to_verilog, #to_vhdl, #use_name?

Methods inherited from Low::Operation

#eql?, #explicit_types, #hash, #initialize, #set_operator!, #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::Binary

Instance Method Details

#execute(mode) ⇒ Object

Execute the expression.



883
884
885
886
887
888
889
# File 'lib/HDLRuby/hruby_rsim.rb', line 883

def execute(mode)
    # Recurse on the children.
    tmpl = self.left.execute(mode)
    tmpr = self.right.execute(mode)
    # Apply the operator.
    return tmpl.send(self.operator,tmpr)
end

#to_exprObject

Converts to a new expression.



3136
3137
3138
3139
# File 'lib/HDLRuby/hruby_high.rb', line 3136

def to_expr
    return Binary.new(self.type, self.operator,
                      self.left.to_expr, self.right.to_expr)
end

#to_lowObject

Converts the binary expression to HDLRuby::Low.



3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
# File 'lib/HDLRuby/hruby_high.rb', line 3142

def to_low
    # return HDLRuby::Low::Binary.new(self.type.to_low, self.operator,
    #                                self.left.to_low, self.right.to_low)
    binaryL = HDLRuby::Low::Binary.new(self.type.to_low, self.operator,
                                   self.left.to_low, self.right.to_low)
    # # For debugging: set the source high object 
    # binaryL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = binaryL
    return binaryL
end

#to_rcsimObject

Generate the C description of the binary operation.



823
824
825
826
827
828
# File 'lib/HDLRuby/hruby_rcsim.rb', line 823

def to_rcsim
    # Create the binary C object.
    return RCSim.rcsim_make_binary(self.type.to_rcsim,self.operator,
                             self.left.to_rcsim,
                             self.right.to_rcsim)
end