Class: HDLRuby::High::Std::ChannelPortObject
- Inherits:
-
ChannelPort
- Object
- ChannelPort
- HDLRuby::High::Std::ChannelPortObject
- Defined in:
- lib/HDLRuby/std/channel.rb
Overview
Wrapper to make an object run like a channel port.
Instance Attribute Summary
Attributes inherited from ChannelPort
Instance Method Summary collapse
-
#initialize(obj) ⇒ ChannelPortObject
constructor
Create a new object wrapper for +obj+.
-
#read(*args, &ruby_block) ⇒ Object
Port read with arguments +args+ executing +ruby_block+ in case of success.
-
#write(*args, &ruby_block) ⇒ Object
Port write with argumnet +Args+ executing +ruby_block+ in case of success.
Methods inherited from ChannelPort
Constructor Details
#initialize(obj) ⇒ ChannelPortObject
Create a new object wrapper for +obj+.
1327 1328 1329 1330 1331 |
# File 'lib/HDLRuby/std/channel.rb', line 1327 def initialize(obj) @obj = obj @scope = HDLRuby::High.cur_scope end |
Instance Method Details
#read(*args, &ruby_block) ⇒ Object
Port read with arguments +args+ executing +ruby_block+ in case of success.
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 |
# File 'lib/HDLRuby/std/channel.rb', line 1335 def read(*args,&ruby_block) # Get the target from the arguments. target = args.pop # Is there any argument left? unless (args.empty?) then # There are arguments left, perform an array access. target <= @obj[*args] else # There are no argument left, perform a direct access. target <= @obj end # Execute the ruby_block if any. ruby_block.call if ruby_block end |
#write(*args, &ruby_block) ⇒ Object
Port write with argumnet +Args+ executing +ruby_block+ in case of success.
1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 |
# File 'lib/HDLRuby/std/channel.rb', line 1352 def write(*args,&ruby_block) # Get the value to write from the arguments. value = args.pop # Is there any argument left? unless (args.empty?) then # There are arguments left, perform an array access. @obj[*args] <= value else # There are no argument left, perform a direct access. @obj <= value end # Execute the ruby_block if any. ruby_block.call if ruby_block end |