Class: HDLRuby::High::Std::SequencerChannel

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

Overview

Creates an abstract channel over an accessing method. NOTE: Works like an enumerator, but can be passed as generic arguments and generates a different enumerator per sequencer.

  • +typ+ is the data type of the elements.
  • +size+ is the number of elements.
  • +access+ is the block implementing the access method.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SEnumerator

#+, #seach, #seach_range, #seach_with_index, #seach_with_object, #with_index, #with_object

Methods included from SEnumerable

#sall?, #sany?, #schain, #schunk, #schunk_while, #scompact, #scount, #scycle, #sdrop, #sdrop_while, #seach_cons, #seach_entry, #seach_nexts, #seach_range, #seach_slice, #seach_with_index, #seach_with_object, #sfind, #sfind_index, #sfirst, #sflat_map, #sgrep, #sgrep_v, #sgroup_by, #sinclude?, #sinject, #slazy, #smap, #smax, #smax_by, #smin, #smin_by, #sminmax, #sminmax_by, #snone?, #sone?, #spartition, #sreject, #sreverse_each, #sselect, #sslice_after, #sslice_before, #sslice_when, #ssort, #ssort_by, #ssort_merge, #ssum, #stake, #stake_while, #stally, #sto_a, #sto_h, #suniq, #szip

Constructor Details

#initialize(typ, size, &access) ⇒ SequencerChannel

Create a new channel for +size+ elements of type +type+ with an JW array-like accesser +access+.



26
27
28
29
30
31
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 26

def initialize(typ,size,&access)
    @type = typ
    @size = size
    @access = access
    @enums  = {} # The enumerator per sequencer.
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



64
65
66
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 64

def size
  @size
end

#typeObject (readonly)

The access to the already defined elements.



63
64
65
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 63

def type
  @type
end

Instance Method Details

#[](addr) ⇒ Object

The array read accesses.



53
54
55
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 53

def [](addr)
    return @access.call(addr)
end

#[]=(addr, val) ⇒ Object

The array write access.



58
59
60
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 58

def []=(addr,val)
    return @access.call(addr,val)
end

#cloneObject

Clones is ambigous here, so deactivated.



48
49
50
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 48

def clone
    raise "clone not supported for channels."
end

#senumeratorObject

Get the enumerator for current sequencer. If does not exist create a new one.



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/HDLRuby/std/sequencer_channel.rb', line 35

def senumerator
    unless SequencerT.current then
        raise "Cannot get a channel enumerator from outside a sequencer."
    end
    enum = @enums[SequencerT.current]
    unless enum then
        enum = @enums[SequencerT.current] =
            SEnumeratorBase.new(@type,@size,&@access)
    end
    return enum
end