Class: HDLRuby::High::Std::ChannelB

Inherits:
Object
  • Object
show all
Includes:
Hmissing, HchannelI
Defined in:
lib/HDLRuby/std/channel.rb

Overview

Describes channel instance wrapper (Box) for fixing arugments.

Constant Summary

Constants included from Hmissing

Hmissing::High

Instance Method Summary collapse

Methods included from HchannelI

#read, #reset, #wrap, #write

Methods included from Hmissing

#method_missing

Constructor Details

#initialize(channelI, *args) ⇒ ChannelB

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: , write: , access:



1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# File 'lib/HDLRuby/std/channel.rb', line 1174

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class HDLRuby::High::Hmissing

Instance Method Details

#branch(name, *args) ⇒ Object

Gets branch channel +name+. NOTE:

  • +name+ can be of any type on purpose.
  • The wrapping arguments are not transmitted to the branch.


1227
1228
1229
# File 'lib/HDLRuby/std/channel.rb', line 1227

def branch(name,*args)
    return @channelI.branch(name,*args)
end

#inout(name = nil) ⇒ Object

Declares the accesser port and assigned them to +name+.



1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
# File 'lib/HDLRuby/std/channel.rb', line 1289

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?Boolean

Tells if the channel support inout port.

Returns:

  • (Boolean)


1232
1233
1234
# File 'lib/HDLRuby/std/channel.rb', line 1232

def inout?
    return @channelI.inout?
end

#input(name = nil) ⇒ Object

Declares the reader port as and assigned them to +name+.



1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
# File 'lib/HDLRuby/std/channel.rb', line 1240

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

#nameObject

The name of the channel instance.



1196
1197
1198
# File 'lib/HDLRuby/std/channel.rb', line 1196

def name
    return @channelI.name
end

#namespaceObject

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



1207
1208
1209
# File 'lib/HDLRuby/std/channel.rb', line 1207

def namespace
    return @channelI.namespace
end

#output(name = nil) ⇒ Object

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



1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
# File 'lib/HDLRuby/std/channel.rb', line 1264

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_portObject

The read port if any.



1212
1213
1214
# File 'lib/HDLRuby/std/channel.rb', line 1212

def read_port
    return @read_port
end

#scopeObject

The scope the channel has been created in.



1201
1202
1203
# File 'lib/HDLRuby/std/channel.rb', line 1201

def scope
    return @channelI.scope
end

#write_portObject

The write port if any.



1217
1218
1219
# File 'lib/HDLRuby/std/channel.rb', line 1217

def write_port
    return @write_port
end