Class: OrigenLink::VectorBased
- Inherits:
-
Object
- Object
- OrigenLink::VectorBased
- Includes:
- CaptureSupport, ConfigurationCommands, ServerCom, OrigenTesters::VectorBasedTester
- Defined in:
- lib/origen_link/vector_based.rb
Overview
OrigenLink::VectorBased
This class describes the OrigenLink app plug-in. 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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#captured_data ⇒ Object
readonly
Data captured using tester.capture.
-
#comment_batch ⇒ Object
readonly
Array of comments received through push_comment.
-
#fail_count ⇒ Object
The number of cycles that fail.
-
#initial_comm_sent ⇒ Object
readonly
Indicates that communication has been initiated with the server.
-
#store_pins_batch ⇒ Object
readonly
Used with capture.
-
#total_comm_time ⇒ Object
readonly
The accumulated total time spent communicating with the server.
-
#total_connect_time ⇒ Object
readonly
The accumulated total time spent establishing the server connection.
-
#total_packets ⇒ Object
readonly
The accumulated total number of packets sent to the server.
-
#total_recv_time ⇒ Object
readonly
The accumulated total time spent receiving from the server app.
-
#total_xmit_time ⇒ Object
readonly
The accumulated total time spent transmitting to the server app.
-
#tsets_programmed ⇒ Object
readonly
The look up of programmed tsets.
-
#user_name ⇒ Object
readonly
The name of the user running OrigenLink.
-
#vector_batch ⇒ Object
readonly
Array of vectors waiting to be sent to the sever.
-
#vector_count ⇒ Object
readonly
The number of vector cycles generated.
-
#vector_repeatcount ⇒ Object
readonly
The accumulated number of times push_vector was called with the present tset and pin info.
Instance Method Summary collapse
-
#finalize_pattern(output_file) ⇒ Object
finalize_pattern This method flushes the final vector.
-
#fix_ordered_pins(options) ⇒ Object
fix_ordered_pins(options) This method is called the first time push_vector is called.
-
#flush_vector(programmed_data = '', tset = '', local_repeat = 1) ⇒ Object
flush_vector Just as the name suggests, this method “flushes” a vector.
-
#initialize(address, port, options = {}) ⇒ VectorBased
constructor
A new instance of VectorBased.
-
#initialize_pattern ⇒ Object
initialize_pattern This method initializes variables at the start of a pattern.
-
#method_missing(m, *args, &block) ⇒ Object
warn but don't fail if an api for another tester is not implmented.
-
#ordered_pins(options = {}) ⇒ Object
ordered_pins(options = {}) expand pin groups to their component pins after the pin ordering is completed OrigenLink always operates on individual pins.
-
#process_response(response, output_file = '') ⇒ Object
process_response This method will process a server response.
-
#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.
-
#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.
-
#push_vector(options) ⇒ Object
push_vector This method intercepts vector data from Origen, removes white spaces and compresses repeats.
-
#synchronize(output_file = '') ⇒ Object
synchronize This method will synchronize the DUT state with Origen.
-
#to_s ⇒ Object
to_s returns 'OrigenLink::VectorBased'.
-
#transaction ⇒ Object
transaction returns true/false indicating whether the transaction passed true = pass false = fail.
-
#wait(options = {}) ⇒ Object
wait a fixed amount of time This method will run the Sleep method to wait rather than generating cycles.
Methods included from ConfigurationCommands
#get_tset_number, #pinformat=, #pinmap=, #pinorder=, #pintiming=, #process_timeset, #replace_tset_name_w_number, #set_pinorder, #tset_argstr_from_events, #tset_warning
Methods included from CaptureSupport
#capture, #store, #store_next_cycle
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
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 |
# File 'lib/origen_link/vector_based.rb', line 52 def initialize(address, port, = {}) @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 = {} @tsets_warned = {} @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 @pattern_link_messages = [] @pattern_comments = {} @user_name = Etc.getlogin @initial_comm_sent = false @initial_vector_pushed = false @pinorder = '' @pinmap_hash = {} @batched_setup_cmds = [] # check the server version against the plug-in version response = send_cmd('version', '') response = 'Error' if response.nil? # prevent run time error in regression tests response.chomp! server_version = response.split(':')[1] server_version = '?.?.? - 0.2.0 or earlier' if response =~ /Error/ app_version = OrigenLink::VERSION # Origen.app(:origen_link).version Origen.log.info("Plug-in link version: #{app_version}, Server link version: #{server_version}") unless app_version == server_version Origen.log.warn('Server version and plug-in link versions do not match') end 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 tester is not implmented
102 103 104 |
# File 'lib/origen_link/vector_based.rb', line 102 def method_missing(m, *args, &block) Origen.log.warn "#{m} is not implemented by origen_link and will be ignored" end |
Instance Attribute Details
#captured_data ⇒ Object (readonly)
Data captured using tester.capture
40 41 42 |
# File 'lib/origen_link/vector_based.rb', line 40 def captured_data @captured_data end |
#comment_batch ⇒ Object (readonly)
Array of comments received through push_comment
46 47 48 |
# File 'lib/origen_link/vector_based.rb', line 46 def comment_batch @comment_batch end |
#fail_count ⇒ Object
The number of cycles that fail
22 23 24 |
# File 'lib/origen_link/vector_based.rb', line 22 def fail_count @fail_count end |
#initial_comm_sent ⇒ Object (readonly)
Indicates that communication has been initiated with the server
50 51 52 |
# File 'lib/origen_link/vector_based.rb', line 50 def initial_comm_sent @initial_comm_sent end |
#store_pins_batch ⇒ Object (readonly)
Used with capture
44 45 46 |
# File 'lib/origen_link/vector_based.rb', line 44 def store_pins_batch @store_pins_batch end |
#total_comm_time ⇒ Object (readonly)
The accumulated total time spent communicating with the server
26 27 28 |
# File 'lib/origen_link/vector_based.rb', line 26 def total_comm_time @total_comm_time end |
#total_connect_time ⇒ Object (readonly)
The accumulated total time spent establishing the server connection
28 29 30 |
# File 'lib/origen_link/vector_based.rb', line 28 def total_connect_time @total_connect_time end |
#total_packets ⇒ Object (readonly)
The accumulated total number of packets sent to the server
34 35 36 |
# File 'lib/origen_link/vector_based.rb', line 34 def total_packets @total_packets end |
#total_recv_time ⇒ Object (readonly)
The accumulated total time spent receiving from the server app
32 33 34 |
# File 'lib/origen_link/vector_based.rb', line 32 def total_recv_time @total_recv_time end |
#total_xmit_time ⇒ Object (readonly)
The accumulated total time spent transmitting to the server app
30 31 32 |
# File 'lib/origen_link/vector_based.rb', line 30 def total_xmit_time @total_xmit_time end |
#tsets_programmed ⇒ Object (readonly)
The look up of programmed tsets. Names are converted to a unique number identifier
38 39 40 |
# File 'lib/origen_link/vector_based.rb', line 38 def tsets_programmed @tsets_programmed end |
#user_name ⇒ Object (readonly)
The name of the user running OrigenLink
48 49 50 |
# File 'lib/origen_link/vector_based.rb', line 48 def user_name @user_name end |
#vector_batch ⇒ Object (readonly)
Array of vectors waiting to be sent to the sever
42 43 44 |
# File 'lib/origen_link/vector_based.rb', line 42 def vector_batch @vector_batch end |
#vector_count ⇒ Object (readonly)
The number of vector cycles generated
24 25 26 |
# File 'lib/origen_link/vector_based.rb', line 24 def vector_count @vector_count end |
#vector_repeatcount ⇒ Object (readonly)
The accumulated number of times push_vector was called with the present tset and pin info
36 37 38 |
# File 'lib/origen_link/vector_based.rb', line 36 def vector_repeatcount @vector_repeatcount end |
Instance Method Details
#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.
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/origen_link/vector_based.rb', line 410 def finalize_pattern(output_file) Origen.log.debug('Pattern generation completed. Sending all stored vector data') synchronize(output_file) send_cmd('', 'session_end') # 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 commands_file = Origen.app.current_job.output_file.split('.')[0] + '_link_cmds.txt' File.open(commands_file, 'w') do |file| file.puts("pin_assign:#{@pinmap}") file.puts("pin_patternorder:#{@pinorder}") @pattern_link_messages.each_index do |index| file.puts(@pattern_link_messages[index]) file.puts(@pattern_comments[index]) if @pattern_comments.key?(index) end file.puts(':session_end') end end |
#fix_ordered_pins(options) ⇒ Object
fix_ordered_pins(options)
This method is called the first time push_vector is called.
This method will create the pinmap from pin meta data if needed.
This method will remove any pin data that doesn't correspond
to a pin in the link pinmap and remove those pins from the
@ordered_pins_cache to prevent them from being rendered
on the next cycle.
This will prevent unwanted behavior. The link server
expects only pin data for pins in the pinmap.
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/origen_link/vector_based.rb', line 168 def fix_ordered_pins() # remove non-mapped pins from the ordered pins cache - prevents them appearing in future push_vector calls orig_size = @ordered_pins_cache.size @ordered_pins_cache.delete_if { |p| !@pinmap_hash[p.name.to_s] } Origen.log.debug('OrigenLink removed non-mapped pins from the cached pin order array') unless orig_size == @ordered_pins_cache.size # update pin values for the current push_vector call vals = [] @ordered_pins_cache.each { |p| vals << p.to_vector } [:pin_vals] = vals.join('') end |
#flush_vector(programmed_data = '', tset = '', local_repeat = 1) ⇒ 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)
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/origen_link/vector_based.rb', line 234 def flush_vector(programmed_data = '', tset = '', local_repeat = 1) # 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 # The hash of programmed tsets does not contain this tset # Check the timing api to see if there is timing info there # and send the timing info to the link server if dut.respond_to?(:timeset) tset_prefix = process_timeset(tset) else tset_warning(tset) tset_prefix = '' end 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 = local_repeat @previous_vectordata = programmed_data @previous_tset = tset end |
#initialize_pattern ⇒ Object
initialize_pattern
This method initializes variables at the start of a pattern.
It is called automatically when pattern generation starts.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'lib/origen_link/vector_based.rb', line 384 def initialize_pattern @fail_count = 0 @vector_count = 0 @vector_batch.delete_if { true } @store_pins_batch.clear @comment_batch.clear @pattern_link_messages.delete_if { true } @pattern_comments.clear @total_packets = 0 @total_comm_time = 0 @total_connect_time = 0 @total_xmit_time = 0 @total_recv_time = 0 # moved to push_vector to allow auto-pinmap # if @pinmap.nil? # Origen.log.error('OrigenLink: pinmap has not been setup, use tester.pinmap= to initialize a pinmap') # else # Origen.log.debug('OrigenLink: executing pattern with pinmap:' + @pinmap.to_s) # end end |
#ordered_pins(options = {}) ⇒ Object
ordered_pins(options = {})
expand pin groups to their component pins after the pin ordering is completed
OrigenLink always operates on individual pins. This saves other methods
from each needing to handle pins and/or groups of pins.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/origen_link/vector_based.rb', line 128 def ordered_pins( = {}) result = super groups = [] result.each { |p| groups << p if p.size > 1 } groups.each do |group| # locate this group in the result array i = result.index(group) result.delete_at(i) dut.pins(group.id).map.each do |sub_pin| result.insert(i, sub_pin) i += 1 end end if @pinmap.nil? # create the pinmap if pin metadata was provided pinarr = [] result.each do |pin| if pin..key?(:link_io) pinarr << pin.name.to_s pinarr << pin.[:link_io].to_s end end self.pinmap = pinarr.join(',') unless pinarr.size == 0 end result 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
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/origen_link/vector_based.rb', line 291 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 == '' # in case there were only comments and no vectors, place comments (if any) microcode @comment_batch[0] if response.size == 0 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 process_vector_response(response[index], output_obj) if @comment_batch.key?(index) if output_file == '' microcode @comment_batch[index] else # get the header placed correctly, the below code doesn't work # if index == response.length - 1 # output_obj.puts 'last comment' # output_obj.lineno = 0 # end output_obj.puts(@comment_batch[index]) end end 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.
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/origen_link/vector_based.rb', line 330 def process_vector_response(vector_response, output_obj = nil) msg = '' unless @store_pins.empty? msg = " (Captured #{@store_pins.map(&:name).join(', ')})\n" capture_data(vector_response) vector_response.strip! # vector_response += msg end vector_cycles = vector_response.split(/\s+/) expected_msg = '' expected_msg = ' ' + vector_cycles.pop if vector_cycles[vector_cycles.length - 1] =~ /Expected/ pfstatus = vector_cycles[0].chr vector_cycles[0] = vector_cycles[0].byteslice(2, vector_cycles[0].length - 2) vector_cycles.each do |cycle| thiscyclefail = false bad_pin_data = false if pfstatus == 'F' # check to see if this cycle failed 0.upto(cycle.length - 1) do |index| bad_pin_data = true if (cycle[index] == 'W') thiscyclefail = true if (cycle[index] == 'H') && (expected_msg[expected_msg.length - cycle.length + index] == 'L') thiscyclefail = true if (cycle[index] == 'L') && (expected_msg[expected_msg.length - cycle.length + index] == 'H') end end if thiscyclefail expected_msg_prnt = expected_msg prepend = 'F:' else expected_msg_prnt = '' prepend = 'P:' end if bad_pin_data expected_msg_prnt = ' ' + 'W indicates no operation, check timeset definition' prepend = 'F:' end if output_obj.nil? microcode prepend + cycle + expected_msg_prnt + msg else output_obj.puts(prepend + cycle + expected_msg_prnt + msg) end 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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/origen_link/vector_based.rb', line 109 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 pattern_key = @pattern_link_messages.length + key @pattern_comments[pattern_key] = @comment_batch[key] else microcode msg end end |
#push_vector(options) ⇒ Object
push_vector
This method intercepts vector data from Origen, removes white spaces and compresses repeats
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 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/origen_link/vector_based.rb', line 182 def push_vector() unless @initial_vector_pushed if @pinmap.nil? Origen.log.error('OrigenLink: pinmap has not been setup, use tester.pinmap= to initialize a pinmap') else Origen.log.debug('OrigenLink: executing pattern with pinmap:' + @pinmap.to_s) end # remove pins not in the link pinmap = fix_ordered_pins() # now send any configuration commands that were saved prior to pinmap setup (clears all server configs) @batched_setup_cmds.each do |cmd| response = send_cmd(cmd[0], cmd[1]) setup_cmd_response_logger(cmd[0], response) end @initial_vector_pushed = true end set_pinorder if @pinorder == '' programmed_data = [:pin_vals].gsub(/\s+/, '') unless [: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 = [:timeset].name local_repeat = [:repeat].nil? ? 1 : [:repeat] if @vector_count > 0 # compressing repeats as we go if (programmed_data == @previous_vectordata) && (@previous_tset == tset) && @store_pins.empty? @vector_repeatcount += local_repeat 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, local_repeat) 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 |
#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
278 279 280 281 282 283 284 285 286 |
# File 'lib/origen_link/vector_based.rb', line 278 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_s ⇒ Object
to_s
returns 'OrigenLink::VectorBased'
No longer a use for this. Use tester.link?
450 451 452 |
# File 'lib/origen_link/vector_based.rb', line 450 def to_s 'OrigenLink::VectorBased' end |
#transaction ⇒ Object
transaction
returns true/false indicating whether the transaction passed
true = pass
false = fail
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
# File 'lib/origen_link/vector_based.rb', line 463 def transaction if block_given? synchronize transaction_fail_count = @fail_count yield synchronize transaction_fail_count = @fail_count - transaction_fail_count if transaction_fail_count == 0 true else false end else true end end |
#wait(options = {}) ⇒ Object
wait a fixed amount of time
This method will run the Sleep method to wait rather than generating cycles.
Cycle execution time is not predictable with OrigenLink.
If you want cycles to be generated by this method include apply_cycles: true
in the options hash
This method currently doesn't handle match blocks.
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/origen_link/vector_based.rb', line 488 def wait( = {}) = { cycles: 0, time_in_cycles: 0, time_in_us: 0, time_in_ns: 0, time_in_ms: 0, time_in_s: 0, match: false, # Set to true to invoke a match loop where the supplied delay apply_cycles: false # will become the timeout duration }.merge() fail 'wait(match: true) is not yet implemented on Link' if [:match] time_delay = 0 time_delay += ([:time_in_s]) time_delay += ([:time_in_ms]) * 0.001 time_delay += ([:time_in_us]) * 0.000001 time_delay += ([:time_in_ns]) * 0.000000001 time_delay += ([:cycles] + [:time_in_cycles]) * current_period_in_ns * 0.000000001 if [:apply_cycles] cycles = time_delay / 0.00003 # cycle execution time is unpredictable, but ~= 30us if [:cycles] > 0 || [:time_in_cycles] > 0 [:repeat] = [:cycles] + [:time_in_cycles] else [:repeat] = (cycles > 0) ? cycles : 1 end cycle() else synchronize # ensure all generated cycles are executed before delay is run sleep time_delay end end |