origen_std_lib 0.10.1 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +5 -5
  2. data/config/application.rb +7 -19
  3. data/config/commands.rb +9 -0
  4. data/config/version.rb +1 -2
  5. data/lib/origen_std_lib/v93k.rb +17 -1
  6. data/{stdlib/v93k → src/advantest/smt7}/origen/.cproject +0 -0
  7. data/{stdlib/v93k → src/advantest/smt7}/origen/.project +0 -0
  8. data/src/advantest/smt7/origen/origen/helpers/console.cpp +94 -0
  9. data/src/advantest/smt7/origen/origen/helpers/misc.cpp +456 -0
  10. data/src/advantest/smt7/origen/origen/helpers/time.cpp +64 -0
  11. data/{stdlib/v93k → src/advantest/smt7}/origen/origen/helpers.hpp +25 -8
  12. data/src/advantest/smt7/origen/origen/site.cpp +237 -0
  13. data/src/advantest/smt7/origen/origen/site.hpp +50 -0
  14. data/src/advantest/smt7/origen/origen/test_method/base.cpp +231 -0
  15. data/src/advantest/smt7/origen/origen/test_method/base.hpp +155 -0
  16. data/src/advantest/smt7/origen/origen/test_method/dc_measurement.cpp +266 -0
  17. data/src/advantest/smt7/origen/origen/test_method/dc_measurement.hpp +58 -0
  18. data/src/advantest/smt7/origen/origen/test_method/empty.cpp +13 -0
  19. data/src/advantest/smt7/origen/origen/test_method/empty.hpp +24 -0
  20. data/src/advantest/smt7/origen/origen/test_method/frequency_measurement.cpp +133 -0
  21. data/src/advantest/smt7/origen/origen/test_method/frequency_measurement.hpp +46 -0
  22. data/src/advantest/smt7/origen/origen/test_method/functional_test.cpp +168 -0
  23. data/src/advantest/smt7/origen/origen/test_method/functional_test.hpp +53 -0
  24. data/{stdlib/v93k → src/advantest/smt7}/origen/origen/test_method.hpp +1 -3
  25. data/src/advantest/smt7/origen/origen/utils/version.cpp +72 -0
  26. data/{stdlib/v93k → src/advantest/smt7}/origen/origen/utils/version.hpp +20 -21
  27. data/{stdlib/v93k → src/advantest/smt7}/origen/origen/utils.hpp +1 -3
  28. data/src/advantest/smt7/origen/origen.cpp +18 -0
  29. data/{stdlib/v93k → src/advantest/smt7}/origen/origen.hpp +3 -3
  30. data/src/advantest/smt7/origen/test_methods/ApplyBin.cpp +37 -0
  31. data/src/advantest/smt7/origen/test_methods/DCMeasurement.cpp +90 -0
  32. data/src/advantest/smt7/origen/test_methods/FrequencyMeasurement.cpp +50 -0
  33. data/src/advantest/smt7/origen/test_methods/FunctionalTest.cpp +24 -0
  34. data/src/advantest/smt7/origen/test_methods/RecordBin.cpp +39 -0
  35. data/src/advantest/smt8/origen/common/Origen.java +334 -0
  36. data/src/advantest/smt8/origen/common/OrigenData.java +391 -0
  37. data/src/advantest/smt8/origen/common/OrigenHelpers.java +170 -0
  38. data/src/advantest/smt8/origen/test_methods/Base.java +265 -0
  39. data/src/advantest/smt8/origen/test_methods/DC_Measurement.java +302 -0
  40. data/src/advantest/smt8/origen/test_methods/Empty.java +12 -0
  41. data/src/advantest/smt8/origen/test_methods/Functional_test.java +474 -0
  42. data/templates/web/faq.md.erb +1 -52
  43. data/templates/web/guides/intro.md.erb +8 -0
  44. data/templates/web/guides/{v93k/intro.md.erb → v93ksmt7/capture.md.erb} +0 -2
  45. data/templates/web/guides/v93ksmt7/complete.md.erb +68 -0
  46. data/templates/web/guides/v93ksmt7/customizable.md.erb +139 -0
  47. data/templates/web/guides/v93ksmt7/helpers.md.erb +3 -0
  48. data/templates/web/guides/{v93k → v93ksmt7}/install.md.erb +1 -1
  49. data/templates/web/guides/v93ksmt7/integration.md.erb +3 -0
  50. data/templates/web/guides/v93ksmt7/intro.md.erb +8 -0
  51. data/templates/web/guides/v93ksmt7/patching.md.erb +3 -0
  52. data/templates/web/guides/v93ksmt8/intro.md.erb +9 -0
  53. data/templates/web/index.md.erb +23 -6
  54. data/templates/web/layouts/_guides.html.erb +15 -3
  55. data/templates/web/partials/_common_args.md.erb +13 -0
  56. data/templates/web/partials/_navbar.html.erb +2 -2
  57. metadata +52 -33
  58. data/stdlib/v93k/origen/origen/helpers/console.cpp +0 -105
  59. data/stdlib/v93k/origen/origen/helpers/misc.cpp +0 -311
  60. data/stdlib/v93k/origen/origen/site.cpp +0 -220
  61. data/stdlib/v93k/origen/origen/site.hpp +0 -51
  62. data/stdlib/v93k/origen/origen/test_method/base.hpp +0 -156
  63. data/stdlib/v93k/origen/origen/test_method/dc_measurement.cpp +0 -182
  64. data/stdlib/v93k/origen/origen/test_method/dc_measurement.hpp +0 -59
  65. data/stdlib/v93k/origen/origen/test_method/frequency_measurement.cpp +0 -107
  66. data/stdlib/v93k/origen/origen/test_method/frequency_measurement.hpp +0 -48
  67. data/stdlib/v93k/origen/origen/test_method/functional_test.cpp +0 -125
  68. data/stdlib/v93k/origen/origen/test_method/functional_test.hpp +0 -52
  69. data/stdlib/v93k/origen/origen/utils/version.cpp +0 -79
  70. data/stdlib/v93k/origen/origen.cpp +0 -22
  71. data/stdlib/v93k/origen/test_methods/ApplyBin.cpp +0 -41
  72. data/stdlib/v93k/origen/test_methods/DCMeasurement.cpp +0 -129
  73. data/stdlib/v93k/origen/test_methods/FrequencyMeasurement.cpp +0 -93
  74. data/stdlib/v93k/origen/test_methods/FunctionalTest.cpp +0 -94
  75. data/stdlib/v93k/origen/test_methods/RecordBin.cpp +0 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dd44b59165d2858a2815a5832f57d1e7de6ad1de
