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

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

Methods included from HEnumerable

#hall?, #hany?, #hchain, #hchunk, #hchunk_while, #hcompact, #hcount, #hcycle, #hdrop, #hdrop_while, #heach_cons, #heach_entry, #heach_range, #heach_slice, #heach_with_index, #heach_with_object, #hfind, #hfind_index, #hfirst, #hflat_map, #hgrep, #hgrep_v, #hgroup_by, #hinclude?, #hinject, #hlazy, #hmap, #hmax, #hmax_by, #hmin, #hmin_by, #hminmax, #hminmax_by, #hnone?, #hone?, #hpartition, #hreduce, #hreject, #hreverse_each, #hselect, #hslice_after, #hslice_before, #hslice_when, #hsort, #hsort_by, #hsum, #htake, #htake_while, #htally, #hto_a, #hto_h, #huniq, #hzip

Constructor Details

#initialize(type, operator, child) ⇒ Unary

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



2428
2429
2430
2431
2432
2433
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2428

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.



2442
2443
2444
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2442

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

#to_python(l = "") ⇒ Object

Convert to Python code.



2447
2448
2449
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2447

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

#to_rubyObject

Convert to Ruby code.



2436
2437
2438
2439
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2436

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

#to_tf(l = "") ⇒ Object

Convert to Python code.



2452
2453
2454
# File 'lib/HDLRuby/std/sequencer_sw.rb', line 2452

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