Class: HDLRuby::High::Std::SEnumeratorBase
- Inherits:
-
SEnumerator
- Object
- SEnumerator
- HDLRuby::High::Std::SEnumeratorBase
- 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 base Enumerator that directly iterates.
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#access(idx) ⇒ Object
Generates the access at +idx+.
-
#clone ⇒ Object
Clones the enumerator.
-
#initialize(typ, size, &access) ⇒ SEnumeratorBase
constructor
Create a new sequencer for +size+ elements as +typ+ with an HW array-like accesser +access+.
-
#snext ⇒ Object
Get the next element.
-
#snext? ⇒ Boolean
Tell if there is a next element.
-
#speek ⇒ Object
View the next element without advancing the iteration.
-
#srewind ⇒ Object
Restart the iteration.
Methods inherited from SEnumerator
#+, #seach, #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_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, #ssum, #stake, #stake_while, #stally, #sto_a, #sto_h, #suniq, #szip
Constructor Details
#initialize(typ, size, &access) ⇒ SEnumeratorBase
Create a new sequencer for +size+ elements as +typ+ with an HW array-like accesser +access+.
1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1669 def initialize(typ,size,&access) # Sets the size. @size = size # Sets the type. @type = typ # Sets the accesser. @access = access # Compute the index width (default: safe 32 bits). width = @size.respond_to?(:width) ? @size.width : 32 # Create the index and the iteration result. idx = nil result = nil HDLRuby::High.cur_system.open do idx = [width].inner({ HDLRuby.uniq_name("enum_idx") => 0 }) result = typ.inner(HDLRuby.uniq_name("enum_res")) end @index = idx @result = result end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
1665 1666 1667 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1665 def index @index end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
1664 1665 1666 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1664 def result @result end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
1662 1663 1664 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1662 def size @size end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1663 1664 1665 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1663 def type @type end |
Instance Method Details
#access(idx) ⇒ Object
Generates the access at +idx+
1696 1697 1698 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1696 def access(idx) @access.call(idx) end |
#clone ⇒ Object
Clones the enumerator.
1691 1692 1693 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1691 def clone return SEnumeratorBase.new(@type,@size,&@access) end |
#snext ⇒ Object
Get the next element.
1707 1708 1709 1710 1711 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1707 def snext @result <= @access.call(@index) @index <= @index + 1 return @result end |
#snext? ⇒ Boolean
Tell if there is a next element.
1714 1715 1716 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1714 def snext? return @index < @size end |
#speek ⇒ Object
View the next element without advancing the iteration.
1701 1702 1703 1704 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1701 def speek @result <= @access.call(@index) return @result end |
#srewind ⇒ Object
Restart the iteration.
1719 1720 1721 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1719 def srewind @index <= 0 end |