4
- data.tar.gz: 50187101839fa15185b1748eeb759686bc97ef9b
2
+ SHA256:
3
+ metadata.gz: b50775e883ea0eb88f73e00399885df3ff2f0f4ffb814bc18343250d923ab8c5
4
+ data.tar.gz: c8c6156186787db0f506b2dc82dfd453f45f721ffbdf3faf4254173c84a3d424
5
5
  SHA512:
6
- metadata.gz: 7ad40452b888b58b6f5fbe9dea02f0a1481796fafb3bba95583a59f453a797677a9b4f10ace16598d479bc91fb1eb8a32a26cfb5b1dbd75fc91c4a89e5f1e2b9
7
- data.tar.gz: 5c47e013d181e7b0b8df91a242b056d0bd315530327fc11c59543138ce4767d9e749fe1af458e3ac9d614e066bb8d64ff010f479a2726820c2cc6d1d59dc6cf6
6
+ metadata.gz: 06170b58cc9e6e950a4e11c41073f71ff99d5490a571aa77b4804636c38a87b7445b5cf439aed5b1f3e3503f4fb9dbef8759a153443b98f2b3c68c1da4bd8c83
7
+ data.tar.gz: 0d2707f492585357c107496fa6dad90227a00ff9853926da843d25aa5c684ec29337e373a495eda0fc58ae17b0997c2ffee91694944f72e943531d8a58f9502d
@@ -38,29 +38,18 @@ class OrigenStdLibApplication < Origen::Application
38
38
 
39
39
  config.semantically_version = true
40
40
 
41
- # Copy the std lib into the app area for inclusion in the gem package
42
41
  def before_release_gem
43
- d = "#{Origen.root}/stdlib/v93k"
44
- FileUtils.rm_rf(d) if File.exist?(d)
45
- FileUtils.mkdir_p(d)
46
42
  # Remove all untracked files, e.g. compiled binaries
