class HDLRuby::High::Std::ChannelPortB

Describes port wrapper (Box) for fixing arugments.

Public Class Methods

new(port,*args) click to toggle source

Creates a new channel box over channel port port fixing args as arguments. args is a list of arguments to apply to all read, write and access procedure, nil values meaning that the corresponding argument is not overwritten. It can also be three lists for seperate read, write and access procedures using named arguments as: read: <read arguments>, write: <write arguments>, access: <access arguments>

# File lib/HDLRuby/std/channel.rb, line 274
def initialize(port,*args)
    # Ensure port is a channel port.
    unless port.is_a?(ChannelPortR) || port.is_a?(ChannelPortW) ||
            port.is_a?(ChannelPortA) || port.is_a?(ChannelPortB)
        raise "Invalid class for a channel port: #{port.class}"
    end
    @port = port
    # Process the arguments.
    if args.size == 1 && args[0].is_a?(Hash) then
        # Read, write and access are separated.
        @args_read = args[0][:read]
        @args_write = args[0][:write]
        @args_access = args[0][:access]
    else
        @args_read = args
        @args_write = args.clone
        @args_access = args.clone
    end

    @scope = @port.scope
end

Public Instance Methods

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

Performs a read on the channel using args and ruby_block as arguments.

# File lib/HDLRuby/std/channel.rb, line 298
def read(*args,&ruby_block)
    # Generate the final arguments: fills the nil with arguments
    # from args
    rargs = @args_read.clone
    rargs.map! { |arg| arg == nil ? args.shift : arg }
    # And add the remaining at the tail.
    rargs += args
    @port.read(*rargs,&ruby_block)
end
reset(*args,&ruby_block) click to toggle source

Performs a reset on the channel using args and ruby_block as arguments.

# File lib/HDLRuby/std/channel.rb, line 322
def reset(*args,&ruby_block)
    @port.reset(*@args,*args)
end
write(*args,&ruby_block) click to toggle source

Performs a write on the channel using args and ruby_block as arguments.

# File lib/HDLRuby/std/channel.rb, line 310
def write(*args,&ruby_block)
    # Generate the final arguments: fills the nil with arguments
    # from args
    rargs = @args_write.clone
    rargs.map! { |arg| arg == nil ? args.shift : arg }
    # And add the remaining at the tail.
    rargs += args
    @port.write(*rargs,&ruby_block)
end