Class: HDLRuby::High::Std::ChannelPortW
- Inherits:
-
ChannelPort
- Object
- ChannelPort
- HDLRuby::High::Std::ChannelPortW
- Defined in:
- lib/HDLRuby/std/channel.rb
Overview
Describes a writer port to a channel.
Instance Attribute Summary
Attributes inherited from ChannelPort
Instance Method Summary collapse
-
#initialize(namespace, writer_proc, reseter_proc = nil) ⇒ ChannelPortW
constructor
Creates a new channel writer running in +namespace+ and writing using +writer_proc+ and reseting using +reseter_proc+.
-
#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(namespace, writer_proc, reseter_proc = nil) ⇒ ChannelPortW
Creates a new channel writer running in +namespace+ and writing using +writer_proc+ and reseting using +reseter_proc+.
159 160 161 162 163 164 165 166 167 |
# File 'lib/HDLRuby/std/channel.rb', line 159 def initialize(namespace,writer_proc,reseter_proc = nil) unless namespace.is_a?(Namespace) raise "Invalid class for a namespace: #{namespace.class}" end @namespace = namespace @writer_proc = writer_proc.to_proc @reseter_proc = reseter_proc ? reseter_proc.to_proc : proc {} @scope = HDLRuby::High.cur_scope end |
Instance Method Details
#reset(*args, &ruby_block) ⇒ Object
Performs a reset on the channel using +args+ and +ruby_block+ as arguments.
184 185 186 187 188 189 190 191 192 193 |
# File 'lib/HDLRuby/std/channel.rb', line 184 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 |
#write(*args, &ruby_block) ⇒ Object
Performs a write on the channel using +args+ and +ruby_block+ as arguments.
171 172 173 174 175 176 177 178 179 180 |
# File 'lib/HDLRuby/std/channel.rb', line 171 def write(*args,&ruby_block) # Gain access to the writer as local variable. writer_proc = @writer_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,&writer_proc) end HDLRuby::High.space_pop end |