Class: HDLRuby::High::Std::ChannelB
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::ChannelB
- Defined in:
- lib/HDLRuby/std/channel.rb
Overview
Describes channel instance wrapper (Box) for fixing arugments.
Constant Summary
Constants included from Hmissing
Hmissing::High, Hmissing::NAMES
Instance Method Summary collapse
-
#branch(name, *args) ⇒ Object
Gets branch channel +name+.
-
#initialize(channelI, *args) ⇒ ChannelB
constructor
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: . -
#inout(name = nil) ⇒ Object
Declares the accesser port and assigned them to +name+.
-
#inout? ⇒ Boolean
Tells if the channel support inout port.
-
#input(name = nil) ⇒ Object
Declares the reader port as and assigned them to +name+.
-
#name ⇒ Object
The name of the channel instance.
-
#namespace ⇒ Object
The namespace associated with the current execution when building a channel.
-
#output(name = nil) ⇒ Object
Declares the ports for the writer and assigned them to +name+.
-
#read_port ⇒ Object
The read port if any.
-
#scope ⇒ Object
The scope the channel has been created in.
-
#write_port ⇒ Object
The write port if any.
Methods included from HchannelI
Methods included from Hmissing
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:
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
# 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 |
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.
1268 1269 1270 |
# File 'lib/HDLRuby/std/channel.rb', line 1268 def branch(name,*args) return @channelI.branch(name,*args) end |
#inout(name = nil) ⇒ Object
Declares the accesser port and assigned them to +name+.
1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
# 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? ⇒ Boolean
Tells if the channel support inout port.
1273 1274 1275 |
# File 'lib/HDLRuby/std/channel.rb', line 1273 def inout? return @channelI.inout? end |
#input(name = nil) ⇒ Object
Declares the reader port as and assigned them to +name+.
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 |
# 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 ⇒ Object
The name of the channel instance.
1237 1238 1239 |
# File 'lib/HDLRuby/std/channel.rb', line 1237 def name return @channelI.name end |
#namespace ⇒ Object
The namespace associated with the current execution when building a channel.
1248 1249 1250 |
# File 'lib/HDLRuby/std/channel.rb', line 1248 def namespace return @channelI.namespace end |
#output(name = nil) ⇒ Object
Declares the ports for the writer and assigned them to +name+.
1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
# 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 ⇒ Object
The read port if any.
1253 1254 1255 |
# File 'lib/HDLRuby/std/channel.rb', line 1253 def read_port return @read_port end |
#scope ⇒ Object
The scope the channel has been created in.
1242 1243 1244 |
# File 'lib/HDLRuby/std/channel.rb', line 1242 def scope return @channelI.scope end |
#write_port ⇒ Object
The write port if any.
1258 1259 1260 |
# File 'lib/HDLRuby/std/channel.rb', line 1258 def write_port return @write_port end |