Sha256: 88850ed94a3dbe349e2cfc1cd6314774ac7dc10d6f6642b5f00b565d64fc945b

Contents?: true

Size: 949 Bytes

Versions: 84

Compression:

Stored size: 949 Bytes

Contents

require_relative './limits/limit'
require_relative './limits/limit_set'
module Origen
  module Limits
    TYPES = [:min, :typ, :max, :target]

    def add_limits(set, options)
      @_limits ||= {}
      options.ids.each do |limit_type|
        unless TYPES.include? limit_type
          Origen.log.error("Limit type '#{limit_type}' not supported, choose from #{TYPES}!")
          fail
        end
      end
      if @_limits.include? set
        # Limit set already exists, modify it unless it is frozen
        unless @_limits[set].frozen?
          options.each do |limit_type, limit_expr|
            @_limits[set].send("#{limit_type}=", limit_expr)
          end
        end
      else
        # Create a default limit set
        @_limits[set] = LimitSet.new(set, self, options)
      end
    end

    def limits(set = nil)
      @_limits ||= {}
      if set.nil?
        @_limits
      else
        @_limits[set]
      end
    end
  end
end

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
origen-0.33.1 lib/origen/limits.rb
origen-0.33.0 lib/origen/limits.rb
origen-0.32.1 lib/origen/limits.rb
origen-0.32.0 lib/origen/limits.rb