47
- system "git clean -f -d -x #{Origen.root}/../v93k"
48
- system "git clean -f -d #{Origen.root}/../v93k"
49
- FileUtils.cp_r("#{Origen.root}/../v93k/src/origen", d)
50
- end
51
-
52
- # Get rid of the local std lib copy after building
53
- def after_release_gem
54
- FileUtils.rm_rf "#{Origen.root}/stdlib"
43
+ system "git clean -f -d -x #{Origen.root}/src"
44
+ system "git clean -f -d #{Origen.root}/src"
55
45
  end
56
46
 
57
47
  def after_web_site_compile(options={})
58
48
  if options[:api]
59
- Dir.chdir "#{Origen.app.rc.root}/v93k" do
60
- system "doxygen .doxygen"
61
- d = "#{Origen.root}/web/output"
62
- FileUtils.mkdir_p(d)
63
- FileUtils.mv "html", "#{d}/v93k"
49
+ f = Origen.root.join "web", "output", "v93k_smt7"
50
+ FileUtils.mkdir_p(f)
51
+ Dir.chdir Origen.root.join "src", "advantest", "smt7", "origen" do
52
+ system "doxygen #{Origen.root.join('config', 'doxygen', 'v93k_smt7')}"
64
53
  end
65
54
  end
66
55
  end
@@ -92,7 +81,7 @@ class OrigenStdLibApplication < Origen::Application
92
81
  def before_release_tag(identifier, note, type, selector, options)
93
82
  v = Origen::VersionString.new(identifier)
94
83
  # Update the version in the C code
95
- f = "#{Origen.app.rc.root}/v93k/src/origen/origen.hpp"
84
+ f = File.join(Origen.root, "src", "advantest", "smt7", "origen", "origen.hpp")
96
85
  data = File.read(f)
