Class: OrigenTesters::Charz::SearchRoutine

Inherits:
Routine
  • Object
show all
Defined in:
lib/origen_testers/charz/routines/search_routine.rb

Overview

a 1D search routine

Instance Attribute Summary collapse

Attributes inherited from Routine

#id, #name

Instance Method Summary collapse

Methods inherited from Routine

#method_missing

Constructor Details

#initialize(id, options = {}, &block) ⇒ SearchRoutine

Runs the same initialization as Routine performs some rudimentary quality checks, which can be disabled by setting @quality_check = false



17
18
19
20
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 17

def initialize(id, options = {}, &block)
  super
  attrs_ok?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OrigenTesters::Charz::Routine

Instance Attribute Details

#resNumeric

Returns search resolution.

Returns:

  • (Numeric)

    search resolution



13
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 13

attr_accessor :start, :stop, :res, :spec

#specNumeric

Returns spec parameter to be searched.

Returns:

  • (Numeric)

    spec parameter to be searched



13
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 13

attr_accessor :start, :stop, :res, :spec

#startNumeric

Returns search start value.

Returns:

  • (Numeric)

    search start value



13
14
15
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 13

def start
  @start
end

#stopNumeric

Returns search stop value.

Returns:

  • (Numeric)

    search stop value



13
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 13

attr_accessor :start, :stop, :res, :spec

Instance Method Details

#attrs_ok?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/origen_testers/charz/routines/search_routine.rb', line 22

def attrs_ok?
  return if @quality_check == false

  @required_attrs ||= [:start, :stop, :res, :spec]
  attrs = @required_attrs.map { |attr| instance_variable_get("@#{attr}") }
  if attrs.compact.size != @required_attrs.size
    Origen.log.error "SearchRoutine #{@id}: unspecified attributes, each of #{@required_attrs} must have a value"
    fail
  end

  return if @attr_value_check == false
  if [@start, @stop, @res].all? { |attr| attr.is_a? Numeric }
    unless @res <= (@start - @stop).abs
      Origen.log.error "SearchRoutine #{@id}: Search resolution (#{@res}) is larger than the search range: #{(@start - @stop).abs}"
      fail
    end
  end
end