Class: HDLRuby::High::Std::SEnumerator
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::SEnumerator
- Includes:
- SEnumerable
- Defined in:
- lib/HDLRuby/std/sequencer.rb
Overview
Describes a sequencer enumerator class that allows to generate HW iteration over HW or SW objects within sequencers. This is the abstract Enumerator class.
Direct Known Subclasses
Instance Method Summary collapse
-
#+(obj) ⇒ Object
Return a new SEnumerator going on iteration over enumerable +obj+.
-
#seach(&ruby_block) ⇒ Object
Iterate on each element.
-
#seach_with_index(&ruby_block) ⇒ Object
Iterate on each element with index.
-
#seach_with_object(val, &ruby_block) ⇒ Object
Iterate on each element with arbitrary object +obj+.
-
#with_index(&ruby_block) ⇒ Object
Iterates with an index.
-
#with_object(obj) ⇒ Object
Return a new SEnumerator with an arbitrary arbitrary object +obj+.
Methods included from SEnumerable
#sall?, #sany?, #schain, #schunk, #schunk_while, #scompact, #scount, #scycle, #sdrop, #sdrop_while, #seach_cons, #seach_entry, #seach_slice, #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
Instance Method Details
#+(obj) ⇒ Object
Return a new SEnumerator going on iteration over enumerable +obj+
1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1570 def +(obj) enum = self.clone obj_enum = obj.seach res = nil this = self HDLRuby::High.cur_system.open do res = this.type.inner(HDLRuby.uniq_name("enum_plus")) end return SEnumeratorBase.new(this.type,this.size+obj_enum.size) do|idx| HDLRuby::High.top_user.hif(idx < this.size) { res <= enum.snext } HDLRuby::High.top_user.helse { res <= obj_enum.snext } res end end |
#seach(&ruby_block) ⇒ Object
Iterate on each element.
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1514 def seach(&ruby_block) # No block given, returns self. return self unless ruby_block # A block is given, iterate. this = self # Reitialize the iteration. this.srewind # Performs the iteration. SequencerT.current.swhile(self.index < self.size) do ruby_block.call(this.snext) end end |
#seach_with_index(&ruby_block) ⇒ Object
Iterate on each element with index.
1528 1529 1530 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1528 def seach_with_index(&ruby_block) return self.with_index(&ruby_block) end |
#seach_with_object(val, &ruby_block) ⇒ Object
Iterate on each element with arbitrary object +obj+.
1533 1534 1535 1536 1537 1538 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1533 def seach_with_object(val,&ruby_block) # self.seach do |elem| # ruby_block(elem,val) # end return self.with_object(val,&ruby_block) end |
#with_index(&ruby_block) ⇒ Object
Iterates with an index.
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1541 def with_index(&ruby_block) # Is there a ruby block? if ruby_block then # Yes, iterate directly. idx = self.index return self.seach do |elem| ruby_block.call(elem,idx-1) end end # No, create a new enumerator with +with_index+ as default # iteration. return SEnumeratorWrapper.new(self,:with_index) end |
#with_object(obj) ⇒ Object
Return a new SEnumerator with an arbitrary arbitrary object +obj+.
1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 |
# File 'lib/HDLRuby/std/sequencer.rb', line 1556 def with_object(obj) # Is there a ruby block? if ruby_block then # Yes, iterate directly. return self.seach do |elem| ruby_block.call(elem,val) end end # No, create a new enumerator with +with_index+ as default # iteration. return SEnumeratorWrapper.new(self,:with_object,obj) end |