Class: OrigenTesters::IGXLBasedTester::UltraFLEX::Flow

Inherits:
Base::Flow show all
Defined in:
lib/origen_testers/igxl_based_tester/ultraflex/flow.rb

Constant Summary collapse

TEMPLATE =
"#{Origen.root!}/lib/origen_testers/igxl_based_tester/ultraflex/templates/flow.txt.erb"
SCALES =
[:p, :n, :u, :m, :none, :k, :M]

Constants inherited from Base::Flow

Base::Flow::OUTPUT_POSTFIX

Constants included from Flow

Flow::PROGRAM_MODELS_DIR

Instance Attribute Summary

Attributes inherited from Base::Flow

#branch, #context, #current_enable, #current_flag, #set_flags, #stack

Instance Method Summary collapse

Methods inherited from Base::Flow

#branch_if_enable, #clean_job, #completed_lines, #current_line, #flag_to_s, #format, #new_line, #number_of_tests_in, #on_continue, #on_cz, #on_disable, #on_enable, #on_flow, #on_if_any_sites_flag, #on_if_enabled, #on_if_flag, #on_if_job, #on_log, #on_name, #on_number, #on_object, #on_on_fail, #on_on_pass, #on_render, #on_set_flag, #on_set_result, #open_lines, #ultraflex

Methods included from Flow

#active_description, #at_flow_start, #at_run_start, callstack, cc_comments, cc_comments=, #children, comment_stack, #context_changed?, flow_comments, flow_comments=, #generate_unique_label, ht_comments, ht_comments=, #is_the_flow?, #lines, #model, name_stack, #nop, #orig_render, #parent, #path, #program, #render, #save_program, #sig, #test, #top_level, #top_level?, unique_ids, unique_ids=

Methods included from ATP::FlowAPI

#atp, #atp=, #hi_limit, #limit, #lo_limit

Methods included from Generator

#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename, #filename=, #finalize, #identity_map, #import, #inhibit_output, #name, #on_close, original_reference_file, original_reference_file=, #output_file, #output_inhibited?, #platform, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template, #write_to_file

Methods inherited from ATP::Formatter

#format, format, run, run_and_format, #run_and_format

Methods inherited from ATP::Processor

#clean_flag, #extract_volatiles, #handler_missing, #process, #process_all, #run, #volatile?, #volatile_flags

Instance Method Details

#lowest_scale(a, b) ⇒ Object

Returns the lowest of the two scales



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/origen_testers/igxl_based_tester/ultraflex/flow.rb', line 154

def lowest_scale(a, b)
  if a == b
    a
  elsif !a
    b
  elsif !b
    a
  else
    if SCALES.index(a) < SCALES.index(b)
      a
    else
      b
    end
  end
end

#on_limit(node) ⇒ Object



120
121
122
123
124
125
126
127
128
# File 'lib/origen_testers/igxl_based_tester/ultraflex/flow.rb', line 120

def on_limit(node)
  value, rule, unit, selector = *node
  case rule
  when 'gte'
    current_line.lolim = value
  when 'lte'
    current_line.hilim = value
  end
end

#on_sub_test(node) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/origen_testers/igxl_based_tester/ultraflex/flow.rb', line 105

def on_sub_test(node)
  # for now assuming sub tests will be limits
  tname = node.find(:object).value
  # for some reason new_line :use_limit does not provide hbin, sbin etc accessors, duplicating behavior in on_test above
  line = open_lines.last.dup
  line.type = :use_limit
  line.opcode = 'Use-Limit'
  line.tname = tname
  line.tnum = nil
  open_lines << line
  process_all(node.children)
  @limit_lines = [] if @limit_lines.nil?
  @limit_lines << open_lines.pop
end

#on_test(node) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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_testers/igxl_based_tester/ultraflex/flow.rb', line 10

def on_test(node)
  super
  ins = node.find(:object).value

  # allow defer limits when limits are only given in sub tests
  if ins.respond_to?(:defer_limits)
    if ins.defer_limits
      completed_lines.last.opcode = 'Test-defer-limits'
    end
  end

  if ins.respond_to?(:lo_limit) && (ins.lo_limit || ins.hi_limit) || ins.respond_to?(:lo) && (ins.lo || ins.hi)
    limit = completed_lines.last.dup
    limit.type = :use_limit
    limit.opcode = 'Use-Limit'
    limit.parameter = nil
    limit.tnum = nil                            # Don't duplate test numbers, allow auto-increment by leaving blank
    if ins.respond_to?(:lo_limit)
      lo = ins.lo_limit
      hi = ins.hi_limit
      if lo.nil?
        lo = ins.lo
      end
      if hi.nil?
        hi = ins.hi
      end
    elsif ins.respond_to?(:lo)
      lo = ins.lo
      hi = ins.hi
    end

    size = 1
    if lo.is_a?(Array)
      size = lo.size if lo.size > size
    end
    if hi.is_a?(Array)
      size = hi.size if hi.size > size
    end

    size.times do |i|
      line = limit.dup

      if lo.is_a?(Array)
        l = lo[i]
      else
        l = lo
      end

      if hi.is_a?(Array)
        h = hi[i]
      else
        h = hi
      end

      if ins.scale
        if ins.scale.is_a?(Array)
          s = ins.scale[i]
        else
          s = ins.scale
        end
      else
        unless $tester.ultraflex?
          s = lowest_scale(scale_of(l), scale_of(h))
          l = scaled(l, s)
          h = scaled(h, s)
        end
      end
      line.lolim = l
      line.hilim = h
      line.scale = s unless s == :none
      if ins.units
        if ins.units.is_a?(Array)
          line.units = ins.units[i]
        else
          line.units = ins.units
        end
      end
      completed_lines << line
    end
  end
  # finish off any limit lines from sub tests
  unless @limit_lines.nil?
    tl = completed_lines.last
    tnum = tl.tnum
    @limit_lines.each do |line|
      line.parameter = tl.parameter
      line.sbin = tl.sbin
      line.bin = tl.bin
      line.tnum = tnum += 1 if tnum.is_a?(Numeric) && !line.tnum
      completed_lines << line
    end
    @limit_lines = nil
  end
end

#scale_of(number) ⇒ Object

Returns the scale that should be best used to represent the given number, returns nil in the case where the given number is nil



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/origen_testers/igxl_based_tester/ultraflex/flow.rb', line 132

def scale_of(number)
  if number && number.is_a?(Numeric)
    number = number.abs
    if number >= 1_000_000
      :M
    elsif number >= 1_000
      :k
    elsif number >= 0.1
      :none
    elsif number >= 0.000_1
      :m
    elsif number >= 0.000_000_1
      :u
    elsif number >= 0.000_000_000_1
      :n
    else
      :p
    end
  end
end

#scaled(number, scale) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/origen_testers/igxl_based_tester/ultraflex/flow.rb', line 170

def scaled(number, scale)
  if number
    if number.is_a?(Numeric)
      number = number.to_f
      if scale
        case scale
        when :M
          number = number / 1_000_000
        when :k
          number = number / 1_000
        when :m
          number = number * 1_000
        when :u
          number = number * 1_000_000
        when :n
          number = number * 1_000_000_000
        when :p
          number = number * 1_000_000_000_000
        end
      end
      if number.round(2) == number.to_i.to_f.round(2)
        number.to_i
      else
        number.round(2)
      end
    else
      number
    end
  end
end