Class: HDLRuby::High::Std::TaskPortSA

Inherits:
Object
  • Object
show all
Defined in:
lib/HDLRuby/std/task.rb

Overview

Describes an runner and finisher port to a task.

Instance Method Summary collapse

Constructor Details

#initialize(namespace, runner_proc, finisher_proc, reseter_proc = nil) ⇒ TaskPortSA

Creates a new task accesser running in +namespace+ and reading using +runner_proc+, writing using +finisher_proc+, and reseting using +reseter_proc+.



191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/HDLRuby/std/task.rb', line 191

def initialize(namespace,runner_proc,finisher_proc,reseter_proc = nil)
    unless namespace.is_a?(Namespace)
        raise "Invalid class for a namespace: #{namespace.class}"
    end
    @namespace = namespace
    unless runner_proc || finisher_proc then
        raise "An accesser must have at least a reading or a writing procedure."
    end
    @runner_proc  = runner_proc ? runner_proc.to_proc : proc { }
    @finisher_proc  = finisher_proc ? finisher_proc.to_proc : proc { }
    @reseter_proc = reseter_proc ? reseter_proc.to_proc : proc {}
end

Instance Method Details

#finish(*args, &ruby_block) ⇒ Object

Performs a finish on the task using +args+ and +ruby_block+ as arguments.



219
220
221
222
223
224
225
226
227
228
# File 'lib/HDLRuby/std/task.rb', line 219

def finish(*args,&ruby_block)
    # Gain access to the accesser as local variable.
    finisher_proc = @finisher_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,&finisher_proc)
    end
    HDLRuby::High.space_pop
end

#reset(*args, &ruby_block) ⇒ Object

Performs a reset on the task using +args+ and +ruby_block+ as arguments.



232
233
234
235
236
237
238
239
240
241
# File 'lib/HDLRuby/std/task.rb', line 232

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

#run(*args, &ruby_block) ⇒ Object

Performs a run on the task using +args+ and +ruby_block+ as arguments.



206
207
208
209
210
211
212
213
214
215
# File 'lib/HDLRuby/std/task.rb', line 206

def run(*args,&ruby_block)
    # Gain access to the accesser as local variable.
    runner_proc = @runner_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,&runner_proc)
    end
    HDLRuby::High.space_pop
end