Class: OrigenLink::VectorBased

Inherits:
Object
  • Object
show all
Includes:
ServerCom, OrigenTesters::VectorBasedTester
Defined in:
lib/origen_link/vector_based.rb

Overview

OrigenLink::VectorBased

This class is meant to be used for live silicon debug.  Vector data that Origen
generates is intercepted and sent to a debug device (typically will be a Udoo
Neo - www.udoo.org).  The debug device can be any device that is able to serve
a TCP socket, recieve and interpret the command set used by this class and send
the expected responses.

Integration instructions

Set the pin map (must be done first) and pin order
  if tester.link?
     tester.pinmap = 'tclk,26,tms,19,tdi,16,tdo,23'
     tester.pinorder = 'tclk,tms,tdi,tdo'
  end

Set Origen to only generate vectors for pins in the pinmap (order should match)
     pin_pattern_order :tclk, :tms, :tdi, :tdo, only: true if tester.link?

At the beginning of the Startup method add this line
   tester.initialize_pattern if tester.link?

At the end of the Shutdown method add this line
  tester.finalize_pattern if tester.link?

Create a link environment with the IP address and socket number of a link server
  $tester = OrigenLink::VectorBased.new('192.168.0.2', 12777)

Direct Known Subclasses

Test::VectorBased

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ServerCom

#send_batch, #send_cmd, #setup_cmd_response_logger

Constructor Details

#initialize(address, port, options = {}) ⇒ VectorBased

Returns a new instance of VectorBased.



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
# File 'lib/origen_link/vector_based.rb', line 39

def initialize(address, port, options = {})
  @address = address
  @port = port
  @fail_count = 0
  @vector_count = 0
  @previous_vectordata = ''
  @previous_tset = ''
  @vector_repeatcount = 0
  @total_comm_time = 0
  @total_connect_time = 0
  @total_xmit_time = 0
  @total_recv_time = 0
  @total_packets = 0
  @max_packet_time = 0
  @max_receive_time = 0
  @tsets_programmed = {}
  @tset_count = 1
  @store_pins = []
  @captured_data = []
  # A tester seems to be unable to register as a callback handler, so for now instantiating a
  # dedicated object to implement the handlers related to this tester
  CallbackHandlers.new
  @vector_batch = []
  @store_pins_batch = {}
  @comment_batch = {}
  @batch_vectors = true
end

Instance Attribute Details

#captured_dataObject (readonly)

Returns the value of attribute captured_data.



36
37
38
# File 'lib/origen_link/vector_based.rb', line 36

def captured_data
  @captured_data
end

#comment_batchObject (readonly)

Returns the value of attribute comment_batch.



37
38
39
# File 'lib/origen_link/vector_based.rb', line 37

def comment_batch
  @comment_batch
end

#fail_countObject (readonly)

these attributes are exposed for testing purposes, a user would not need to read them



35
36
37
# File 'lib/origen_link/vector_based.rb', line 35

def fail_count
  @fail_count
end

#store_pins_batchObject (readonly)

Returns the value of attribute store_pins_batch.



37
38
39
# File 'lib/origen_link/vector_based.rb', line 37

def store_pins_batch
  @store_pins_batch
end

#total_comm_timeObject (readonly)

these attributes are exposed for testing purposes, a user would not need to read them



35
36
37
# File 'lib/origen_link/vector_based.rb', line 35

def total_comm_time
  @total_comm_time
end

#total_connect_timeObject (readonly)

these attributes are exposed for testing purposes, a user would not need to read them



35
36
37
# File 'lib/origen_link/vector_based.rb', line 35

def total_connect_time
  @total_connect_time
end

#total_packetsObject (readonly)

Returns the value of attribute total_packets.



36
37
38
# File 'lib/origen_link/vector_based.rb', line 36

def total_packets
  @total_packets
end

#total_recv_timeObject (readonly)

Returns the value of attribute total_recv_time.



36
37
38
# File 'lib/origen_link/vector_based.rb', line 36

def total_recv_time
  @total_recv_time
end

#total_xmit_timeObject (readonly)

these attributes are exposed for testing purposes, a user would not need to read them



35
36
37
# File 'lib/origen_link/vector_based.rb', line 35

def total_xmit_time
  @total_xmit_time
end

#tsets_programmedObject (readonly)

Returns the value of attribute tsets_programmed.



36
37
38
# File 'lib/origen_link/vector_based.rb', line 36

def tsets_programmed
  @tsets_programmed
end

#vector_batchObject (readonly)

Returns the value of attribute vector_batch.



37
38
39
# File 'lib/origen_link/vector_based.rb', line 37

