Class: OrigenTesters::LabVIEWBasedTester::Pxie6570

Inherits:
Object
  • Object
show all
Includes:
VectorBasedTester
Defined in:
lib/origen_testers/labview_based_tester/pxie6570.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from VectorBasedTester

#register_tester

Constructor Details

#initializePxie6570

Returns a new instance of Pxie6570.


8
9
10
11
12
13
14
15
16
17
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 8

def initialize
  @name = 'pxie'
  @pat_extension = 'digipatsrc'
  @capture_history = {}
  @source_history = {}
  @global_label_export = []
  @called_subroutines = []
  @default_capture_wave_name = 'default_capture_waveform'
  @default_source_wave_name = 'default_source_waveform'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object

warn but don't fail if an api for another platform is not yet implemented


217
218
219
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 217

def method_missing(m, *args, &block)
  Origen.log.warn "#{m} is not yet implemented for LabVIEWBasedTester::Pxie6570"
end

Instance Attribute Details

#default_capture_wave_nameObject

Returns the value of attribute default_capture_wave_name.


6
7
8
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 6

def default_capture_wave_name
  @default_capture_wave_name
end

#default_source_wave_nameObject

Returns the value of attribute default_source_wave_name.


6
7
8
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 6

def default_source_wave_name
  @default_source_wave_name
end

Instance Method Details

#add_capture_start(pins, options = {}) ⇒ Object

internal method to avoid needless code duplication


176
177
178
179
180
181
182
183
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 176

def add_capture_start(pins, options = {})
  unless @capture_history[:started]
    # add the capture start opcode to the top of the pattern
    add_microcode_to_first_vec "capture_start(#{@default_capture_wave_name})"
    @capture_history[:started] = true
    @capture_history[:count] = 0
  end
end

#add_microcode_to_first_vec(statement) ⇒ Object


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 119

def add_microcode_to_first_vec(statement)
  # find the first vector
  i = 0
  i += 1 until stage.bank[i].is_a?(OrigenTesters::Vector)
  first_vector = stage.bank[i]

  if first_vector.has_microcode? || first_vector.repeat > 1
    v = OrigenTesters::Vector.new
    v.pin_vals = first_vector.pin_vals
    v.timeset = first_vector.timeset
    v.inline_comment = 'added line for opcode insert'
    v.dont_compress = true
    v.microcode = statement
    stage.insert_from_start v, i

    # decrement repeat count of previous first vector if > 1
    first_vector.repeat -= 1 if first_vector.repeat > 1
  else
    first_vector.microcode = statement
  end
end

#call_subroutine(name, options = {}) ⇒ Object

insert a subroutine call provide optional argument to implement as jump instead of call:

Examples:

tester.call_subroutine 'my_sub', jump: true

76
77
78
79
80
81
82
83
84
85
86
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 76

def call_subroutine(name, options = {})
  options = { jump: false }.merge(options)
  @called_subroutines << name.to_s.chomp unless @called_subroutines.include?(name.to_s.chomp)
  local_microcode = ''
  if options[:jump]
    local_microcode = "jump #{name}"
  else
    local_microcode = "call #{name}"
  end
  update_vector microcode: local_microcode, offset: options[:offset]
end

#cycle(options = {}) ⇒ Object


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 141

def cycle(options = {})
  # handle overlay if requested
  overlay_options = options.key?(:overlay) ? options.delete(:overlay) : {}
  cur_pin_state = nil
  if overlay_options.key?(:pins)
    overlay_options = { change_data: true }.merge(overlay_options)
    unless @source_history[:started]
      add_microcode_to_first_vec "source_start(#{@default_source_wave_name})"
      @source_history[:started] = true
      @source_history[:count] = 0
    end

    # ensure no unwanted repeats on the source line
    options[:dont_compress] = true

    if overlay_options[:change_data]
      @source_history[:count] += 1
      if options[:microcode].nil?
        options[:microcode] = 'source'
      else
        options[:microcode] = options[:microcode] + ', source'
      end
      options[:microcode] = options[:microcode] + ", repeat (#{options[:repeat]})" unless options[:repeat].nil?
      options.delete(:repeat)
    end

    # set pins to drive data
    cur_pin_state = overlay_options[:pins].state.to_sym
    overlay_options[:pins].drive_mem
  end
  super(options)
  overlay_options[:pins].state = cur_pin_state if overlay_options.key?(:pins)
