Class: HDLRuby::High::Std::AnyRange
- Inherits:
-
Object
- Object
- HDLRuby::High::Std::AnyRange
- Includes:
- SEnumerable
- Defined in:
- lib/HDLRuby/std/sequencer.rb
Overview
Range substitute class for sequencers that supports any kind of bounds.
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#last ⇒ Object
readonly
Returns the value of attribute last.
Instance Method Summary collapse
-
#initialize(first, last) ⇒ AnyRange
constructor
A new instance of AnyRange.
-
#seach(&ruby_block) ⇒ Object
HW iteration on each element.
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(first, last) ⇒ AnyRange
Returns a new instance of AnyRange.
2250 2251 2252 2253 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2250 def initialize(first,last) @first = first @last = last end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
2248 2249 2250 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2248 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
2248 2249 2250 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2248 def last @last end |
Instance Method Details
#seach(&ruby_block) ⇒ Object
HW iteration on each element.
2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2256 def seach(&ruby_block) # Create the iteration type: selection of the larger HDLRuby type # between first and last. If one of first and last is a Numeric, # priority to the non Numeric one. if (self.last.is_a?(Numeric)) then typ = self.first.to_expr.type elsif (self.first.is_a?(Numeric)) then typ = self.last.to_expr.type else typ = self.first.type.width > self.last.type.width ? self.first.type : self.last.type end # Create the hardware iterator. this = self # size = this.size ? this.size : this.last - this.first + 1 size = this.last - this.first + 1 size = size.to_expr.as(typ) hw_enum = SEnumeratorBase.new(typ,size) do |idx| idx.as(typ) + this.first.to_expr.as(typ) end # Is there a ruby block? if(ruby_block) then # Yes, apply it. return hw_enum.seach(&ruby_block) else # No, return the resulting enumerator. return hw_enum end end |