Class: Origen::Tester::J750::Parser::FlowLine

Inherits:
Object
  • Object
show all
Defined in:
lib/origen/tester/j750/parser/flow_line.rb

Constant Summary

TYPES =
%w(
Test characterize defaults enable-flow-word disable-flow-word error-print goto
goto-on-all-done goto-on-all-lastfail goto-on-all-lastfaildoall logprint modify
nop print reset set-device set-device-new set-error-bin set-retest-bin skip
stop assign-integer create-integer delete-integer create-site-var assign-site-var
flag-clear flag-clear-all flag-false flag-false-all flag-true flag-true-all
state-clear-all state-false-all state-true-all
ATTRS =
%w(
label enable job part env opcode parameter
tname tnum bin_pass bin_fail sort_pass sort_fail result flag_pass
flag_fail state group_specifier group_sense group_condition group_name
device_sense device_condition device_name debug_assume debug_sites
comment
ALIASES =
{
  bin:         :bin_fail,
  softbin:     :sort_fail,
  soft_bin:    :sort_fail,
  name:        :tname,
  number:      :tnum,
  test_number: :tnum,
  test_num:    :tnum,
  type:        :opcode
}

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FlowLine) initialize(line, options = {})

Returns a new instance of FlowLine



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 56

def initialize(line, options = {})
  @parser = options[:parser]
  @flow = options[:flow]
  @line = line
  parse
  if valid?
    ATTRS.each_with_index do |attr, i|
      instance_variable_set("@#{attr}", components[i + 1])
    end
  end
end

Instance Attribute Details

- (Object) flow

Returns the value of attribute flow



6
7
8
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 6

def flow
  @flow
end

- (Object) line

Returns the value of attribute line



6
7
8
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 6

def line
  @line
end

- (Object) parser

Returns the value of attribute parser



6
7
8
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 6

def parser
  @parser
end

Class Method Details

+ (Object) extract_test(line)

Returns the test instance called by the given line or nil



49
50
51
52
53
54
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 49

def self.extract_test(line)
  l = new(line)
  if l.valid? && l.test?
    l.test_instance_name
  end
end

Instance Method Details

- (Object) components



92
93
94
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 92

def components
  @components ||= []
end

- (Object) conditions

Returns a string summarizing any conditions (enable words, jobs, etc.) that gate the execution of this line



188
189
190
191
192
193
194
195
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 188

def conditions
  c = []
  c << "Enable: #{enable}" unless enable.empty?
  c << "Job: #{job}" unless job.empty?
  c << "Part: #{part}" unless part.empty?
  c << "Env: #{env}" unless env.empty?
  c.join('; ')
end

- (Boolean) conditions_met?(conditions, values)

Returns:

  • (Boolean)


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 123

def conditions_met?(conditions, values)
  if conditions.empty?
    true
  else
    values = [values].flatten
    conditions = conditions.split(',').map(&:strip)
    not_conditions = conditions.select { |c| c =~ /^!/ }
    conditions = conditions - not_conditions
    # Make sure all -ve conditions are not met
    if not_conditions.all? do |c|
         c =~ /^!(.*)/
         c = Regexp.last_match[1]
         !values.include?(c)
       end
      # And then any +ve conditions
      if conditions.empty?
        true
      else
        values.any? { |v| conditions.include?(v) }
      end
    else
      false
    end
  end
end

- (Object) description



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 72

def description
  from_instance = test_instance ? test_instance.description : ''
  from_flow = parser.descriptions.flow_line(name: test_instance_name, flow: flow.file)
  if !from_instance.empty? && !from_flow.empty?
    [from_instance, "\n", from_flow].flatten
  elsif from_instance.empty?
    from_flow
  else
    from_instance
  end
end

- (Boolean) enable_conditions_met?(context)

Returns:

  • (Boolean)


107
108
109
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 107

def enable_conditions_met?(context)
  conditions_met?(enable, context[:enable])
end

- (Boolean) env_conditions_met?(context)

Returns:

  • (Boolean)


119
120
121
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 119

def env_conditions_met?(context)
  conditions_met?(env, context[:env])
end

- (Boolean) executes_under_context?(context)

Returns:

  • (Boolean)


100
101
102
103
104
105
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 100

def executes_under_context?(context)
  enable_conditions_met?(context) &&
    job_conditions_met?(context) &&
    part_conditions_met?(context) &&
    env_conditions_met?(context)
end

- (Object) inspect

:nodoc:



68
69
70
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 68

def inspect  # :nodoc:
  "<FlowLine: #{type}, Parameter: #{parameter}>"
end

- (Boolean) job_conditions_met?(context)

Returns:

  • (Boolean)


111
112
113
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 111

def job_conditions_met?(context)
  conditions_met?(job, context[:job])
end

- (Object) parse



84
85
86
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 84

def parse
  @components = @line.split("\t") unless @line.strip.empty?
end

- (Boolean) part_conditions_met?(context)

Returns:

  • (Boolean)


115
116
117
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 115

def part_conditions_met?(context)
  conditions_met?(part, context[:part])
end

- (Object) patterns(options = {}) Also known as: pattern

Returns an array of patterns used by the given test, if there are none an empty array is returned. Optionally supply patterns to exclude if you want to ignore common subroutine patterns for example.



171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 171

def patterns(options = {})
  i = test_instance
  if i
    pats = i.patterns
    if options[:ignore] && pats
      pats.reject { |p| [options[:ignore]].flatten.include?(p) }
    else
      []
    end
  else
    []
  end
end

- (Boolean) test?

Returns:

  • (Boolean)


96
97
98
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 96

def test?
  %w(Test characterize).include? opcode
end

- (Object) test_instance Also known as: instance



154
155
156
157
158
159
160
161
162
163
164
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 154

def test_instance
  instances = parser.test_instances.where(name: parameter, exact: true)
  if instances.size > 1
    puts "Warning multiple instances of #{name} found, using the first one"
  end
  if instances.size == 0
    nil
  else
    instances.first
  end
end

- (Object) test_instance_name Also known as: instance_name



149
150
151
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 149

def test_instance_name
  parameter
end

- (Boolean) valid?

Returns:

  • (Boolean)


88
89
90
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 88

def valid?
  components[6] && TYPES.include?(components[6])
end

- (Object) vdd



197
198
199
200
201
202
# File 'lib/origen/tester/j750/parser/flow_line.rb', line 197

def vdd
  i = test_instance
  if i
    i.vdd
  end
end