Module: HDLRuby::High::HRef

Includes:
Enumerable
Included in:
RefConcat, RefIndex, RefName, RefObject, RefRange, RefThis, SignalC, SignalI
Defined in:
lib/HDLRuby/hruby_high.rb

Overview

Module giving high-level reference properties.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Properties of expressions are also required



3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
# File 'lib/HDLRuby/hruby_high.rb', line 3069

def self.included(klass)
    klass.class_eval do
        include HExpression
        include HArrow

        # Converts to a new expression.
        def to_expr
            self.to_ref
        end
    end
end

Instance Method Details

#each(&ruby_block) ⇒ Object

Iterate over the elements.

Returns an enumerator if no ruby block is given.



3096
3097
3098
3099
3100
3101
3102
3103
# File 'lib/HDLRuby/hruby_high.rb', line 3096

def each(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each) unless ruby_block
    # A block? Apply it on each element.
    self.type.range.heach do |i|
        yield(self[i])
    end
end

#to_eventObject

Converts to a new event.



3089
3090
3091
# File 'lib/HDLRuby/hruby_high.rb', line 3089

def to_event
    return Event.new(:change,self.to_ref)
end

#to_refObject

Converts to a new reference.

NOTE: to be redefined in case of non-reference class.

Raises:



3084
3085
3086
# File 'lib/HDLRuby/hruby_high.rb', line 3084

def to_ref
    raise AnyError, "Internal error: to_ref not defined yet for class: #{self.class}"
end