Module: OrigenTesters::API

Defined in:
lib/origen_testers/api.rb

Overview

This module implements the basic set of methods that a tester must have in order for Origen to talk to it.

They can be overridden by tester specific classes and who may go on to add additional methods of their own.

Essentially this API means that any class that includes Origen::Tester will function as a tester, although it might not do very much!

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#comment_levelObject

Returns the value of attribute comment_level.



12
13
14
# File 'lib/origen_testers/api.rb', line 12

def comment_level
  @comment_level
end

#generatingObject

Returns the value of attribute generating.



13
14
15
# File 'lib/origen_testers/api.rb', line 13

def generating
  @generating
end

#includesObject

Returns the value of attribute includes.



11
12
13
# File 'lib/origen_testers/api.rb', line 11

def includes
  @includes
end

Instance Method Details

#annotate(msg, options = {}) ⇒ Object



84
85
# File 'lib/origen_testers/api.rb', line 84

def annotate(msg, options = {})
end

#any_clocks_running?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/origen_testers/api.rb', line 202

def any_clocks_running?
  @clocks_running.nil? ? false : @clocks_running.count > 0
end

#c1(msg, options = {}) ⇒ Object

Output a comment in the pattern, normally you would not call this directly and instead use these shorthand methods:

cc "Some comment"
ss "A single line step comment"
step_comment do
    cc "A multi line"
    cc "step comment"
end


104
105
106
107
108
# File 'lib/origen_testers/api.rb', line 104

def c1(msg, options = {})
  prefix = comment_char + ' '
  prefix += step_comment_prefix + ' ' if @step_comment_on
  push_comment(prefix + msg.to_s)
end

#c2(msg, options = {}) ⇒ Object



110
111
112
# File 'lib/origen_testers/api.rb', line 110

def c2(msg, options = {})
  c1(msg, options)
end

#clocks_runningObject Also known as: running_clocks



206
207
208
# File 'lib/origen_testers/api.rb', line 206

def clocks_running
  @clocks_running
end

#comment_charObject



36
37
38
# File 'lib/origen_testers/api.rb', line 36

def comment_char
  @comment_char || '//'
end

#cycle(options = {}) ⇒ Object

Generate a vector. Calling this method will generate a vector in the output pattern based on the current pin states and timeset.



164
165
166
167
168
169
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
# File 'lib/origen_testers/api.rb', line 164

def cycle(options = {})
  options = {
    microcode: '',
    timeset:   current_timeset,
    pin_vals:  current_pin_vals,
    repeat:    nil
  }.merge(options)

  if any_clocks_running?
    update_running_clocks
    if options[:repeat]
      slice_repeats(options).each do |slice|
        options[:repeat] = slice[0]
        delay(options.delete(:repeat), options) do |options|
          push_vector(options)
        end
        slice[1].each { |clock_pin_name| clocks_running[clock_pin_name].toggle_clock }
        options[:pin_vals] = current_pin_vals
      end
    else
      push_vector(options)
      pins_need_toggling.each { |clock_pin_name| clocks_running[clock_pin_name].toggle_clock }
    end
  else
    if options[:repeat]
      delay(options.delete(:repeat), options) do |options|
        push_vector(options)
      end
    else
      push_vector(options)
    end
  end
end

#doc?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/origen_testers/api.rb', line 80

def doc?
  false
end

#generate?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/origen_testers/api.rb', line 19

def generate?
  true
end

#generating_pattern?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/origen_testers/api.rb', line 23

def generating_pattern?
  @generating == :pattern
end

#generating_program?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/origen_testers/api.rb', line 27

def generating_program?
  @generating == :program
end

#ignore_fails(*pins) ⇒ Object

Ignore fails on the given pins for the duration of the given block, this has the effect of temporarily setting the states of the given pins to don’t care.



90
91
92
93
94
# File 'lib/origen_testers/api.rb', line 90

def ignore_fails(*pins)
  pins.each(&:suspend)
  yield
  pins.each(&:resume)
end

#import_test_time(file, options = {}) ⇒ Object



198
199
200
# File 'lib/origen_testers/api.rb', line 198

def import_test_time(file, options = {})
  puts "Sorry but an importer doesn't exist for: #{Origen.tester.class}"
end

#inhibit_vectors_and_commentsObject

Allows a section to be run without actually generating any vectors. This can be useful to ensure the pin states end up as they otherwise would have if the section had been run. Classic example of this is a subroutine pattern, wrap this around a call to the startup routine to ensure the pin states are as they would have been immediately after the startup.

Example

# Setup state as if I had run startup without actually doing so
$tester.inhibit_vectors_and_comments do
    $soc.startup
    $top.startup
end


151
152
153
154
155
156
157
158
159
# File 'lib/origen_testers/api.rb', line 151

def inhibit_vectors_and_comments
  inhibit_vectors = @inhibit_vectors
  inhibit_comments = @inhibit_comments
  @inhibit_vectors = true
  @inhibit_comments = true
  yield
  @inhibit_vectors = inhibit_vectors      # Restore to their initial state
  @inhibit_comments = inhibit_comments
