Class: RubyHDL::High::Unary

Inherits:
Expression show all
Defined in:
lib/HDLRuby/std/sequencer_sw.rb

Overview

Describes the software implementation of an unary operation.

Instance Attribute Summary

Attributes inherited from Expression

#type

Instance Method Summary collapse

Methods inherited from Expression

#<=, #[], #mux, #sdownto, #seach, #stimes, #supto, #to_expr, #to_value

Constructor Details

#initialize(type, operator, child) ⇒ Unary

Create a new unary operation with +type+ data type, operator +operator+ and operand +child+



1822
1823
1824
1825
1826
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1822

def initialize(type,operator,child)
  super(type)
  @operator = operator.to_sym
  @child = child.to_expr
end

Instance Method Details

#to_cObject

Convert to C code.



1834
1835
1836
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1834

def to_c
  return C_OPERATOR[@operator] % @child.to_c
end

#to_rubyObject

Convert to Ruby code.



1829
1830
1831
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1829

def to_ruby
  return RUBY_OPERATOR[@operator] % @child.to_ruby
end