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+



1998
1999
2000
2001
2002
2003
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 1998

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.



2012
2013
2014
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2012

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

#to_python(l = "") ⇒ Object

Convert to Python code.



2017
2018
2019
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2017

def to_python(l = "")
  return PYTHON_OPERATOR[@operator] % { l: @child.to_python }
end

#to_rubyObject

Convert to Ruby code.



2006
2007
2008
2009
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2006

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