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
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 8

def initialize
  @pat_extension = 'digipatsrc'
  @capture_started = {}
  @source_started = {}
  @global_label_export = []
  @called_subroutines = []
  @default_capture_wave_name = 'default_capture_waveform'
  @default_source_wave_name = 'default_source_waveform'
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



171
172
173
174
175
176
177
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 171

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

#add_microcode_to_first_vec(statement) ⇒ Object



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

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


73
74
75
76
77
78
79
80
81
82
83
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 73

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



138
139
140
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
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 138

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_started[:default]
      add_microcode_to_first_vec "source_start(#{@default_source_wave_name})"
      @source_started[:default] = true
    end

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

    if overlay_options[:change_data]
      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



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

def end_subroutine
  update_vector microcode: 'return'
end

#format_pin_state(pin) ⇒ Object

change the capture state character



202
203
204
205
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 202

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

#format_vector(vec) ⇒ Object

Internal method called by Origen



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

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



196
197
198
199
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 196

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

Internal method called by Origen



42
43
44
45
46
47
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 42

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

#pattern_header(options = {}) ⇒ Object

Internal method called by Origen



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

def pattern_header(options = {})
  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)
    end
  end
end

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



85
86
87
88
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 85

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



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

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



180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/origen_testers/labview_based_tester/pxie6570.rb', line 180

def store_next_cycle(*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 { |pin| pin.save; pin.capture }
  preset_next_vector(microcode: 'capture') do
    pins.each(&:restore)
  end
end