Top Level Namespace

Defined Under Namespace

Modules: C99, Enumerable, Origen Classes: Array, Bignum, Fixnum, Hash, Module, Numeric, Object, OptionParser, Range, String

Constant Summary collapse

ORIGEN_COMMAND_ALIASES =
{
  'g'         => 'generate',
  'p'         => 'program',
  't'         => 'target',
  '-t'        => 'target',          # For legacy reasons
  'e'         => 'environment',
  '-e'        => 'environment',
  'mods'      => 'modifications',
  '-o'        => 'modifications',   # Legacy
  'l'         => 'lsf',
  'i'         => 'interactive',
  'c'         => 'compile',
  'pl'        => 'plugin',
  '-v'        => 'version',
  '--version' => 'version'
}

Constants included from Origen::GlobalMethods

Origen::GlobalMethods::Flow, Origen::GlobalMethods::Pattern, Origen::GlobalMethods::Resources, Origen::GlobalMethods::User

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Origen::Utility::InputCapture

#find_space, #get_text, #split_long_line

Methods included from Origen::GlobalMethods

#annotate, #c1, #c2, #debug, #encoding_search, #encodings, #get_excel_column, #get_full_class, #global_binding, #options, #pp, #render, #require_gem, #snip, #ss

Class Method Details

._with_doc_tester(options) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/origen/commands/program.rb', line 44

def self._with_doc_tester(options)
  if options[:doc]
    Origen.app.with_doc_tester do
      yield
    end
  else
    yield
  end
end

Instance Method Details

#_unmanaged_dirsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/origen/commands/rc.rb', line 21

def _unmanaged_dirs
  # List of unmanaged files and directories for an Origen workspace
  unmanaged_dirs = Origen::RevisionControl::IGNORE_DIRS
  unmanaged_dirs += config.unmanaged_dirs || []

  # If the given dirs are not full paths then prefix with Origen.root
  unmanaged_dirs.map do |d|
    if Pathname.new(d).absolute?
      d
    else
      "#{Origen.root}/#{d}"
    end
  end
end

#_unmanaged_filesObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/origen/commands/rc.rb', line 5

def _unmanaged_files
  unmanaged_files = Origen::RevisionControl::IGNORE_FILES
  unmanaged_files += config.unmanaged_files || []
  unmanaged_files += Origen.import_manager.all_symlinks || []

  # If the given files are not full paths then prefix with Origen.root, unless they
  # are wildcards
  unmanaged_files.map do |f|
    if f =~ /\*/ || Pathname.new(f).absolute?
      f
    else
      "#{Origen.root}/#{f}"
    end
  end
end

#debuggerObject



110
111
112
113
# File 'lib/origen/commands.rb', line 110

def debugger
  caller[0] =~ /.*\/(\w+\.rb):(\d+).*/
  puts "#{Regexp.last_match[1]}:#{Regexp.last_match[2]} - debugger statement ignored, run again with '-d' to enable it"
end

#evaluate_limit(limit) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/origen/specs/checkers.rb', line 69

def evaluate_limit(limit)
  return limit if limit.is_a?(Numeric) || limit.is_a?(Symbol)
  return nil if limit.nil?
  limit.gsub!("\n", ' ')
  limit.scrub!
  result = false
  if !!(limit.match(/^\d+\.\d+$/)) || !!(limit.match(/^-\d+\.\d+$/))
    result = Float(limit).round(4) rescue false # Use the same four digits of accuracy as the Spec model
  elsif !!(limit.match(/\d+\.\d+\s+\d+\.\d+/)) # workaround for multiple specs authoring bug
    Origen.log.debug "Found two numbers without an operator in the limit string '#{limit}', choosing the first..."
    first_number = limit.match(/(\d+\.\d+)\s+\d+\.\d+/).captures.first
    result = Float(first_number).round(4) rescue false # Use the same four digits of accuracy as the Spec model
  # elsif !!(limit.match(/^tbd$/i)) # unique case of TBD or To Be Determined, will convert to symbol
  #  limit = limit.downcase.to_sym
  else
    result = Integer(limit) rescue false
  end
  if result == false
    # Attempt to eval the limit because users could write a limit like "3.3 + 50.mV"
    # which would not work with the code above but should eval to a number 3.35
    begin
      result = eval(limit)
      return result.round(4) if result.is_a? Numeric
      rescue SyntaxError, NameError, TypeError
        Origen.log.debug "Limit '#{limit}' had to be rescued, storing it as a #{limit.class}"
        if limit.is_a? Symbol
          return limit
        else
          return "#{limit}"
        end
    end
  else
    return result
  end