97
86
  filtered_data = data.sub(/#define ORIGEN_VERSION \"\d+\.\d+\.\d+\"/, "#define ORIGEN_VERSION \"#{v}\"")
98
87
  File.open(f, "w") do |f|
@@ -138,5 +127,4 @@ class OrigenStdLibApplication < Origen::Application
138
127
  #config.pattern_name_translator do |name|
139
128
  # name.gsub(/_b\d/, "_bx")
140
129
  #end
141
-
142
130
  end
data/config/commands.rb CHANGED
@@ -13,6 +13,14 @@ aliases ={
13
13
  # Now branch to the specific task code
14
14
  case @command
15
15
 
16
+ when "format"
17
+ Dir.glob("#{Origen.root}/src/**/*.{cpp,hpp}").each do |f|
18
+ system "clang-format -i #{f}"
19
+ end
20
+ java_files = Dir.glob("#{Origen.root}/src/**/*.java")
21
+ system "java -jar vendor/google-java-format-1.7-all-deps.jar --replace #{java_files.join(' ')}"
22
+ exit 0
23
+
16
24
  ## Example of how to make a command to run unit tests, this simply invokes RSpec on
17
25
  ## the spec directory
18
26
  #when "specs"
@@ -55,6 +63,7 @@ else
55
63
  # before handing control back to Origen. Un-comment the example below to get started.
56
64
  @application_commands = <<-EOT
57
65
  examples Run the examples (tests), -c will enable coverage
66
+ format Format/prettify the library source files (requires clang-format and java to be available)
58
67
  EOT
59
68
 
60
69
  end
data/config/version.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  module OrigenStdLib
2
2
  MAJOR = 0
3
- MINOR = 10
3
+ MINOR = 13
4
4
  BUGFIX = 1
5
5
  DEV = nil
6
-
7
6
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
8
7
  end
@@ -4,6 +4,11 @@ module OrigenStdLib
4
4
  class_name: 'origen',
5
5
 
6
6
  functional_test: {
7
+ port: [:string, ''],
8
+ test_name: [:string, ''],
9
+ force_pass: [:boolean, false],
10
+ on_pass_flag: [:string, ''],
11
+ on_fail_flag: [:string, '']
7
12
  },
8
13
 
9
14
  dc_measurement: {
@@ -15,9 +20,15 @@ module OrigenStdLib
15
20
  measure: [:string, 'VOLT', %w(VOLT CURR v i voltage current)],
16
21
  settling_time: [:double, 0],
17
22
  pin: [:string, nil],
23
+ port: [:string, ''],
18
24
  force_value: [:double, 0],
19
25
  i_range: [:integer, nil],
20
26
  badc: [:integer, 0],
27
+ test_name: [:string, ''],
28
+ force_pass: [:boolean, false],
29
+ on_pass_flag: [:string, ''],
30
+ on_fail_flag: [:string, ''],
31
+
21
32
  methods: {
22
33
  finalize: lambda do |tm|
23
34
  # Clean up the measurement type parameter
@@ -40,8 +51,13 @@ module OrigenStdLib
40
51
  frequency_measurement: {
41
52
  period_based: [:integer, 0],
42
53
  pin: [:string, nil],
54
+ port: [:string, ''],
43
55
  samples: [:integer, 2000],
44
- period_in_ns: [:integer, nil]
56
+ period_in_ns: [:integer, nil],
57
+ test_name: [:string, ''],
58
+ force_pass: [:boolean, false],
59
+ on_pass_flag: [:string, ''],
60
+ on_fail_flag: [:string, '']
45
61
  },
46
62
 
47
63
  record_bin: {
File without changes
@@ -0,0 +1,94 @@
1
+ /** @file */
2
+ #include "../helpers.hpp"
3
+
4
+ namespace Origen {
5
+
6
+ /// Prints the result of a parametric test to the console
7
+ void logParametricTest(string name, int site, double result, LIMIT limits,
8
+ string pin) {
9
+ cout << site << " ";
10
+ if (isPass(result, limits))
11
+ cout << " ";
12
+ else
13
+ cout << "FAIL ";
14
+ cout << left << setw(65) << setfill(' ') << name << " ";
15
+ cout << left << setw(20) << setfill(' ') << loStr(limits) << " ";
16
+ cout << left << setw(20) << setfill(' ') << result;
17
+ cout << left << setw(20) << setfill(' ') << hiStr(limits);
18
+ cout << pin << endl;
19
+ }
20
+
21
+ /// Returns a LIMIT object with no limits enabled
22
+ LIMIT noLimits() { return LIMIT(TM::NA, 0, TM::NA, 0); }
23
+
24
+ /// Prints the result of a functional test to the console
25
+ void logFunctionalTest(string name, int site, bool passed, string pattern) {
26
+ cout << site << " ";
27
+ if (passed)
28
+ cout << " ";
29
+ else
30
+ cout << "FAIL ";
31
+ cout << left << setw(65) << setfill(' ') << name << " ";
32
+ cout << pattern << endl;
33
+ }
34
+
35
+ /// Converts the low limit in the given LIMIT object into a string, where an
36
+ /// empty string will be returned if the limit is not enabled
37
+ string loStr(LIMIT limits) {
38
+ double lo = 0.0;
39
+ double* plo = &lo;
40
+ TM::COMPARE clo;
41
+
42
+ clo = limits.getLow(plo);
43
+
44
+ if (clo == TM::NA) {
45
+ return "";
46
+ } else {
47
+ stringstream val;
48
+ val << lo;
49
+ return val.str();
50
+ }
51
+ }
52
+
53
+ /// Converts the high limit in the given LIMIT object into a string, where an
54
+ /// empty string will be returned if the limit is not enabled
55
+ string hiStr(LIMIT limits) {
56
+ double hi = 0.0;
57
+ double* phi = &hi;
58
+ TM::COMPARE chi;
59
+
60
+ chi = limits.getHigh(phi);
61
+
62
+ if (chi == TM::NA) {
63
+ return "";
64
+ } else {
65
+ stringstream val;
66
+ val << hi;
67
+ return val.str();
68
+ }
69
+ }
70
+ /// Returns true if the result is within the given limits
71
+ bool isPass(double val, LIMIT limits) {
72
+ double lo = 0.0;
73
+ double hi = 0.0;
74
+ double* plo = &lo;
75
+ double* phi = &hi;
76
+ TM::COMPARE clo, chi;
77
+ bool result;
78
+
79
+ clo = limits.getLow(plo);
80
+ chi = limits.getHigh(phi);
81
+
82
+ result = true;
83
+
84
+ if (clo != TM::NA) {
85
+ if (clo == TM::GE && val < lo) result = false;
86
+ if (clo == TM::GT && val <= lo) result = false;
87
+ }
88
+ if (chi != TM::NA) {
89
+ if (chi == TM::LE && val > hi) result = false;
90
+ if (chi == TM::LT && val >= hi) result = false;
91
+ }
92
+ return result;
93
+ }
94
+ }
@@ -0,0 +1,456 @@
1
+ /** @file */
2
+ #include "../helpers.hpp"
3
+
4
+ using namespace std;
5
+
6
+ namespace Origen {
7
+
8
+ uint64_t flip(uint64_t input, int size) {
9
+ uint64_t output = 0;
10
+ for (int i = 0; i < size; i++) {
11
+ output <<= 1;
12
+ output |= input & 1;
13
+ input >>= 1;
14
+ }
15
+ return output;
16
+ }
17
+
18
+ /// Split the given string by the given delimiter and return the results in a
19
+ /// vector of strings
20
+ ///
21
+ /// split("AB1234-24", '-') // => ["AB1234", "24"]
22
+ vector<string> split(const string &str, char delim) {
23
+ vector<string> elems;
24
+ split(str, delim, elems);
25
+ return elems;
26
+ }
27
+
28
+ /// This version places the result in the supplied vector rather than returning
29
+ /// a new one
30
+ void split(const string &str, char delim, vector<string> &elems) {
31
+ stringstream ss;
32
+ ss.str(str);
33
+ string item;
34
+ while (getline(ss, item, delim)) {
35
+ elems.push_back(item);
36
+ }
37
+ }
38
+
39
+ ///
40
+ string ltrim(string str, const char *remove_chars /* = " \n\t\r\f\v" */) {
41
+ str.erase(0, str.find_first_not_of(remove_chars));
42
+ return str;
43
+ }
44
+
45
+ string rtrim(string str, const char *remove_chars /* = " \n\t\r\f\v" */) {
46
+ str.erase(str.find_last_not_of(remove_chars) + 1);
47
+ return str;
48
+ }
49
+
50
+ string trim(string str, const char *remove_chars /* = " \n\t\r\f\v" */) {
51
+ str = rtrim(str, remove_chars);
52
+ str = ltrim(str, remove_chars);
53
+ return str;
54
+ }
55
+
56
+ /// Convert the given string to a 64-bit integer. Works for both decimal and hex
57
+ /// strings as
58
+ /// shown in the examples below.
59
+ ///
60
+ /// If the string is not successfully converted the site in focus will be binned
61
+ /// out.
62
+ ///
63
+ /// toInt("0xFF") // => 255
64
+ /// toInt("FF", 16) // => 255 (must declare base 16 if no leading 0x)
65
+ /// toInt("255") // => 255
66
+ int64_t toInt(string str, int base) {
67
+ str = trim(str); // Remove any whitespace
68
+ str = ltrim(str, "0"); // Remove any leading 0's
69
+ if (str == "") {
70
+ return 0;
71
+ }
72
+ char *end;
73
+ char *cstr = const_cast<char *>(str.c_str());
74
+ long long int l;
75
+ errno = 0;
76
+ l = strtoll(cstr, &end, base);
77
+ if ((errno == ERANGE && l == LLONG_MAX) || l > LLONG_MAX) {
78
+ cout << "ERROR: String conversion overflowed a 64-bit integer - " << str
79
+ << endl;
80
+ ERROR_EXIT(TM::EXIT_FLOW);
81
+ }
82
+ if ((errno == ERANGE && l == LLONG_MIN) || l < LLONG_MIN) {
83
+ cout << "ERROR: String conversion underflowed a 64-bit integer - " << str
84
+ << endl;
85
+ ERROR_EXIT(TM::EXIT_FLOW);
86
+ }
87
+ if (*cstr == '\0' || *end != '\0') {
88
+ cout << "ERROR: String is not convertible to a 64-bit integer - " << str
89
+ << endl;
90
+ ERROR_EXIT(TM::EXIT_FLOW);
91
+ }
92
+ return (int64_t)l;
93
+ }
94
+
95
+ /// See toInt, but returns an unsigned 64-bit integer
96
+ uint64_t toUInt(string str, int base) {
97
+ str = trim(str); // Remove any whitespace
98
+ str = ltrim(str, "0"); // Remove any leading 0's
99
+ if (str == "") {
100
+ return 0;
101
+ }
102
+
103
+ char *end;
104
+ char *cstr = const_cast<char *>(str.c_str());
105
+ unsigned long long int l;
106
+ errno = 0;
107
+ l = strtoull(cstr, &end, base);
108
+ if (errno == ERANGE && l == ULLONG_MAX) {
109
+ cout << "ERROR: String conversion was out of the range of a UInt64 - "
110
+ << str << endl;
111
+ ERROR_EXIT(TM::EXIT_FLOW);
112
+ }
113
+ if (*cstr == '\0' || *end != '\0') {
114
+ cout << "ERROR: String is not convertible to a UInt64 - " << str << endl;
115
+ ERROR_EXIT(TM::EXIT_FLOW);
116
+ }
117
+ return (uint64_t)l;
118
+ }
119
+
120
+ /// Convert the given number to a hex string
121
+ ///
122
+ /// toHex(255); // => "ff"
123
+ string toHex(const uint64_t &val) {
124
+ stringstream stream;
125
+ stream << hex << val;
126
+ return stream.str();
127
+ }
128
+
129
+ /// Convert the given number to a string
130
+ ///
131
+ /// toStr(255); // => "255"
132
+ string toStr(const uint64_t &val) {
133
+ stringstream stream;
134
+ stream << val;
135
+ return stream.str();
136
+ }
137
+
138
+ /// Uppercase the given string
139
+ ///
140
+ /// upcase("ff"); // => "FF"
141
+ string upcase(string base) {
142
+ transform(base.begin(), base.end(), base.begin(), ::toupper);
143
+ return base;
144
+ }
145
+
146
+ /// Lowercase the given string
147
+ ///
148
+ /// downcase("FF"); // => "ff"
149
+ string downcase(string base) {
150
+ transform(base.begin(), base.end(), base.begin(), ::tolower);
151
+ return base;
152
+ }
153
+
154
+ /// Extend the string to the given size, padding with the given character on the
155
+ /// left
156
+ ///
157
+ /// lpad("FF", 4, '0'); // => "00FF"
158
+ string lpad(string base, int length, char fill) {
159
+ stringstream padded;
160
+ padded << right << setw(length) << setfill(fill) << base;
161
+ return padded.str();
162
+ }
163
+
164
+ /// Extend the string to the given size, padding with the given character on the
165
+ /// right
166
+ ///
167
+ /// rpad("FF", 4, ' '); // => "FF "
168
+ string rpad(string base, int length, char fill) {
169
+ stringstream padded;
170
+ padded << left << setw(length) << setfill(fill) << base;
171
+ return padded.str();
172
+ }
173
+
174
+ /// Returns true if the given number is even
175
+ bool isEven(uint64_t number) { return number % 2 == 0; }
176
+
177
+ /// Returns true if the given number is odd
178
+ bool isOdd(uint64_t number) { return number % 2 != 0; }
179
+
180
+ /// Overlays the given data on the given pin, starting from the first vector of
181
+ /// the given pattern
182
+ /// must provide the waveform indices used for output high and low
183
+ void overlaySubroutineOutput(string subroutinePattern, string pin,
184
+ uint64_t data, int size, int loOutputIndex,
185
+ int hiOutputIndex) {
186
+ string p = extractPinsFromGroup(pin);
187
+ // string pat = getTdiLabelName(subroutinePattern);
188
+ string pat = subroutinePattern;
189
+ VEC_LABEL_EDIT ov(pat, p);
190
+
191
+ // Need to use a vector here so the size can be determined at runtime
192
+ vector<VECTOR_DATA> vecData(size);
193
+
194
+ for (int i = 0; i < size; i++) {
195
+ int val = (data & (1 << i)) >> i;
196
+ if (val == 1)
197
+ val = hiOutputIndex;
198
+ else
199
+ val = loOutputIndex;
200
+ VECTOR_DATA v = {i, val};
201
+ vecData[i] = v;
202
+ }
203
+
204
+ // However the downloadUserVectors function only accepts an array, so use this
205
+ // trick
206
+ // to create an array instance that points to the vector data
207
+ VECTOR_DATA *vecDataArray = &vecData[0];
208
+
209
+ ov.downloadUserVectors(vecDataArray, size);
210
+ }
211
+
212
+ /// Overlays the given data on the given pin, starting from the first vector of
213
+ /// the given pattern
214
+ void overlaySubroutine(string subroutinePattern, string pin, uint64_t data,
215
+ int size) {
216
+ string p = extractPinsFromGroup(pin);
217
+ string pat = subroutinePattern;
218
+ VEC_LABEL_EDIT ov(pat, p);
219
+
220
+ // Need to use a vector here so the size can be determined at runtime
221
+ vector<VECTOR_DATA> vecData(size);
222
+
223
+ for (int i = 0; i < size; i++) {
224
+ int val = (data & (1 << i)) >> i;
225
+ VECTOR_DATA v = {i, val};
226
+ vecData[i] = v;
227
+ }
228
+
229
+ // However the downloadUserVectors function only accepts an array, so use this
230
+ // trick
231
+ // to create an array instance that points to the vector data
232
+ VECTOR_DATA *vecDataArray = &vecData[0];
233
+
234
+ ov.downloadUserVectors(vecDataArray, size);
235
+ }
236
+
237
+ /// Same as overlaySubroutine but the data is applied in reverse order
238
+ void reverseOverlaySubroutine(string subroutinePattern, string pin,
239
+ uint64_t data, int size) {
240
+ string p = extractPinsFromGroup(pin);
241
+ string pat = subroutinePattern;
242
+ VEC_LABEL_EDIT ov(pat, p);
243
+
244
+ // Need to use a vector here so the size can be determined at runtime
245
+ vector<VECTOR_DATA> vecData(size);
246
+
247
+ for (int i = 0; i < size; i++) {
248
+ int j = size - 1 - i;
249
+ int val = (data & (1 << j)) >> j;
250
+ VECTOR_DATA v = {i, val};
251
+ vecData[i] = v;
252
+ }
253
+
254
+ // However the downloadUserVectors function only accepts an array, so use this
255
+ // trick
256
+ // to create an array instance that points to the vector data
257
+ VECTOR_DATA *vecDataArray = &vecData[0];
258
+
259
+ ov.downloadUserVectors(vecDataArray, size);
260
+ }
261
+
262
+ /// Returns the number of 1's (bits that are set) in the given 32-bit number
263
+ int numberOfOnes(uint32_t i) {
264
+ i = i - ((i >> 1) & 0x55555555);
265
+ i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
266
+ return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
267
+ }
268
+
269
+ /// Returns the number of 0's (bits that are not set) in the given 32-bit number
270
+ int numberOfZeros(uint32_t i) { return 32 - numberOfOnes(i); }
271
+
272
+ double calculateFrequency(const ARRAY_I &captureData, double periodInNs) {
273
+ int iFreqCount;
274
+ double dFreq_MHz;
275
+
276
+ iFreqCount = 0;
277
+ for (int j = 0; j < captureData.size() - 1; j++) {
278
+ if ((captureData[j + 1] - captureData[j]) == 1) {
279
+ iFreqCount++;
280
+ }
281
+ }
282
+ dFreq_MHz = iFreqCount / ((periodInNs / 1000) * captureData.size());
283
+ return dFreq_MHz * 1000000;
284
+ }
285
+
286
+ double calculatePeriod(const ARRAY_I &captureData, double periodInNs) {
287
+ return 1 / calculateFrequency(captureData, periodInNs);
288
+ }
289
+
290
+ /// Call to wait for all SMC threads to complete, supply the max amount of
291
+ /// seconds to wait
292
+ void synchronize(double timeout) {
293
+ bool ok;
294
+ int site = CURRENT_SITE_NUMBER();
295
+
296
+ if (timeout) {
297
+ ok = SMC_SYNCHRONIZE(timeout s);
298
+ } else {
299
+ ok = SMC_SYNCHRONIZE();
300
+ }
301
+
302
+ if (!ok) {
303
+ cout << "ERROR: All SMC threads not complete after " << timeout
304
+ << " second(s) on site " << site << endl;
305
+ ERROR_EXIT(TM::EXIT_FLOW);
306
+ }
307
+ }
308
+
309
+ // Check to see if a pin exists in current pin config
310
+ bool pinExists(const string &pinName) {
311
+ stringstream fw_command;
312
+ string fw_answer;
313
+ bool result;
314
+
315
+ fw_command << "dfpn? (" << pinName << ")" << endl;
316
+
317
+ FW_TASK(fw_command.str(), fw_answer);
318
+ fw_command.str(std::string());
319
+
320
+ result = !(fw_answer.empty());
321
+ return result;
322
+ }
323
+
324
+ /// Supply a pin alias name and get the name of the physical pin returned
325
+ string extractPinsFromGroup(const string &groupname) {
326
+ string pinlist;
327
+
328
+ try {
329
+ pinlist = PinUtility.createPinListFromPinNames(
330
+ PinUtility.getDigitalPinNamesFromPinList(
331
+ groupname, TM::ALL_DIGITAL, true, true,
332
+ PIN_UTILITY::DEFINITION_ORDER));
333
+ } catch (...) {
334
+ cout << "ERROR: Pingroup " << groupname << " not found." << endl;
335
+ ERROR_EXIT(TM::ABORT_FLOW);
336
+ }
337
+
338
+ return pinlist;
339
+ }
340
+
341
+ // Initializes the site objects that are used to store the ECID, this should be
342
+ // called at
343
+ // the start of the test flow if using the Origen.site API
344
+ void initializeSites() {
345
+ INT num_of_sites;
346
+ ARRAY_I sites;
347
+
348
+ ON_FIRST_INVOCATION_BEGIN();
349
+
350
+ num_of_sites = GET_CONFIGURED_SITES(sites);
351
+
352
+ // Leave an empty space at 0, easier then to fetch by site number (which start
353
+ // at 1)
354
+ Origen::Sites.resize(num_of_sites + 1, Origen::Site(0));
355
+
356
+ Origen::Time::initTime(); // take snapshot of current time for later use
357
+
358
+ ON_FIRST_INVOCATION_END();
359
+
360
+ // Instantiate a new site object and save it in the global site array
361
+ Origen::Site site(CURRENT_SITE_NUMBER());
362
+
363
+ Origen::Sites[CURRENT_SITE_NUMBER()] = site;
364
+ }
365
+
366
+ double getUnitMultiplier(const string &units) {
367
+ double mult;
368
+
369
+ if (units.find("nA") != string::npos) {
370
+ mult = 1e9;
371
+ } else if (units.find("uA") != string::npos) {
372
+ mult = 1e6;
373
+ } else if (units.find("mA") != string::npos) {
374
+ mult = 1e3;
375
+ } else if (units.find("A") != string::npos) {
376
+ mult = 1;
377
+ } else if (units.find("nV") != string::npos) {
378
+ mult = 1e9;
379
+ } else if (units.find("uV") != string::npos) {
380
+ mult = 1e6;
381
+ } else if (units.find("mV") != string::npos) {
382
+ mult = 1e3;
383
+ } else if (units.find("V") != string::npos) {
384
+ mult = 1;
385
+ } else if (units.find("Kohm") != string::npos) {
386
+ mult = 1e-3;
387
+ } else if (units.find("ns") != string::npos) {
388
+ mult = 1e9;
389
+ } else if (units.find("us") != string::npos) {
390
+ mult = 1e6;
391
+ } else if (units.find("ms") != string::npos) {
392
+ mult = 1e3;
393
+ } else if (units.find("s") != string::npos) {
394
+ mult = 1;
395
+ } else if (units.find("KHz") != string::npos) {
396
+ mult = 1e-3;
397
+ } else if (units.find("MHz") != string::npos) {
398
+ mult = 1e-6;
399
+ } else {
400
+ mult = 1;
401
+ }
402
+
403
+ return mult;
404
+ }
405
+
406
+ string getLabelFromBurst(const string &burst, const string &port) {
407
+ ////////////////////////////////////////////////////////////////////
408
+ // Note this function will always return the first label in a burst
409
+ ////////////////////////////////////////////////////////////////////
410
+ string answer;
411
+ stringstream ss;
412
+
413
+ ss << "sqpg? \"" << burst << "\",(" << port << ")" << endl;
414
+
415
+ FW_TASK(ss.str(), answer);
416
+
417
+ ss.str("");
418
+
419
+ int fc = answer.find_first_of("\"") + 1;
420
+ int len = answer.find_last_of("\"") - fc;
421
+
422
+ return (answer.substr(fc, len));
423
+ }
424
+
425
+ string checksum16bits(const string &mystring) {
426
+ long flag;
427
+ long poly = 0xa001;
428
+ long crc = 0xffff;
429
+ string crc16;
430
+
431
+ vector<char> ch(mystring.begin(), mystring.end());
432
+
433
+ for (unsigned int i = 0; i < ch.size(); i++) {
434
+ crc ^= static_cast<int>(ch[i]);
435
+
436
+ for (unsigned int j = 0; j < 8; j++) {
437
+ flag = crc & long(0x1);
438
+ crc /= long(0x2);
439
+
440
+ if (flag == 1) crc ^= poly;
441
+ }
442
+ }
443
+
444
+ unsigned n;
445
+ stringstream ss;
446
+ ss << hex << (crc & long(0xffff));
447
+ ss >> n;
448
+ ss.str("");
449
+
450
+ bitset<16> bstr(n);
451
+
452
+ crc16 = bstr.to_string();
453
+
454
+ return crc16;
455
+ }
456
+ }