Class: RubyHDL::High::Unary
- Inherits:
-
Expression
- Object
- Expression
- RubyHDL::High::Unary
- Defined in:
- lib/HDLRuby/std/sequencer_sw.rb
Overview
Describes the software implementation of an unary operation.
Instance Attribute Summary
Attributes inherited from Expression
Instance Method Summary collapse
-
#initialize(type, operator, child) ⇒ Unary
constructor
Create a new unary operation with +type+ data type, operator +operator+ and operand +child+.
-
#to_c ⇒ Object
Convert to C code.
-
#to_ruby ⇒ Object
Convert to Ruby code.
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_c ⇒ Object
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_ruby ⇒ Object
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 |