Class: HDLRuby::High::Std::ChannelPortB
- Inherits:
-
ChannelPort
- Object
- ChannelPort
- HDLRuby::High::Std::ChannelPortB
- 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 inherited from ChannelPort
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:
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/HDLRuby/std/channel.rb', line 266 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.
288 289 290 291 292 293 294 295 296 |
# File 'lib/HDLRuby/std/channel.rb', line 288 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.
312 313 314 |
# File 'lib/HDLRuby/std/channel.rb', line 312 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.
300 301 302 303 304 305 306 307 308 |
# File 'lib/HDLRuby/std/channel.rb', line 300 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 |