def vector_batch
  @vector_batch
end

#vector_countObject (readonly)

these attributes are exposed for testing purposes, a user would not need to read them



35
36
37
# File 'lib/origen_link/vector_based.rb', line 35

def vector_count
  @vector_count
end

#vector_repeatcountObject (readonly)

Returns the value of attribute vector_repeatcount.



36
37
38
# File 'lib/origen_link/vector_based.rb', line 36

def vector_repeatcount
  @vector_repeatcount
end

Instance Method Details

#capture(*args) ⇒ Object

Capture any store data within the given block, return it and then internally clear the tester’s capture memory.

Examples:


v = tester.capture do
  my_reg.store!
end
v      # => Data value read from my_reg on the DUT


160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/origen_link/vector_based.rb', line 160

def capture(*args)
  if block_given?
    yield
    synchronize
    d = @captured_data
    @captured_data = []
    d
  else
    # On other testers capture is an alias of store
    store(*args)
  end
end

#finalize_pattern(output_file) ⇒ Object

finalize_pattern

This method flushes the final vector.  Then, it logs success or failure of the
pattern execution along with execution time information.


307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/origen_link/vector_based.rb', line 307

def finalize_pattern(output_file)
  Origen.log.debug('Pattern generation completed. Sending all stored vector data')
  synchronize(output_file)
  # for debug, report communication times
  Origen.log.debug("total communication time: #{@total_comm_time}")
  Origen.log.debug("total connect time: #{@total_connect_time}")
  Origen.log.debug("total transmit time: #{@total_xmit_time}")
  Origen.log.debug("total receive time: #{@total_recv_time}")
  Origen.log.debug("total packets: #{@total_packets}")
  Origen.log.debug("total time per packet: #{@total_comm_time / @total_packets}")
  Origen.log.debug("connect time per packet: #{@total_connect_time / @total_packets}")
  Origen.log.debug("transmit time per packet: #{@total_xmit_time / @total_packets}")
  Origen.log.debug("receive time per packet: #{@total_recv_time / @total_packets}")
  Origen.log.debug("max packet time: #{@max_packet_time}")
  Origen.log.debug("max duration command - #{@longest_packet}")
  Origen.log.debug("max receive time: #{@max_receive_time}")
  if @fail_count == 0
    # Origen.log.success("PASS - pattern execution passed (#{@vector_count} vectors pass)")
    Origen.app.stats.report_pass
  else
    # Origen.log.error("FAIL - pattern execution failed (#{@fail_count} failures)")
    Origen.app.stats.report_fail
  end
end

#flush_vector(programmed_data = '', tset = '') ⇒ Object

flush_vector

