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
@@ -0,0 +1,391 @@
1
+ package origen.common;
2
+
3
+ import java.util.ArrayList;
4
+ import java.util.Collections;
5
+ import java.util.Comparator;
6
+ import java.util.List;
7
+ import xoc.dta.datatypes.MultiSiteBoolean;
8
+ import xoc.dta.datatypes.MultiSiteLong;
9
+ import xoc.dta.datatypes.MultiSiteLongArray;
10
+ import xoc.dta.resultaccess.datatypes.BitSequence.BitOrder;
11
+
12
+ /**
13
+ * Generic data holder class
14
+ *
15
+ * <p>Can be used for example to store data before patching. Data elements are of type long. The
16
+ * implementation class is responsible for mapping this data to the right format
17
+ *
18
+ * <p>Use: It's basically a key-value pair per data point. This format is efficient for large arrays
19
+ * with little set data. It's not so efficient for a small array with many datapoints set. The key
20
+ * is the address and the value is called data. Everything is stored in a multisitelongarray for
21
+ * efficient patching.
22
+ *
23
+ * <p>Usage example:
24
+ *
25
+ * <pre>{@code
26
+ * OrigenData mem = new OrigenData();
27
+ * mem.setData(10, 0x55);
28
+ * mem.setData(12, 0x55);
29
+ * println("The same? " + mem.allSitesTheSame(10));
30
+ * mem.setDataOnSite(1, 10, 11);
31
+ * println("The same? " + mem.allSitesTheSame(10));
32
+ *
33
+ * mem.setDataOnSite(4, 100, 44);
34
+ * mem.setDataOnSite(4, 200, 44);
35
+ * mem.setDataOnSite(4, 300, 44);
36
+ * mem.setData(60, 60);
37
+ * mem.printData();
38
+ *
39
+ * println("Addr 10 site 1 set? : " + mem.addrIsSet(1, 10));
40
+ * int addr = 60;
41
+ * if (mem.allSitesTheSame(addr)) {
42
+ * println(mem.getDataCommon(addr));
43
+ * } else {
44
+ * println(mem.getDataMSL(addr));
45
+ * }
46
+ * }</pre>
47
+ */
48
+ public class OrigenData {
49
+ private MultiSiteLongArray mem_addr;
50
+ private MultiSiteLongArray mem_data;
51
+
52
+ private ArrayList<Long> _sortedUniqueElements;
53
+ // For printing purposes only
54
+ public int bitPerDataElement = 32;
55
+
56
+ private boolean _anythingSet = false;
57
+ /** Constructor, initialized empty address and data arrays */
58
+ public OrigenData() {
59
+ mem_addr = new MultiSiteLongArray();
60
+ mem_data = new MultiSiteLongArray();
61
+ _anythingSet = false;
62
+ }
63
+
64
+ public ArrayList<Long> getUniqueAddressList() {
65
+ ArrayList<Long> list = new ArrayList<Long>();
66
+ for (int site : mem_data.getActiveSites()) {
67
+ long[] a = mem_addr.get(site);
68
+ for (int i = 0; i < a.length; i++) {
69
+ if (!list.contains(a[i])) {
70
+ list.add(a[i]);
71
+ }
72
+ }
73
+ }
74
+ Collections.sort(list);
75
+ return list;
76
+ }
77
+
78
+ public MultiSiteBoolean getActiveSitesOnAddr(long addr) {
79
+ MultiSiteBoolean MSB = new MultiSiteBoolean();
80
+ for (int site : mem_data.getActiveSites()) {
81
+ MSB.set(site, addrIsSet(site, addr));
82
+ }
83
+ return MSB;
84
+ }
85
+
86
+ public int getUniqueAddr(int index) {
87
+ _sortedUniqueElements = getUniqueAddressList();
88
+ return _sortedUniqueElements.get(index).intValue();
89
+ }
90
+
91
+ public int getNumUniqueAddr() {
92
+ _sortedUniqueElements = getUniqueAddressList();
93
+ return _sortedUniqueElements.size();
94
+ }
95
+
96
+ public static <T extends Comparable<T>> List<Integer> sortIndex(final List<T> in) {
97
+ ArrayList<Integer> index = new ArrayList<>();
98
+ for (int i = 0; i < in.size(); i++) {
99
+ index.add(i);
100
+ }
101
+
102
+ Collections.sort(
103
+ index,
104
+ new Comparator<Integer>() {
105
+ @Override
106
+ public int compare(Integer idx1, Integer idx2) {
107
+ return in.get(idx1).compareTo(in.get(idx2));
108
+ }
109
+ });
110
+
111
+ return index;
112
+ }
113
+
114
+ public void sort() {
115
+ for (int site : mem_data.getActiveSites()) {
116
+ long[] a = mem_addr.get(site);
117
+ long[] d = mem_data.get(site);
118
+
119
+ List<Long> list = new ArrayList<Long>(a.length);
120
+ for (long n : a) {
121
+ list.add(n);
122
+ }
123
+
124
+ List<Integer> idx = sortIndex(list);
125
+
126
+ long[] newA = a.clone();
127
+ long[] newD = d.clone();
128
+ for (int i = 0; i < a.length; i++) {
129
+ newA[i] = a[idx.get(i)];
130
+ newD[i] = d[idx.get(i)];
131
+ }
132
+ mem_addr.set(site, newA);
133
+ mem_data.set(site, newD);
134
+ }
135
+ }
136
+
137
+ public boolean memEmpty() {
138
+ return _anythingSet;
139
+ }
140
+ /**
141
+ * Set data on 1 specific site for 1 address
142
+ *
143
+ * @param site
144
+ * @param addr
145
+ * @param data
146
+ */
147
+ public void setDataOnSite(int site, long addr, long data) {
148
+ long[] a = mem_addr.get(site);
149
+ long[] d = mem_data.get(site);
150
+ if (a == null) {
151
+ a = new long[0];
152
+ }
153
+ if (d == null) {
154
+ d = new long[0];
155
+ }
156
+ int loc = valInAddr(a, addr);
157
+ if (loc == d.length) {
158
+ d = expand(d);
159
+ a = expand(a);
160
+ }
161
+ d[loc] = data;
162
+ a[loc] = addr;
163
+ mem_data.set(site, d);
164
+ mem_addr.set(site, a);
165
+ _anythingSet = true;
166
+ }
167
+
168
+ /**
169
+ * Set the data for a certain 32bit addr
170
+ *
171
+ * @param addr
172
+ * @param data
173
+ */
174
+ public void setData(long addr, long data) {
175
+ for (int site : mem_data.getActiveSites()) {
176
+ setDataOnSite(site, addr, data);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Returns true if a certain address is set on ANY site
182
+ *
183
+ * @param addr
184
+ * @return
185
+ */
186
+ public boolean addrIsSetAnySite(long addr) {
187
+ for (int site : mem_data.getActiveSites()) {
188
+ if (addrIsSet(site, addr)) {
189
+ return true;
190
+ }
191
+ }
192
+ return false;
193
+ }
194
+
195
+ /**
196
+ * Returns true if a certain address is set on a specific site
197
+ *
198
+ * @param site
199
+ * @param addr
200
+ * @return
201
+ */
202
+ public boolean addrIsSet(int site, long addr) {
203
+ long[] a = mem_addr.get(site);
204
+ int loc = valInAddr(a, addr);
205
+ return loc != a.length;
206
+ }
207
+
208
+ /**
209
+ * Returns the common data for all sites. Throws an error if this specific address is
210
+ * site-specific
211
+ *
212
+ * @param addr
213
+ * @return
214
+ */
215
+ public long getDataCommon(long addr) {
216
+ int sites[] = mem_data.getActiveSites();
217
+ if (allSitesTheSame(addr)) {
218
+ return getDataPerSite(sites[0], addr);
219
+ }
220
+ throw new Error(
221
+ "Not all sites have the same data, cannot give common data for this addr: " + addr);
222
+ }
223
+
224
+ /**
225
+ * Returns the site specific data for an address, returning -1 for the data if it has not been
226
+ * previously set
227
+ *
228
+ * @param addr
229
+ * @return
230
+ */
231
+ public MultiSiteLong getDataMSL(long addr) {
232
+ return getDataMSL(addr, false, "");
233
+ }
234
+
235
+ /**
236
+ * Returns the site specific data for an address, but raising and error with the given message if
237
+ * the data has not been previously set
238
+ *
239
+ * @param addr
240
+ * @return
241
+ */
242
+ public MultiSiteLong getDataMSL(long addr, String errorMsg) {
243
+ return getDataMSL(addr, true, errorMsg);
244
+ }
245
+
246
+ private MultiSiteLong getDataMSL(long addr, boolean errorOnNotSet, String errorMsg) {
247
+ MultiSiteLong result = new MultiSiteLong();
248
+ for (int site : mem_data.getActiveSites()) {
249
+ if (addrIsSet(site, addr)) {
250
+ result.set(site, getDataPerSite(site, addr));
251
+ } else {
252
+ if (errorOnNotSet) {
253
+ throw new Error(errorMsg);
254
+ }
255
+ result.set(site, -1);
256
+ }
257
+ }
258
+ return result;
259
+ }
260
+
261
+ /**
262
+ * Returns whether or not all the sites have the same data for this addr
263
+ *
264
+ * @param addr
265
+ * @return
266
+ */
267
+ public boolean allSitesTheSame(long addr) {
268
+ long commonData = -1;
269
+ boolean addrFound = false, addrNotFound = false;
270
+ for (int site : mem_data.getActiveSites()) {
271
+ long[] d = mem_data.get(site);
272
+ long[] a = mem_addr.get(site);
273
+ int loc = valInAddr(a, addr);
274
+ if (loc != a.length) {
275
+ if (addrNotFound) {
276
+ return false;
277
+ }
278
+ // Addr is found
279
+ addrFound = true;
280
+ if (commonData == -1) {
281
+ commonData = d[loc];
282
+ } else {
283
+ if (commonData != d[loc]) {
284
+ // Not all data the same for this addr over all sits
285
+ return false;
286
+ }
287
+ }
288
+ } else {
289
+ addrNotFound = true;
290
+ // Addr is found on one site but not the other
291
+ if (addrFound) {
292
+ return false;
293
+ }
294
+ }
295
+ }
296
+ return true;
297
+ }
298
+
299
+ /** Print all set data for all sites */
300
+ public void printData() {
301
+ sort();
302
+ System.out.println(getUniqueAddressList());
303
+ for (int site : mem_data.getActiveSites()) {
304
+ System.out.println("Site: " + site);
305
+ long[] d = mem_data.get(site);
306
+ long[] a = mem_addr.get(site);
307
+ for (int i = 0; i < d.length; i++) {
308
+ System.out.println(
309
+ a[i]
310
+ + "\t"
311
+ + OrigenHelpers.longToPaddedHexString(
312
+ d[i], bitPerDataElement / 4, BitOrder.RIGHT_TO_LEFT));
313
+ }
314
+ }
315
+ }
316
+
317
+ /** Clears all data on all sites */
318
+ public void clearAllData() {
319
+ // Lazy man's approach: Basically just throwing the reference to the old MSLarray away
320
+ // Let's hope the garbage collector removes the old references nicely
321
+ mem_addr = new MultiSiteLongArray();
322
+ mem_data = new MultiSiteLongArray();
323
+ _anythingSet = false;
324
+ }
325
+ // Some private helper functions
326
+
327
+ /**
328
+ * Returns the location in the array for a certain address. Returns the last+1 location of the
329
+ * array if addr is not found
330
+ *
331
+ * @param arr
332
+ * @param val
333
+ * @return
334
+ */
335
+ private int valInAddr(long[] arr, long val) {
336
+ if (arr != null) {
337
+ for (int i = 0; i < arr.length; i++) {
338
+ if (val == arr[i]) {
339
+ return i;
340
+ }
341
+ }
342
+ return arr.length;
343
+ }
344
+ return 0;
345
+ }
346
+
347
+ /**
348
+ * Get the data for a specific site. This is private because the testmethod should call
349
+ * getDataMSL()
350
+ *
351
+ * @param site
352
+ * @param addr
353
+ * @return
354
+ */
355
+ private long getDataPerSite(int site, long addr) {
356
+ long[] d = mem_data.get(site);
357
+ long[] a = mem_addr.get(site);
358
+ int loc = valInAddr(a, addr);
359
+ return d[loc];
360
+ }
361
+
362
+ /**
363
+ * Expand the array by 1
364
+ *
365
+ * @param origArray
366
+ * @return
367
+ */
368
+ private long[] expand(long[] origArray) {
369
+ long[] newArray = new long[origArray.length + 1];
370
+ System.arraycopy(origArray, 0, newArray, 0, origArray.length);
371
+ return newArray;
372
+ }
373
+ }
374
+
375
+ class DataPair<T> {
376
+ private final T addr;
377
+ private final T data;
378
+
379
+ public DataPair(T first, T second) {
380
+ addr = first;
381
+ data = second;
382
+ }
383
+
384
+ public T addr() {
385
+ return addr;
386
+ }
387
+
388
+ public T second() {
389
+ return data;
390
+ }
391
+ }
@@ -0,0 +1,170 @@
1
+ package origen.common;
2
+
3
+ import xoc.dta.datatypes.MultiSiteLong;
4
+ import xoc.dta.resultaccess.datatypes.BitSequence;
5
+ import xoc.dta.resultaccess.datatypes.BitSequence.BitOrder;
6
+ import xoc.dta.setupaccess.IPattern;
7
+ import xoc.dta.setupaccess.IStateCharBuffer;
8
+
9
+ public class OrigenHelpers {
10
+
11
+ public static boolean isEven(int number) {
12
+ return (number % 2) == 0;
13
+ }
14
+
15
+ public static boolean isOdd(int number) {
16
+ return (number % 2) != 0;
17
+ }
18
+
19
+ public static boolean isEven(long number) {
20
+ return (number % 2) == 0;
21
+ }
22
+
23
+ public static boolean isOdd(long number) {
24
+ return (number % 2) != 0;
25
+ }
26
+
27
+ /**
28
+ * String parameter to assert it's not used Default value is "0"
29
+ *
30
+ * @param params
31
+ */
32
+ public static void assertNotImplStrParam(String params) {
33
+ assertNotImplementedStringParam(new String[] {params}, "0");
34
+ }
35
+
36
+ /**
37
+ * Check list of string parameters to assert they are not used Default value is "0"
38
+ *
39
+ * @param params
40
+ */
41
+ public static void assertNotImplStrParam(String[] params) {
42
+ assertNotImplementedStringParam(params, "0");
43
+ }
44
+
45
+ /**
46
+ * Check list of string parameters to make sure they are not used
47
+ *
48
+ * @param params
49
+ * @param defValue
50
+ */
51
+ public static void assertNotImplementedStringParam(String[] params, String defValue) {
52
+ for (String p : params) {
53
+ if (p != null && (p != "" && p != defValue)) {
54
+ throw new Error("String Paramvalue: " + p + " is not defined!!");
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Check list int parameters to make sure they not used Default value = 0
61
+ *
62
+ * @param params
63
+ */
64
+ public static void assertNotImplIntParam(int[] params) {
65
+ assertNotImplementedIntParam(params, 0);
66
+ }
67
+
68
+ /**
69
+ * Check list of int parameter to make sure it's not used
70
+ *
71
+ * @param params
72
+ * @param defValue
73
+ */
74
+ public static void assertNotImplementedIntParam(int[] params, int defValue) {
75
+ for (int p : params) {
76
+ if (p != 0) {
77
+ throw new Error("Int Paramvalue: " + p + " is not defined!!");
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Check double paramter they make sure it's not used
84
+ *
85
+ * @param params
86
+ */
87
+ public static void assertNotImplDoubleParam(double params) {
88
+ assertNotImplDoubleParam(new double[] {params});
89
+ }
90
+
91
+ /**
92
+ * Check list of double parameters to make sure they are not used Default value = 0
93
+ *
94
+ * @param params
95
+ */
96
+ public static void assertNotImplDoubleParam(double[] params) {
97
+ assertNotImplementedDoubleParam(params, 0);
98
+ }
99
+
100
+ /**
101
+ * Check list of double parameters
102
+ *
103
+ * @param params
104
+ * @param defValue
105
+ */
106
+ public static void assertNotImplementedDoubleParam(double[] params, double defValue) {
107
+ for (double p : params) {
108
+ if (p != 0) {
109
+ throw new Error("double Paramvalue: " + p + " is not defined!!");
110
+ }
111
+ }
112
+ }
113
+
114
+ // Overlays the given data on the given pin, starting from the first vector of the given pattern
115
+ // For ALL sites the same
116
+ public static void overlaySubroutine(
117
+ IPattern subroutinePattern, String pin, long decData, int size) {
118
+ if (size > 64) {
119
+ throw new NumberFormatException("Cannot patch more than 64 bits using Long");
120
+ }
121
+ if (decData != -1) {
122
+ String data = longToPaddedBinaryString(decData, size, BitOrder.LEFT_TO_RIGHT, false);
123
+ subroutinePattern.vector(0).writeStateChar(data.toCharArray(), pin);
124
+ }
125
+ }
126
+
127
+ public static String longToPaddedHexString(Long data, int size, BitSequence.BitOrder order) {
128
+ String binStr = longToPaddedBinaryString(data, size, order, false);
129
+ long value = Long.parseLong(binStr, 2);
130
+ String format = "%" + size + "s";
131
+ String strData = String.format(format, Long.toHexString(value).toUpperCase()).replace(" ", "0");
132
+ return strData;
133
+ }
134
+
135
+ public static String longToPaddedBinaryString(
136
+ Long data, int size, BitSequence.BitOrder order, boolean replace01ToHL) {
137
+ // Enforce minimum string size
138
+ String format = "%" + size + "s";
139
+ String strData = String.format(format, Long.toBinaryString(data)).replace(" ", "0");
140
+ if (order == BitOrder.LEFT_TO_RIGHT) {
141
+ strData = new StringBuilder(strData).reverse().toString();
142
+ // System.out.println(strData);
143
+ // Enforce maximum string size
144
+ strData = strData.substring(0, size);
145
+ }
146
+
147
+ if (replace01ToHL) {
148
+ strData = strData.replace("0", "L").replace("1", "H");
149
+ }
150
+ return strData;
151
+ }
152
+ // Overlay per site
153
+ public static void overlaySubroutine(
154
+ IPattern subroutinePattern, String pin, MultiSiteLong decData, int size, int[] sites) {
155
+ if (size > 64) {
156
+ throw new NumberFormatException("Cannot patch more than 64 bits using Long");
157
+ }
158
+ IStateCharBuffer scBuf = subroutinePattern.createStateCharBuffer();
159
+ for (int site : sites) {
160
+ long longData = decData.get(site);
161
+ // Only patch if data != -1, this can be used to not patch data on certain sites
162
+ if (longData != -1) {
163
+ String data = longToPaddedBinaryString(longData, size, BitOrder.LEFT_TO_RIGHT, false);
164
+ scBuf.writeStateChar(site, 0, pin, data.toCharArray());
165
+ }
166
+ }
167
+
168
+ scBuf.flush();
169
+ }
170
+ }