Class: Origen::Tester::Ultraflex::Parser::FlowLine
- Defined in:
- lib/origen/tester/ultraflex/parser/flow_line.rb
Constant Summary collapse
- 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
-
#flow ⇒ Object
Returns the value of attribute flow.
-
#line ⇒ Object
Returns the value of attribute line.
-
#parser ⇒ Object
Returns the value of attribute parser.
Class Method Summary collapse
-
.extract_test(line) ⇒ Object
Returns the test instance called by the given line or nil.
Instance Method Summary collapse
- #components ⇒ Object
-
#conditions ⇒ Object
Returns a string summarizing any conditions (enable words, jobs, etc.) that gate the execution of this line.
- #conditions_met?(conditions, values) ⇒ Boolean
- #description ⇒ Object
- #enable_conditions_met?(context) ⇒ Boolean
- #env_conditions_met?(context) ⇒ Boolean
- #executes_under_context?(context) ⇒ Boolean
-
#initialize(line, options = {}) ⇒ FlowLine
constructor
A new instance of FlowLine.
-
#inspect ⇒ Object
:nodoc:.
- #job_conditions_met?(context) ⇒ Boolean
- #parse ⇒ Object
- #part_conditions_met?(context) ⇒ Boolean
-
#patterns(options = {}) ⇒ Object
(also: #pattern)
Returns an array of patterns used by the given test, if there are none an empty array is returned.
- #test? ⇒ Boolean
- #test_instance ⇒ Object (also: #instance)
- #test_instance_name ⇒ Object (also: #instance_name)
- #valid? ⇒ Boolean
- #vdd ⇒ Object
Constructor Details
#initialize(line, options = {}) ⇒ FlowLine
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 56 def initialize(line, = {}) @parser = [:parser] @flow = [: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
#flow ⇒ Object
Returns the value of attribute flow.
6 7 8 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 6 def flow @flow end |
#line ⇒ Object
Returns the value of attribute line.
6 7 8 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 6 def line @line end |
#parser ⇒ Object
Returns the value of attribute parser.
6 7 8 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 6 def parser @parser end |
Class Method Details
.extract_test(line) ⇒ Object
Returns the test instance called by the given line or nil
49 50 51 52 53 54 |
# File 'lib/origen/tester/ultraflex/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
#components ⇒ Object
92 93 94 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 92 def components @components ||= [] end |
#conditions ⇒ Object
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/ultraflex/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 |
#conditions_met?(conditions, values) ⇒ 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/ultraflex/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 |
#description ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/origen/tester/ultraflex/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 |
#enable_conditions_met?(context) ⇒ Boolean
107 108 109 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 107 def enable_conditions_met?(context) conditions_met?(enable, context[:enable]) end |
#env_conditions_met?(context) ⇒ Boolean
119 120 121 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 119 def env_conditions_met?(context) conditions_met?(env, context[:env]) end |
#executes_under_context?(context) ⇒ Boolean
100 101 102 103 104 105 |
# File 'lib/origen/tester/ultraflex/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 |
#inspect ⇒ Object
:nodoc:
68 69 70 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 68 def inspect # :nodoc: "<FlowLine: #{type}, Parameter: #{parameter}>" end |
#job_conditions_met?(context) ⇒ Boolean
111 112 113 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 111 def job_conditions_met?(context) conditions_met?(job, context[:job]) end |
#parse ⇒ Object
84 85 86 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 84 def parse @components = @line.split("\t") unless @line.strip.empty? end |
#part_conditions_met?(context) ⇒ Boolean
115 116 117 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 115 def part_conditions_met?(context) conditions_met?(part, context[:part]) end |
#patterns(options = {}) ⇒ Object 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/ultraflex/parser/flow_line.rb', line 171 def patterns( = {}) i = test_instance if i pats = i.patterns if [:ignore] && pats pats.reject { |p| [[:ignore]].flatten.include?(p) } else [] end else [] end end |
#test? ⇒ Boolean
96 97 98 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 96 def test? %w(Test characterize).include? opcode end |
#test_instance ⇒ Object Also known as: instance
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/origen/tester/ultraflex/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 |
#test_instance_name ⇒ Object Also known as: instance_name
149 150 151 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 149 def test_instance_name parameter end |
#valid? ⇒ Boolean
88 89 90 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 88 def valid? components[6] && TYPES.include?(components[6]) end |
#vdd ⇒ Object
197 198 199 200 201 202 |
# File 'lib/origen/tester/ultraflex/parser/flow_line.rb', line 197 def vdd i = test_instance if i i.vdd end end |