Module: Origen::Limits

Included in:
Tests::Test
Defined in:
lib/origen/limits.rb,
lib/origen/limits/limit.rb,
lib/origen/limits/limit_set.rb

Defined Under Namespace

Classes: Limit, LimitSet

Constant Summary collapse

TYPES =
[:min, :typ, :max, :target]

Instance Method Summary collapse

Instance Method Details

#add_limits(set, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/origen/limits.rb', line 7

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

#limits(set = nil) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/origen/limits.rb', line 28

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