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

Methods included from Enumerable

#seach

Class Method Details

.included(klass) ⇒ Object

Properties of expressions are also required



3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
# File 'lib/HDLRuby/hruby_high.rb', line 3316

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.



3344
3345
3346
3347
3348
3349
3350
3351
# File 'lib/HDLRuby/hruby_high.rb', line 3344

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

#objectsObject

Get the refered objects.



3354
3355
3356
3357
# File 'lib/HDLRuby/hruby_high.rb', line 3354

def objects
    return [ self.object] if self.is_a?(RefObject)
    return self.each.map { |ref| ref.objects }.flatten
end

#to_eventObject

Converts to a new event.



3336
3337
3338
3339
# File 'lib/HDLRuby/hruby_high.rb', line 3336

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

#to_refObject

Converts to a new reference.

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

Raises:



3331
3332
3333
# File 'lib/HDLRuby/hruby_high.rb', line 3331

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