lib/origen/registers/reg.rb
# Returns each named bit collection contained in the register,
Returns each named bit collection contained in the register.
Returns each named bit collection contained in the register .
def named_bits(options = {})
        options = {
          include_spacers: false
        }.merge(options)
        result = []
        def changed_bits(options = {})
          temp = named_bits.select { |name, bits| bits.data != bits.reset_val }
          temp.each do |r|
            Origen.log.info "\t\t#{self.name}.#{r[0]} : #{r[1].value.to_hex}".bold.blue
          end
          Origen.log.info '  '
        end
        split_bits = false
        @lookup.each { |_k, v| split_bits = true if v.is_a? Array }
        if split_bits == false
          current_pos = size
          @lookup.sort_by { |_name, details| -details[:pos] }.each do |name, details|
            pos = details[:bits] + details[:pos]
            if options[:include_spacers] && (pos != current_pos)
              collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)
              unless collection.size == 0
                if block_given?
                  yield nil, collection
                else
                  result << [nil, collection]
                end
              end
            end
            collection = BitCollection.new(self, name)
            details[:bits].times do |i|
              collection << @bits[details[:pos] + i]
            end
            unless collection.size == 0
              if block_given?
                yield name, collection
              else
                result << [name, collection]
              end
            end
            current_pos = details[:pos]
          end
          if options[:include_spacers] && (current_pos != 0)
            collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)
            unless collection.size == 0
              if block_given?
                yield nil, collection
              else
                result << [nil, collection]
              end
            end
          end
        elsif split_bits == true 
          @lookup_splits = []
          @lookup.each do |k, v|
            tempbit = {}
            bitcounter = {}
            if v.is_a? Hash
              tempbit[k] = v
              @lookup_splits << tempbit.clone
            elsif v.is_a? Array
              v.each_with_index do |bitdetail, _i|
                if bitcounter.key?(k)
                  bitcounter[k] = bitcounter[k] + bitdetail[:bits]
                else
                  bitcounter[k] = bitdetail[:bits]
                end
                tempbit[k] = bitdetail
                @lookup_splits << tempbit.clone
              end
            end
            if v.is_a? Array
              @lookup_splits.each_with_index do |_e, q|
                groupname = @lookup_splits[q].to_a[0][0]
                if groupname == k
                  @lookup_splits[q][groupname][:bitgrouppos] = bitcounter[groupname] if groupname == k
                  bitcounter[groupname] = bitcounter[groupname] - @lookup_splits[q][groupname][:bits]
                end
              end
            end
          end
          @lookup_splits = @lookup_splits.sort do |a, b|
            b.to_a[0][1][:pos] <=> a.to_a[0][1][:pos]
          end
          current_pos = size
          countbits = {} 
          @master = {}
          bitgroup = {}
          bitinfo = {}
          info = {}
          @lookup_splits.each_with_index do |hash, _i|
            name = hash.to_a[0][0]
            details = hash.to_a[0][1]
            bitcounter = hash.to_a[0][1][:bitgrouppos]
            pos = details[:bits] + details[:pos]
            if options[:include_spacers] && (pos != current_pos)
              collection = BitCollection.dummy(self, nil, size: current_pos - pos, pos: pos)
              unless collection.size == 0
                if block_given?
                  yield nil, collection, bitcounter
                else
                  result << [nil, collection, bitcounter]
                end
              end
            end
            collection = BitCollection.new(self, name)
            details[:bits].times do |i|
              collection << @bits[details[:pos] + i]
            end
            unless collection.size == 0
              if block_given?
                yield name, collection, bitcounter
              else
                result << [name, collection, bitcounter]
              end
            end
            current_pos = details[:pos]
          end
          if options[:include_spacers] && current_pos != 0
            collection = BitCollection.dummy(self, nil, size: current_pos, pos: 0)
            unless collection.size == 0
              if block_given?
                yield nil, collection, bitcounter
              else
                result << [nil, collection, bitcounter]
              end
            end
          end
        end
        unless block_given?
          result
        end
      end
