Class: HDLRuby::High::Std::ChannelPortB
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::ChannelPortB
- Includes:
- ChannelPortWrapping
- Defined in:
- lib/HDLRuby/std/channel.rb
Overview
Describes port wrapper (Box) for fixing arugments.
Instance Method Summary collapse
-
#initialize(port, *args) ⇒ ChannelPortB
constructor
Creates a new channel box over channel port +port+ fixing +args+ as arguments.
-
#read(*args, &ruby_block) ⇒ Object
Performs a read on the channel using +args+ and +ruby_block+ as arguments.
-
#reset(*args, &ruby_block) ⇒ Object
Performs a reset on the channel using +args+ and +ruby_block+ as arguments.
-
#write(*args, &ruby_block) ⇒ Object
Performs a write on the channel using +args+ and +ruby_block+ as arguments.
Methods included from ChannelPortWrapping
Constructor Details
#initialize(port, *args) ⇒ ChannelPortB
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:
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/HDLRuby/std/channel.rb', line 258 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 end |
Instance Method Details
#read(*args, &ruby_block) ⇒ Object
Performs a read on the channel using +args+ and +ruby_block+ as arguments.
280 281 282 283 284 285 286 287 288 |
# File 'lib/HDLRuby/std/channel.rb', line 280 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) ⇒ Object
Performs a reset on the channel using +args+ and +ruby_block+ as arguments.
304 305 306 |
# File 'lib/HDLRuby/std/channel.rb', line 304 def reset(*args,&ruby_block) @port.reset(*@args,*args) end |
#write(*args, &ruby_block) ⇒ Object
Performs a write on the channel using +args+ and +ruby_block+ as arguments.
292 293 294 295 296 297 298 299 300 |
# File 'lib/HDLRuby/std/channel.rb', line 292 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 |