class HDLRuby::High::Std::ChannelPortObject

Wrapper to make an object run like a channel port.

Public Class Methods

new(obj) click to toggle source

Create a new object wrapper for obj.

# File lib/HDLRuby/std/channel.rb, line 1368
def initialize(obj)
    @obj = obj

    @scope = HDLRuby::High.cur_scope
end

Public Instance Methods

read(*args,&ruby_block) click to toggle source

Port read with arguments args executing ruby_block in case of success.

# File lib/HDLRuby/std/channel.rb, line 1376
def read(*args,&ruby_block)
    # Get the target from the arguments.
    target = args.pop
    # Is there any argument left?
    unless (args.empty?) then
        # There are arguments left, perform an array access.
        target <= @obj[*args]
    else
        # There are no argument left, perform a direct access.
        target <= @obj
    end
    # Execute the ruby_block if any.
    ruby_block.call if ruby_block 
end
write(*args,&ruby_block) click to toggle source

Port write with argumnet Args executing ruby_block in case of success.

# File lib/HDLRuby/std/channel.rb, line 1393
def write(*args,&ruby_block)
    # Get the value to write from the arguments.
    value = args.pop
    # Is there any argument left?
    unless (args.empty?) then
        # There are arguments left, perform an array access.
        @obj[*args] <= value
    else
        # There are no argument left, perform a direct access.
        @obj <= value
    end
    # Execute the ruby_block if any.
    ruby_block.call if ruby_block 
end