Just as the name suggests, this method "flushes" a vector.  This is necessary because
of repeat compression (a vector isn't sent until different vector data is encountered)

Don't forget to flush when you're in debug mode.  Otherwise, the last vector of a
write command won't be sent to the server.


179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/origen_link/vector_based.rb', line 179

def flush_vector(programmed_data = '', tset = '')
  # prevent server crash when vector_flush is used during debug
  unless @previous_vectordata == ''
    if @vector_repeatcount > 1
      repeat_prefix = "repeat#{@vector_repeatcount},"
    else
      repeat_prefix = ''
    end
    if @tsets_programmed[@previous_tset]
      tset_prefix = "tset#{@tsets_programmed[@previous_tset]},"
    else
      tset_prefix = ''
    end

    if @batch_vectors
      @vector_batch << 'pin_cycle:' + tset_prefix + repeat_prefix + @previous_vectordata
      # store capture pins for batch processing
      unless @store_pins.empty?
        @store_pins_batch[@vector_batch.length - 1] = @store_pins
      end
    else
      process_vector_response(send_cmd('pin_cycle', tset_prefix + repeat_prefix + @previous_vectordata))
    end

    # make sure that only requested vectors are stored when batching is enabled
    @store_pins = []
  end

  @vector_repeatcount = 1
  @previous_vectordata = programmed_data
  @previous_tset = tset
end

#get_tset_number(name) ⇒ Object

get_tset_number(name)

This method returns the test number associated with the
passed in tset name.  If the name is unknown a new lookup
number is returned.


415
416
417
418
419
420
421
# File 'lib/origen_link/vector_based.rb', line 415

def get_tset_number(name)
  unless @tsets_programmed.key?(name)
    @tsets_programmed[name] = @tset_count
    @tset_count += 1
  end
  @tsets_programmed[name]
end

#initialize_patternObject

initialize_pattern

This method sets initializes variables at the start of a pattern.
it is called automatically when pattern generation starts.


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/origen_link/vector_based.rb', line 284

def initialize_pattern
  @fail_count = 0
  @vector_count = 0
  @vector_batch.delete_if { true }
  @store_pins_batch.clear
  @comment_batch.clear

  @total_packets = 0
  @total_comm_time = 0
  @total_connect_time = 0
  @total_xmit_time = 0
  @total_recv_time = 0

  if @pinmap.nil?
    Origen.log.error('pinmap has not been setup, use tester.pinmap= to initialize a pinmap')
  else
    Origen.log.debug('executing pattern with pinmap:' + @pinmap.to_s)
  end
end

#pinformat=(pinformat) ⇒ Object

pinformat=

This method is used to setup the pin clock format on the debugger device.
The supported formats are rl and rh

example:
  tester.pinformat = 'func_25mhz,tclk,rl'


377
378
379
380
381
# File 'lib/origen_link/vector_based.rb', line 377

def pinformat=(pinformat)
  @pinformat = replace_tset_name_w_number(pinformat.gsub(/\s+/, ''))
  response = send_cmd('pin_format', @pinformat)
  setup_cmd_response_logger('pin_format', response)
end

#pinmap=(pinmap) ⇒ Object

pinmap=

This method is used to setup the pin map on the debugger device.
The argument should be a string with <pin name>, <gpio #>, <pin name>
<gpio #>, etc

example:
  tester.pinmap = 'tclk,26,tms,19,tdi,16,tdo,23'


349
350
351
352
353
# File 'lib/origen_link/vector_based.rb', line 349

def pinmap=(pinmap)
  @pinmap = pinmap.gsub(/\s+/, '')
  response = send_cmd('pin_assign', @pinmap)
  setup_cmd_response_logger('pin_assign', response)
end

#pinorder=(pinorder) ⇒ Object

pinorder=

This method is used to setup the pin order on the debugger device.
The pin order will indicate the order that pin data appears in vector
data.

This is a duplicate of pattern_pin_order and can be handled behind the
scenes in the future.

example:
  tester.pinorder = 'tclk,tms,tdi,tdo'


365
366
367
368
369
# File 'lib/origen_link/vector_based.rb', line 365

def pinorder=(pinorder)
  @pinorder = pinorder.gsub(/\s+/, '')
  response = send_cmd('pin_patternorder', @pinorder)
  setup_cmd_response_logger('pin_patternorder', response)
end

#pintiming=(pintiming) ⇒ Object

pintiming=

This method is used to setup the pin timing on the debugger device.
Timing is relative to the rise and fall of a clock

timing value:         0   1   2
clock waveform:      ___/***\___

example:
  tester.pintiming = 'func_25mhz,tms,0,tdi,0,tdo,1'


392
393
394
395
396
# File 'lib/origen_link/vector_based.rb', line 392

def pintiming=(pintiming)
  @pintiming = replace_tset_name_w_number(pintiming.gsub(/\s+/, ''))
  response = send_cmd('pin_timing', @pintiming)
  setup_cmd_response_logger('pin_timing', response)
end

#process_response(response, output_file = '') ⇒ Object

process_response

This method will process a server response.  Send log info to the output,
keep track of fail count and captured data


228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/origen_link/vector_based.rb', line 228

def process_response(response, output_file = '')
  if response.is_a?(Array)
    # if called from finalize_pattern -> synchronize, open the output_file and store results
    output_obj = nil
    output_obj = File.open(output_file, 'a+') unless output_file == ''
    response.each_index do |index|
      # restore store pins state for processing
      if @store_pins_batch.key?(index)
        @store_pins = @store_pins_batch[index]
      else
        @store_pins = []
      end
      if @comment_batch.key?(index)
        unless output_file == ''
          # get the header placed correctly
          if index == response.length - 1
            output_obj.puts 'last comment'
            output_obj.lineno = 0
          end
          output_obj.puts(@comment_batch[index])
        end
      end
      process_vector_response(response[index], output_obj)
    end
    output_obj.close unless output_file == ''
  else
    process_vector_response(response)
  end
end

#process_vector_response(vector_response, output_obj = nil) ⇒ Object

process_vector_response

This method exists to prevent code duplication when handling an array of
batched responses versus a single response string.


261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/origen_link/vector_based.rb', line 261

def process_vector_response(vector_response, output_obj = nil)
  unless @store_pins.empty?
    msg = "  (Captured #{@store_pins.map(&:name).join(', ')})\n"
    capture_data(vector_response)
    vector_response.strip!
    vector_response += msg
  end
  if output_obj.nil?
    microcode vector_response
  else
    output_obj.puts(vector_response)
  end

  unless vector_response.chr == 'P'
    # TODO: Put this back with an option to disable, based on a serial or parallel interface being used
    # microcode 'E:' + @previous_vectordata + ' //expected data for previous vector'
    @fail_count += 1
  end
end

#push_comment(msg) ⇒ Object

push_comment

This method intercepts comments so they can be correctly placed in the output file
when vector batching is used


70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/origen_link/vector_based.rb', line 70

def push_comment(msg)
  if @batch_vectors
    key = @vector_batch.length
    if @comment_batch.key?(key)
      @comment_batch[key] = @comment_batch[key] + "\n" + msg
    else
      @comment_batch[key] = msg
    end
  else
    microcode msg
  end
end

#push_vector(options) ⇒ Object

push_vector

This method intercepts vector data from Origen, removes white spaces and compresses repeats


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/origen_link/vector_based.rb', line 85

def push_vector(options)
  programmed_data = options[:pin_vals].gsub(/\s+/, '')
  unless options[:timeset]
    puts 'No timeset defined!'
    puts 'Add one to your top level startup method or target like this:'
    puts '$tester.set_timeset("nvmbist", 40)   # Where 40 is the period in ns'
    exit 1
  end
  tset = options[:timeset].name
  if @vector_count > 0
    # compressing repeats as we go
    if (programmed_data == @previous_vectordata) && (@previous_tset == tset) && @store_pins.empty?
      @vector_repeatcount += 1
    else
      # all repeats of the previous vector have been counted
      # time to flush.  Don't panic though!  @previous_vectordata
      # is what gets flushed.  programmed_data is passed as an
      # arg to be set as the new @previous_vectordata
      flush_vector(programmed_data, tset)
    end
  else
    # if this is the first vector of the pattern, insure variables are initialized
    @previous_vectordata = programmed_data
    @previous_tset = tset
    @vector_repeatcount = 1
  end # if vector_count > 0
  @vector_count += 1
end

#replace_tset_name_w_number(csl) ⇒ Object

replace_tset_name_w_number(csl)

This method is used by pinformat= and pintiming=
This method receives a comma separated list of arguments
the first of which is a timeset name.  A comma
separated list is returned with the timeset name replaced
by it's lookup number.  If it is a new timset, a lookup
number is associated with the name.


405
406
407
408
409
# File 'lib/origen_link/vector_based.rb', line 405

def replace_tset_name_w_number(csl)
  args = csl.split(',')
  args[0] = get_tset_number(args[0])
  args.join(',')
end

#store(*pins) ⇒ Object

Capture a vector

This method applies a store vector request to the previous vector, note that is does not actually generate a new vector.

The captured data is added to the captured_data array.

This method is indended to be used by pin drivers, see the #capture method for the application level API.

Examples:

$tester.cycle                # This is the vector you want to capture
$tester.store                # This applies the store request


127
128
129
130
# File 'lib/origen_link/vector_based.rb', line 127

def store(*pins)
  options = pins.last.is_a?(Hash) ? pins.pop : {}
  fail 'The store is not implemented yet on Link'
end

#store_next_cycle(*pins) ⇒ Object

Capture the next vector generated

This method applies a store request to the next vector to be generated, note that is does not actually generate a new vector.

The captured data is added to the captured_data array.

This method is indended to be used by pin drivers, see the #capture method for the application level API.

Examples:

tester.store_next_cycle
tester.cycle                # This is the vector that will be captured


145
146
147
148
149
# File 'lib/origen_link/vector_based.rb', line 145

def store_next_cycle(*pins)
  options = pins.last.is_a?(Hash) ? pins.pop : {}
  flush_vector
  @store_pins = pins
end

#synchronize(output_file = '') ⇒ Object

synchronize

This method will synchronize the DUT state with Origen.  All generated
vectors are sent to the DUT for execution and the responses are processed


215
216
217
218
219
220
221
222
223
# File 'lib/origen_link/vector_based.rb', line 215

def synchronize(output_file = '')
  flush_vector
  if @batch_vectors
    process_response(send_batch(@vector_batch), output_file)
  end
  @vector_batch = []
  @store_pins_batch.clear
  @comment_batch.clear
end

#to_sObject

to_s

returns 'Origen::VectorBased'

This method at the moment is used for implementing code that runs only if the
environment is set to link vector based.  tester.link? will be used once the testers
plug in supports the method link?.


338
339
340
# File 'lib/origen_link/vector_based.rb', line 338

def to_s
  'OrigenLink::VectorBased'
end