end

#is_command_based?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/origen_testers/api.rb', line 59

def is_command_based?
  !is_vector_based?
end

#is_vector_based?Boolean

Returns:

  • (Boolean)


54
55
56
57
# File 'lib/origen_testers/api.rb', line 54

def is_vector_based?
  return @vector_based if defined?(@vector_based)
  true
end

#j750?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/origen_testers/api.rb', line 63

def j750?
  is_a?(OrigenTesters::IGXLBasedTester::J750)
end

#j750_hpt?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/origen_testers/api.rb', line 67

def j750_hpt?
  is_a?(OrigenTesters::IGXLBasedTester::J750_HPT)
end

#nameObject



15
16
17
# File 'lib/origen_testers/api.rb', line 15

def name
  @name || self.class
end

#pat_extensionObject Also known as: pattern_extension



31
32
33
# File 'lib/origen_testers/api.rb', line 31

def pat_extension
  @pat_extension || 'txt'
end


47
48
# File 'lib/origen_testers/api.rb', line 47

def pattern_footer(*args)
end

#pattern_header(*args) ⇒ Object



44
45
# File 'lib/origen_testers/api.rb', line 44

def pattern_header(*args)
end

#pattern_section(msg) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/origen_testers/api.rb', line 114

def pattern_section(msg)
  if generating_program?
    yield
  else
    step_comment(msg)
    yield
  end
end

#pins_need_togglingObject



244
245
246
247
248
249
250
# File 'lib/origen_testers/api.rb', line 244

def pins_need_toggling
  toggle_ary = []
  clocks_running.each do |name, clock_pin|
    toggle_ary.push("#{name}") if clock_pin.next_edge == cycle_count
  end
  toggle_ary
end

#pop_running_clock(pin) ⇒ Object



215
216
217
218
# File 'lib/origen_testers/api.rb', line 215

def pop_running_clock(pin)
  fail "ERROR: No clocks running, doesn't make sense to pop one" unless any_clocks_running?
  @clocks_running.delete(pin.name.to_s)
end

#program_comment_charObject



40
41
42
# File 'lib/origen_testers/api.rb', line 40

def program_comment_char
  @program_comment_char || comment_char
end

#push_running_clock(pin) ⇒ Object



211
212
213
# File 'lib/origen_testers/api.rb', line 211

def push_running_clock(pin)
  @clocks_running.nil? ? @clocks_running = { pin.name.to_s => pin } : @clocks_running[pin.name.to_s] = pin
end

#slice_repeats(options = {}) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/origen_testers/api.rb', line 220

def slice_repeats(options = {})
  slices = {}
  repeat_ary = []
  clocks_running.each do |name, clock_pin|
    if clock_pin.next_edge < (cycle_count + options[:repeat])
      pin_slices = (clock_pin.next_edge..(cycle_count + options[:repeat])).step(clock_pin.half_period).to_a
      pin_slices.insert(0, cycle_count)
    else
      pin_slices = [cycle_count]
    end
    pin_slices.each do |cycle|
      slices[cycle].nil? ? slices[cycle] = name : slices[cycle] = "#{slices[cycle]},#{name}"
    end
    slices[cycle_count + options[:repeat]] = '' if pin_slices[-1] != cycle_count + options[:repeat]
  end
  slices.keys.sort.each do |edge_cycles|
    # puts "Toggle #{slices[edge_cycles]} on #{edge_cycles}"
    repeat_ary.push([edge_cycles, slices[edge_cycles].split(',')])
  end

  (repeat_ary.count - 1).downto(1).each { |i| repeat_ary[i][0] = repeat_ary[i][0] - repeat_ary[i - 1][0] }
  repeat_ary[1..-1]
end

#snip(number, options = {}) ⇒ Object



137
138
139
# File 'lib/origen_testers/api.rb', line 137

def snip(number, options = {})
  yield
end

#ss(msg = nil) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/origen_testers/api.rb', line 123

def ss(msg = nil)
  div = step_comment_prefix.length
  div = 1 if div == 0
  c1(step_comment_prefix * (70 / div))
  @step_comment_on = true
  if block_given?
    yield
  else
    c1(msg)
  end
  @step_comment_on = false
  c1(step_comment_prefix * (70 / div))
end

#step_comment_prefixObject



50
51
52
# File 'lib/origen_testers/api.rb', line 50

def step_comment_prefix
  @step_comment_prefix || '##'
end

#ultraflex?Boolean Also known as: uflex?

Returns:

  • (Boolean)


75
76
77
# File 'lib/origen_testers/api.rb', line 75

def ultraflex?
  is_a?(OrigenTesters::IGXLBasedTester::UltraFLEX)
end

#update_running_clocksObject



252
253
254
255
256
# File 'lib/origen_testers/api.rb', line 252

def update_running_clocks
  clocks_running.each do |name, clock_pin|
    clock_pin.update_clock
  end
end

#v93k?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/origen_testers/api.rb', line 71

def v93k?
  is_a?(OrigenTesters::SmartestBasedTester::V93K)
end