def named_bits ( options = { } ) options = { include_spacers : false } . merge ( options ) result = [ ] def changed_bits ( options = { } ) temp = named_bits . select { | name , bits | bits . data != bits . reset_val } temp . each do | r | Origen . log . info "\t\t#{self.name}.#{r[0]} : #{r[1].value.to_hex}" . bold . blue end Origen . log . info '  ' end split_bits = false @lookup . each { | _k , v | split_bits = true if v . is_a? Array } if split_bits == false current_pos = size @lookup . sort_by { | _name , details | - details [ :pos ] } . each do | name , details | pos = details [ :bits ] + details [ :pos ] if options [ :include_spacers ] && ( pos != current_pos ) collection = BitCollection . dummy ( self , nil , size : current_pos - pos , pos : pos ) unless collection . size == 0 if block_given? yield nil , collection else result << [ nil , collection ] end end end collection = BitCollection . new ( self , name ) details [ :bits ] . times do | i | collection << @bits [ details [ :pos ] + i ] end unless collection . size == 0 if block_given? yield name , collection else result << [ name , collection ] end end current_pos = details [ :pos ] end if options [ :include_spacers ] && ( current_pos != 0 ) collection = BitCollection . dummy ( self , nil , size : current_pos , pos : 0 ) unless collection . size == 0 if block_given? yield nil , collection else result << [ nil , collection ] end end end elsif split_bits == true @lookup_splits = [ ] @lookup . each do | k , v | tempbit = { } bitcounter = { } if v . is_a? Hash tempbit [ k ] = v @lookup_splits << tempbit . clone elsif v . is_a? Array v . each_with_index do | bitdetail , _i | if bitcounter . key? ( k ) bitcounter [ k ] = bitcounter [ k ] + bitdetail [ :bits ] else bitcounter [ k ] = bitdetail [ :bits ] end tempbit [ k ] = bitdetail @lookup_splits << tempbit . clone end end if v . is_a? Array @lookup_splits . each_with_index do | _e , q | groupname = @lookup_splits [ q ] . to_a [ 0 ] [ 0 ] if groupname == k @lookup_splits [ q ] [ groupname ] [ :bitgrouppos ] = bitcounter [ groupname ] if groupname == k bitcounter [ groupname ] = bitcounter [ groupname ] - @lookup_splits [ q ] [ groupname ] [ :bits ] end end end end @lookup_splits = @lookup_splits . sort do | a , b | b . to_a [ 0 ] [ 1 ] [ :pos ] <=> a . to_a [ 0 ] [ 1 ] [ :pos ] end current_pos = size countbits = { } @master = { } bitgroup = { } bitinfo = { } info = { } @lookup_splits . each_with_index do | hash , _i | name = hash . to_a [ 0 ] [ 0 ] details = hash . to_a [ 0 ] [ 1 ] bitcounter = hash . to_a [ 0 ] [ 1 ] [ :bitgrouppos ] pos = details [ :bits ] + details [ :pos ] if options [ :include_spacers ] && ( pos != current_pos ) collection = BitCollection . dummy ( self , nil , size : current_pos - pos , pos : pos ) unless collection . size == 0 if block_given? yield nil , collection , bitcounter else result << [ nil , collection , bitcounter ] end end end collection = BitCollection . new ( self , name ) details [ :bits ] . times do | i | collection << @bits [ details [ :pos ] + i ] end unless collection . size == 0 if block_given? yield name , collection , bitcounter else result << [ name , collection , bitcounter ] end end current_pos = details [ :pos ] end if options [ :include_spacers ] && current_pos != 0 collection = BitCollection . dummy ( self , nil , size : current_pos , pos : 0 ) unless collection . size == 0 if block_given? yield nil , collection , bitcounter else result << [ nil , collection , bitcounter ] end end end end unless block_given? result end end
Returns each named bit collection contained in the register,
Returns each named bit collection contained in the register
# Shows the bits that have changed from the reset value of the register/bits. # Currently logs it to the console window using Origen logger. # test if @lookup has any values stored as an array # if so it means there is a split group of bits # process that differently to a single bit or continuous range of bits # which are typically stored in a hash # Sort by position # if there are split bits, need to convert all register bit values to array elements to allow sorting # if the register has bits split up across it, then store the bits in order of decreasing reg position # but first, stuff all the bits in a simple array, as single bits, or ranges of bits # then this is already a single bit or a continuous range so just stuff it into the array # if the bitgroup is split, then decompose into single bits and continuous ranges # Now sort the array in descending order # Does adding the bitgrouppos need to happen after the sort ? # if countbits.method == nil
options
<not_specific>