end

#get_modeObject



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/origen/specs/checkers.rb', line 55

def get_mode
  spec_mode = nil
  if current_mode.nil?
    if self == Origen.top_level
      spec_mode = :global
    else
      spec_mode = :local
    end
  else
    spec_mode = current_mode.name
  end
  spec_mode
end

#limits_ok?Boolean

Check that min, max are not mixed with typ. If a user wants a baseline value for a spec use target as it will not be checked against pass/fail

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/origen/specs/checkers.rb', line 23

def limits_ok?
  status = true
  if (@min.exp.to_s.include? '/') || (@max.exp.to_s.include? '/')
    return status
  end
  if @min.exp.nil? ^ @max.exp.nil?
    @limit_type = :single_sided
    if @typ.exp
      # status = false
      Origen.log.debug "Spec #{@name} has a typical limit defined with either min or max.  They are mutually exclusive, use 'target' when using min or max"
    end
  elsif @min.exp && @max.exp
    @limit_type = :double_sided
    # Both min and max must be numerical to compare them
    if @min.value.is_a?(Numeric) && @max.value.is_a?(Numeric)
      # Check that min and max make sense
      if @max.value <= @min.value || @min.value >= @max.value
        status = false
        Origen.log.debug "Spec #{@name} has min (#{@min.value}) and max (#{@max.value}) reversed"
      end
      # Check that target is OK
      unless @target.nil?
        if @target.value <= @min.value || @target.value >= @max.value
          status = false
          Origen.log.debug "Spec #{@name} has a target (#{@target.value}) that is not within the min (#{@min.value}) and max #{@max.value}) values"
        end
      end
    end
  end
  status
end

#min_ruby_versionObject



7
8
9
10
11
12
13
# File 'lib/origen/ruby_version_check.rb', line 7

def min_ruby_version
  if Origen.os.windows?
    '1.9.3'
  else
    '2.1.0'
  end
end

#name_audit(name) ⇒ Object

rubocop:disable Style/RescueModifier:



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/origen/specs/checkers.rb', line 2

def name_audit(name)
  return name if name.nil?
  return nil unless name.is_a?(Symbol) || name.is_a?(String)
  if name == :inspect
    Origen.log.debug ':inspect is a reserved spec name'
    return nil
  end
  if name.match(/^\d/)
    Origen.log.debug "Spec #{name} starts with a number"
    return nil
  end
  if name.match(/\s+/)
    Origen.log.debug "Spec #{name} contains white space, removing it"
    name.delete!(/\s+/)
  end
  name.is_a?(String) ? name.downcase.to_sym : name
end

#require_type_or_id(options) ⇒ Object



5
6
7
8
9
10
# File 'lib/origen/commands/lsf.rb', line 5

def require_type_or_id(options)
  unless options[:id] || options[:type]
    puts 'You must supply a job type or ID'
    exit 1
  end
end

#ruby_acceptable_to_run?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/origen/ruby_version_check.rb', line 3

def ruby_acceptable_to_run?
  RUBY_VERSION >= min_ruby_version
end

#workspace_dirsObject



36
37
38
# File 'lib/origen/commands/rc.rb', line 36

def workspace_dirs
  "#{Origen.root} " + Origen.app.config.external_app_dirs.join(' ')
end