class HDLRuby::High::Std::ChannelB

Describes channel instance wrapper (Box) for fixing arugments.

Public Class Methods

new(channelI,*args) click to toggle source

Create a new channel box over channelI channel instance using args for fixing the arguments as follows: 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 1215
def initialize(channelI,*args)
    # Ensure port is a channel port.
    unless channelI.is_a?(ChannelI) || channel.is_a?(ChannelB)
        raise "Invalid class for a channel instance: #{ch.class}"
    end
    @channelI = channelI
    # 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
end

Public Instance Methods

branch(name,*args) click to toggle source

Gets branch channel name. NOTE:

* +name+ can be of any type on purpose.
* The wrapping arguments are not transmitted to the branch.
# File lib/HDLRuby/std/channel.rb, line 1268
def branch(name,*args)
    return @channelI.branch(name,*args)
end
inout(name = nil) click to toggle source

Declares the accesser port and assigned them to name.

# File lib/HDLRuby/std/channel.rb, line 1330
def inout(name = nil)
    # Ensure name is a symbol.
    name = HDLRuby.uniq_name unless name
    name = name.to_sym
    # Ensure the port is not already existing.
    if @read_port then
        raise "Read port already declared for channel instance: " +
            self.name
    end
    if @write_port then
        raise "Write port already declared for channel instance: " +
            self.name
    end

    # Create a write port for the encaspulted channel.
    if @channelI.read_port == @channelI.write_port then
        real_port = @channelI.read_port
        real_port = @channelI.inout unless real_port
    else
        raise "Inout port not supported for channel #{@channelI}"
    end

    # Wrap it to a new port using.
    chp = real_port.wrap(read: @args_read, write: @args_write)

    HDLRuby::High.space_reg(name) { chp }
    # Save the port in the channe to avoid conflicting declaration.
    @write_port = chp
    @read_port = chp
    return chp
end
inout?() click to toggle source

Tells if the channel support inout port.

# File lib/HDLRuby/std/channel.rb, line 1273
def inout?
    return @channelI.inout?
end
input(name = nil) click to toggle source

Declares the reader port as and assigned them to name.

# File lib/HDLRuby/std/channel.rb, line 1281
def input(name = nil)
    # Ensure name is a symbol.
    name = HDLRuby.uniq_name unless name
    name = name.to_sym
    # Ensure the port is not already existing.
    if @read_port then
        raise "Read port already declared for channel instance: " +
            self.name
    end

    # Create a read port for the encaspulted channel.
    real_port = @channelI.read_port
    real_port = @channelI.input unless real_port

    # Wrap it to a new port using.
    chp = real_port.wrap(read: @args_read)

    HDLRuby::High.space_reg(name) { chp }
    # Save the port in the channe to avoid conflicting declaration.
    @read_port = chp
    return chp
end
name() click to toggle source

The name of the channel instance.

# File lib/HDLRuby/std/channel.rb, line 1237
def name
    return @channelI.name
end
namespace() click to toggle source

The namespace associated with the current execution when building a channel.

# File lib/HDLRuby/std/channel.rb, line 1248
def namespace
    return @channelI.namespace
end
output(name = nil) click to toggle source

Declares the ports for the writer and assigned them to name.

# File lib/HDLRuby/std/channel.rb, line 1305
def output(name = nil)
    # Ensure name is a symbol.
    name = HDLRuby.uniq_name unless name
    name = name.to_sym
    # Ensure the port is not already existing.
    if @write_port then
        raise "Read port already declared for channel instance: " +
            self.name
    end

    # Create a write port for the encaspulted channel.
    real_port = @channelI.write_port
    real_port = @channelI.output unless real_port

    # Wrap it to a new port using.
    chp = real_port.wrap(write: @args_write)

    HDLRuby::High.space_reg(name) { chp }
    # Save the port in the channe to avoid conflicting declaration.
    @write_port = chp
    return chp
end
read_port() click to toggle source

The read port if any.

# File lib/HDLRuby/std/channel.rb, line 1253
def read_port
    return @read_port
end
scope() click to toggle source

The scope the channel has been created in.

# File lib/HDLRuby/std/channel.rb, line 1242
def scope
    return @channelI.scope
end
write_port() click to toggle source

The write port if any.

# File lib/HDLRuby/std/channel.rb, line 1258
def write_port
    return @write_port
end