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+



1916
1917
1918
1919
1920
1921
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1916

def initialize(type,operator,child)
  super(type)
  @operator = operator.to_sym
  @child = child.to_expr
  @mask = (2 ** @type.width)-1
end

Instance Method Details

#to_cObject

Convert to C code.



1930
1931
1932
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1930

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

#to_rubyObject

Convert to Ruby code.



1924
1925
1926
1927
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1924

def to_ruby
  # return RUBY_OPERATOR[@operator] % @child.to_ruby
  return RUBY_OPERATOR[@operator] % { l: @child.to_ruby }
end