Class: HDLRuby::High::Unary

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

Overview

Extends the Unary 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 collapse

Attributes included from HExpression

#systemT, #type

Attributes inherited from Low::Unary

#child

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

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

Methods included from Low::OneChildMutable

#map_nodes!, #replace_expressions!, #set_child!

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

Instance Attribute Details

#rcexpressionObject (readonly)

Returns the value of attribute rcexpression.



808
809
810
# File 'lib/HDLRuby/hruby_rcsim.rb', line 808

def rcexpression
  @rcexpression
end

Instance Method Details

#execute(mode) ⇒ Object

Execute the expression.



868
869
870
871
872
873
874
875
# File 'lib/HDLRuby/hruby_rsim.rb', line 868

def execute(mode)
    # puts "Unary with operator=#{self.operator}"
    # Recurse on the child.
    tmp = self.child.execute(mode)
    # puts "tmp=#{tmp}"
    # Apply the operator.
    return tmp.send(self.operator)
end

#to_exprObject

Converts to a new expression.



3112
3113
3114
# File 'lib/HDLRuby/hruby_high.rb', line 3112

def to_expr
    return Unary.new(self.type,self.operator,self.child.to_expr)
end

#to_lowObject

Converts the unary expression to HDLRuby::Low.



3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
# File 'lib/HDLRuby/hruby_high.rb', line 3117

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

#to_rcsimObject

Generate the C description of the unary operation.



811
812
813
814
815
# File 'lib/HDLRuby/hruby_rcsim.rb', line 811

def to_rcsim
    # Create the unary C object.
    return RCSim.rcsim_make_unary(self.type.to_rcsim,self.operator,
                            self.child.to_rcsim)
end