Module: Enumerable

Included in:
HDLRuby::High::HRef, VerilogTools::AST
Defined in:
lib/HDLRuby/std/sequencer.rb

Instance Method Summary collapse

Instance Method Details

#seach(&ruby_block) ⇒ Object

HW iteration on each element.



2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
# File 'lib/HDLRuby/std/sequencer.rb', line 2176

def seach(&ruby_block)
    # Convert the enumrable to an array for easier processing.
    ar = self.to_a
    return if ar.empty? # The array is empty, nothing to do.
    # Compute the type of the elements.
    typ = ar[0].respond_to?(:type) ? ar[0].type : signed[32]
    # Create the hardware iterator.
    hw_enum = SEnumeratorBase.new(typ,ar.size) do |idx|
        HDLRuby::High.top_user.mux(idx,*ar)
    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