Class: HDLRuby::High::Std::PriorityMonitorT

Inherits:
PriorityArbiterT show all
Defined in:
lib/HDLRuby/std/sequencer_sync.rb

Overview

Describes priority-based monitor.

Instance Method Summary collapse

Methods inherited from PriorityArbiterT

#policy

Methods inherited from ArbiterT

#call

Constructor Details

#initialize(name, tbl = nil, *sigs, &ruby_block) ⇒ PriorityMonitorT

Create a new priority-based arbiter named +name+ with priority table +tbl+ or priority algorithm +ruby_block+ for shared signals +sigs+.



263
264
265
266
267
268
269
270
271
272
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 263

def initialize(name, tbl = nil, *sigs, &ruby_block)
    super(name,tbl,*sigs,&ruby_block)
    # Declare the current selected point.
    selected_point = nil
    name = @name
    HDLRuby::High.cur_system.open do
        selected_point = [1].inner(HDLRuby.uniq_name(:"#{name}_selected"))
    end
    @selected_point = selected_point
end

Instance Method Details

#<=(val) ⇒ Object

Arbiter access code generation: 1 for acquire and 0 for release.



309
310
311
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 309

def <=(val)
    raise "For monitors, you must use the methods lock and unlock."
end

#add_pointObject

Add a point.



275
276
277
278
279
280
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 275

def add_point
    # Redefine to update the size of @selected_point.
    point = super
    @selected_point.type.instance_variable_set(:@range,(@size-1).width-1..0)
    return point
end

#lockObject

Monitor lock code generation



314
315
316
317
318
319
320
321
322
323
324
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 314

def lock
    # Fully redefine to lock until selected if acquiring.
    # Add an access point if required.
    point = self.add_point
    # Do the access.
    res = (@acquires[point] <= 1)
    selected_point = @selected_point
    # Lock until not selected.
    SequencerT.current.swhile(selected_point != point)
    return res
end

#select(point) ⇒ Object

Shared signal selection code generation.



283
284
285
286
287
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 283

def select(point)
    # Redefine to remember which point is selected.
    super(point)
    @selected_point <= point
end

#unlockObject

Monitor unlock code generation



327
328
329
330
331
332
333
334
335
# File 'lib/HDLRuby/std/sequencer_sync.rb', line 327

def unlock
    # Fully redefine to lock until selected if acquiring.
    # Add an access point if required.
    point = self.add_point
    # Do the access.
    res = (@acquires[point] <= 0)
    selected_point = @selected_point
    return res
end