Class: HDLRuby::High::Std::SEnumeratorSub

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

Overview

Describes a sequencer enumerator class that allows to generate HW iterations over HW or SW objects within sequencers. This is the sub Enumerator over an other one for interating inside the enumerator. This is specific the HDLRuby for avoiding creation of array which are expensive in HW. Used by seach_next for example. Will change the index position of the initial iterator without reseting it.

Instance Method Summary collapse

Methods inherited from SEnumerator

#+, #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(enum, rng, *args) ⇒ SEnumeratorSub

Create a new SEnumerator wrapper over +enum+ among +rng+ indexes.



1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
# File 'lib/HDLRuby/std/sequencer.rb', line 1968

def initialize(enum,rng,*args)
    @enumerator = enum.seach
    @range = rng.first..rng.last
    # Declare the sub index.
    idx = nil
    siz = @range.last-@range.first+1
    HDLRuby::High.cur_system.open do
        idx = [siz.width].inner({
            HDLRuby.uniq_name("sub_idx") => 0 })
    end
    @index = idx
    @size = siz
end

Instance Method Details

#access(idx) ⇒ Object



1999
2000
2001
# File 'lib/HDLRuby/std/sequencer.rb', line 1999

def access(idx)
    return @enumerator.access(@index+@range.first)
end

#cloneObject

Clones the enumerator.



2025
2026
2027
# File 'lib/HDLRuby/std/sequencer.rb', line 2025

def clone
    return SEnumeratorSub.new(@enumerator,@range)
end

#indexObject



1995
1996
1997
# File 'lib/HDLRuby/std/sequencer.rb', line 1995

def index
    return @index
end

#resultObject



1991
1992
1993
# File 'lib/HDLRuby/std/sequencer.rb', line 1991

def result
    return @enumerator.result
end

#seach(&ruby_block) ⇒ Object

Iterate over each element.



2030
2031
2032
2033
2034
2035
2036
2037
2038
# File 'lib/HDLRuby/std/sequencer.rb', line 2030

def seach(&ruby_block)
    # No block given, returns self.
    return self unless ruby_block
    # A block is given, iterate.
    this = self
    SequencerT.current.swhile(this.snext?) do
        ruby_block.call(this.snext)
    end
end

#sizeObject

The directly delegate methods.



1983
1984
1985
# File 'lib/HDLRuby/std/sequencer.rb', line 1983

def size
    return @size
end

#snextObject



2007
2008
2009
2010
# File 'lib/HDLRuby/std/sequencer.rb', line 2007

def snext
    @index <= @index + 1
    return @enumerator.snext
end

#snext!(val) ⇒ Object



2016
2017
2018
# File 'lib/HDLRuby/std/sequencer.rb', line 2016

def snext!(val)
    return @enumerator.snext!(val)
end

#snext?Boolean

Returns:

  • (Boolean)


2012
2013
2014
# File 'lib/HDLRuby/std/sequencer.rb', line 2012

def snext?
    return @index < self.size
end

#speekObject



2003
2004
2005
# File 'lib/HDLRuby/std/sequencer.rb', line 2003

def speek
    return @enumerator.speek
end

#srewindObject



2020
2021
2022
# File 'lib/HDLRuby/std/sequencer.rb', line 2020

def srewind
    @index <= 0
end

#typeObject



1987
1988
1989
# File 'lib/HDLRuby/std/sequencer.rb', line 1987

def type
    return @enumerator.type
end