end

#end_subroutineObject


93
94
95
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 93

def end_subroutine
  update_vector microcode: 'return'
end

#format_pin_state(pin) ⇒ Object

change the capture state character


211
212
213
214
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 211

def format_pin_state(pin)
  response = super(pin)
  response.sub('C', 'V')
end

#format_vector(vec) ⇒ Object

Internal method called by Origen


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 53

def format_vector(vec)
  timeset = vec.timeset ? " #{vec.timeset.name}" : ''
  pin_vals = vec.pin_vals ? "#{vec.pin_vals} ;" : ''
  microcode = vec.microcode ? vec.microcode : ''
  if vec.repeat > 1
    microcode = "repeat (#{vec.repeat})"
  else
    microcode = vec.microcode ? vec.microcode : ''
  end
  if vec.pin_vals && ($_testers_enable_vector_comments || vector_comments)
    comment = " // #{vec.number}:#{vec.cycle} #{vec.inline_comment}"
  else
    comment = vec.inline_comment.empty? ? '' : " // #{vec.inline_comment}"
  end

  "#{microcode.ljust(65)}#{timeset.ljust(31)}#{pin_vals}#{comment}"
end

#label(name, global = false) ⇒ Object

add a label to the output pattern


205
206
207
208
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 205

def label(name, global = false)
  microcode name + ':'
  @global_label_export << name if global
end

Internal method called by Origen


45
46
47
48
49
50
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 45

def pattern_footer(options = {})
  # add capture/source stop to the end of the pattern
  cycle microcode: 'capture_stop' if @capture_history[:started]
  cycle microcode: 'halt'
  microcode '}'
end

#pattern_header(options = {}) ⇒ Object

Internal method called by Origen


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 20

def pattern_header(options = {})
  microcode "// source count: #{@source_history[:count]}" if @source_history[:started]
  microcode "// capture count: #{@capture_history[:count]}" if @capture_history[:started]
  microcode 'file_format_version 1.0;'
  start_label = "#{options[:pattern]}_st"
  microcode "export #{start_label};"
  @global_label_export.each { |label| microcode "export #{label};" }
  @called_subroutines.each { |sub| microcode "import #{sub};" }
  called_timesets.each do |timeset|
    microcode "timeset #{timeset.name};"
  end
  pin_list = ordered_pins.map(&:name).join(',')
  microcode "pattern #{options[:pattern]} (#{pin_list})"
  microcode '{'
  microcode "#{start_label}:"
  # Remove any leading comments before first vector data
  unless options[:subroutine_pat]
    stage.with_bank(:body) do
      # find the first vector
      stage.bank.delete_at(0) until stage.bank[0].is_a?(OrigenTesters::Vector) || stage.bank.empty?
    end
  end
end

#start_subroutine(name, options = {}) ⇒ Object


88
89
90
91
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 88

def start_subroutine(name, options = {})
  options = { global: false }.merge(options)
  label name, options[:global]
end

#store(*pins) ⇒ Object Also known as: to_hram, capture

store/capture the state of the provided pins


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 98

def store(*pins)
  options = pins.last.is_a?(Hash) ? pins.pop : {}
  options = { offset: 0 }.merge(options)
  pins = pins.flatten.compact

  fail 'For the PXIE6570 you must supply the pins to store/capture' if pins.empty?
  add_capture_start pins, options

  pins.each do |pin|
    pin.restore_state do
      pin.capture
      update_vector_pin_val pin, offset: options[:offset]
      last_vector(options[:offset]).dont_compress = true
    end
  end

  update_vector microcode: 'capture', offset: options[:offset]
end

#store_next_cycle(*pins) ⇒ Object Also known as: store!

store/capture the provided pins on the next cycle


186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 186

def store_next_cycle(*pins)
  options = pins.last.is_a?(Hash) ? pins.pop : {}
  options = { offset: 0 }.merge(options)
  pins = pins.flatten.compact

  repeat_count = options[:repeat].nil? ? 1 : options[:repeat]

  fail 'For the PXIE6570 you must supply the pins to store/capture' if pins.empty?
  add_capture_start pins, options
  @capture_history[:count] += repeat_count

  pins.each { |pin| pin.save; pin.capture }
  preset_next_vector(microcode: 'capture') do
    pins.each(&:restore)
  end
end