Sha256: 3bb82d20538573d2a3a8cb43dad4ff3d9a8740749ba9f1f286d7036d8619d7cd

Contents?: true

Size: 1.04 KB

Versions: 65

Compression:

Stored size: 1.04 KB

Contents

module Origen
  module Registers
    require 'delegate'

    # Thin wrapper around register objects to modify bit number interpretation
    #
    # This is provided as a convenience to make user code more readable
    class Msb0Delegator < ::Delegator
      def initialize(reg_object, bits)
        @reg_object = reg_object
        @bits = bits
      end

      def __getobj__
        @reg_object
      end

      def __object__
        @reg_object
      end

      def __setobj__(obj)
        @reg_object = obj
      end

      def inspect(options = {})
        options[:with_bit_order] = :msb0
        @reg_object.inspect(options)
      end

      def method_missing(method, *args, &block)
        if args.last.is_a?(Hash)
          args.last[:with_bit_order] = :msb0
        else
          args << { with_bit_order: :msb0 }
        end
        @reg_object.method_missing(method, *args, &block)
      end

      def bit(*args)
        @reg_object.bit(args, with_bit_order: :msb0)
      end
      alias_method :bits, :bit
      alias_method :[], :bit
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
origen-0.42.1 lib/origen/registers/msb0_delegator.rb
origen-0.42.0 lib/origen/registers/msb0_delegator.rb
origen-0.41.2 lib/origen/registers/msb0_delegator.rb
origen-0.41.1 lib/origen/registers/msb0_delegator.rb
origen-0.41.0 lib/origen/registers/msb0_delegator.rb