Class: HDLRuby::High::Std::ChannelPortR
- Inherits:
-
ChannelPort
- Object
- ChannelPort
- HDLRuby::High::Std::ChannelPortR
- Defined in:
- lib/HDLRuby/std/channel.rb
Overview
Describes a read port to a channel.
Instance Attribute Summary
Attributes inherited from ChannelPort
Instance Method Summary collapse
-
#initialize(namespace, reader_proc, reseter_proc = nil) ⇒ ChannelPortR
constructor
Creates a new channel reader running in +namespace+ and reading using +reader_proc+ and reseting using +reseter_proc+.
-
#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.
Methods inherited from ChannelPort
Constructor Details
#initialize(namespace, reader_proc, reseter_proc = nil) ⇒ ChannelPortR
Creates a new channel reader running in +namespace+ and reading using +reader_proc+ and reseting using +reseter_proc+.
114 115 116 117 118 119 120 121 122 |
# File 'lib/HDLRuby/std/channel.rb', line 114 def initialize(namespace,reader_proc,reseter_proc = nil) unless namespace.is_a?(Namespace) raise "Invalid class for a namespace: #{namespace.class}" end @namespace = namespace @reader_proc = reader_proc.to_proc @rester_proc = reseter_proc ? reseter_proc.to_proc : proc {} @scope = HDLRuby::High.cur_scope end |
Instance Method Details
#read(*args, &ruby_block) ⇒ Object
Performs a read on the channel using +args+ and +ruby_block+ as arguments.
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/HDLRuby/std/channel.rb', line 126 def read(*args,&ruby_block) # Gain access to the reader as local variable. reader_proc = @reader_proc # Execute the code generating the accesser in context. HDLRuby::High.space_push(@namespace) HDLRuby::High.cur_block.open do instance_exec(ruby_block,*args,&reader_proc) end HDLRuby::High.space_pop end |
#reset(*args, &ruby_block) ⇒ Object
Performs a reset on the channel using +args+ and +ruby_block+ as arguments.
139 140 141 142 143 144 145 146 147 148 |
# File 'lib/HDLRuby/std/channel.rb', line 139 def reset(*args,&ruby_block) # Gain access to the accesser as local variable. reseter_proc = @reseter_proc # Execute the code generating the accesser in context. HDLRuby::High.space_push(@namespace) HDLRuby::High.cur_block.open do instance_exec(ruby_block,*args,&reseter_proc) end HDLRuby::High.space_pop end |