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.
2301 2302 2303 2304 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2301 def initialize(first,last) @first = first @last = last end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
2299 2300 2301 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2299 def first @first end |
#last ⇒ Object (readonly)
Returns the value of attribute last.
2299 2300 2301 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2299 def last @last end |
Instance Method Details
#seach(&ruby_block) ⇒ Object
HW iteration on each element.
2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 |
# File 'lib/HDLRuby/std/sequencer.rb', line 2307 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 |