@yowasp/yosys 0.59.35-dev.1011 → 0.59.84-dev.1025
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gen/bundle.js +305 -105
- package/gen/yosys-resources.tar +0 -0
- package/gen/yosys.core.wasm +0 -0
- package/lib/api.d.ts +4 -0
- package/package.json +6 -7
- package/gen/resources-yosys.js +0 -425
- package/gen/share/ice40/cells_sim.v +0 -3502
- package/gen/share/lattice/cells_bb_nexus.v +0 -10389
- package/gen/share/nexus/cells_xtra.v +0 -10389
- package/gen/share/quicklogic/qlf_k6n10f/bram_types_sim.v +0 -74035
- package/gen/share/quicklogic/qlf_k6n10f/brams_sim.v +0 -10949
- package/gen/share/xilinx/cells_sim.v +0 -4397
- package/gen/share/xilinx/cells_xtra.v +0 -34120
package/gen/bundle.js
CHANGED
|
@@ -1,21 +1,154 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// node_modules/nanotar/dist/index.mjs
|
|
12
|
+
function parseTar(data, opts) {
|
|
13
|
+
const buffer = data.buffer || data;
|
|
14
|
+
const files = [];
|
|
15
|
+
let offset = 0;
|
|
16
|
+
while (offset < buffer.byteLength - 512) {
|
|
17
|
+
const name = _readString(buffer, offset, 100);
|
|
18
|
+
if (name.length === 0) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
const mode = _readString(buffer, offset + 100, 8).trim();
|
|
22
|
+
const uid = Number.parseInt(_readString(buffer, offset + 108, 8));
|
|
23
|
+
const gid = Number.parseInt(_readString(buffer, offset + 116, 8));
|
|
24
|
+
const size = _readNumber(buffer, offset + 124, 12);
|
|
25
|
+
const seek = 512 + 512 * Math.trunc(size / 512) + (size % 512 ? 512 : 0);
|
|
26
|
+
const mtime = _readNumber(buffer, offset + 136, 12);
|
|
27
|
+
const _type = _readNumber(buffer, offset + 156, 1);
|
|
28
|
+
const type = _type === TAR_TYPE_FILE ? "file" : _type === TAR_TYPE_DIR ? "directory" : _type;
|
|
29
|
+
const user = _readString(buffer, offset + 265, 32);
|
|
30
|
+
const group = _readString(buffer, offset + 297, 32);
|
|
31
|
+
const meta = {
|
|
32
|
+
name,
|
|
33
|
+
type,
|
|
34
|
+
size,
|
|
35
|
+
attrs: {
|
|
36
|
+
mode,
|
|
37
|
+
uid,
|
|
38
|
+
gid,
|
|
39
|
+
mtime,
|
|
40
|
+
user,
|
|
41
|
+
group
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (opts?.filter && !opts.filter(meta)) {
|
|
45
|
+
offset += seek;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (opts?.metaOnly) {
|
|
49
|
+
files.push(meta);
|
|
50
|
+
offset += seek;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const data2 = _type === TAR_TYPE_DIR ? void 0 : new Uint8Array(buffer, offset + 512, size);
|
|
54
|
+
files.push({
|
|
55
|
+
...meta,
|
|
56
|
+
data: data2,
|
|
57
|
+
get text() {
|
|
58
|
+
return new TextDecoder().decode(this.data);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
offset += seek;
|
|
62
|
+
}
|
|
63
|
+
return files;
|
|
64
|
+
}
|
|
65
|
+
function _readString(buffer, offset, size) {
|
|
66
|
+
const view = new Uint8Array(buffer, offset, size);
|
|
67
|
+
const i = view.indexOf(0);
|
|
68
|
+
const td = new TextDecoder();
|
|
69
|
+
return td.decode(i === -1 ? view : view.slice(0, i));
|
|
70
|
+
}
|
|
71
|
+
function _readNumber(buffer, offset, size) {
|
|
72
|
+
const view = new Uint8Array(buffer, offset, size);
|
|
73
|
+
let str = "";
|
|
74
|
+
for (let i = 0; i < size; i++) {
|
|
75
|
+
str += String.fromCodePoint(view[i]);
|
|
76
|
+
}
|
|
77
|
+
return Number.parseInt(str, 8);
|
|
78
|
+
}
|
|
79
|
+
var TAR_TYPE_FILE, TAR_TYPE_DIR;
|
|
80
|
+
var init_dist = __esm({
|
|
81
|
+
"node_modules/nanotar/dist/index.mjs"() {
|
|
82
|
+
TAR_TYPE_FILE = 0;
|
|
83
|
+
TAR_TYPE_DIR = 5;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// gen/yosys-resources.js
|
|
88
|
+
var yosys_resources_exports = {};
|
|
89
|
+
__export(yosys_resources_exports, {
|
|
90
|
+
filesystem: () => filesystem,
|
|
91
|
+
modules: () => modules
|
|
92
|
+
});
|
|
93
|
+
function unpackResources(url) {
|
|
94
|
+
function defaultFetchFn(url2) {
|
|
95
|
+
return fetch(url2).then((resp) => resp.arrayBuffer());
|
|
96
|
+
}
|
|
97
|
+
return async (fetchFn = defaultFetchFn) => {
|
|
98
|
+
const root = {};
|
|
99
|
+
for (const tarEntry of parseTar(await fetchFn(url))) {
|
|
100
|
+
const nameParts = tarEntry.name.split("/");
|
|
101
|
+
const dirNames = nameParts.slice(0, -1);
|
|
102
|
+
const fileName = nameParts[nameParts.length - 1];
|
|
103
|
+
let dir = root;
|
|
104
|
+
for (const dirName of dirNames)
|
|
105
|
+
dir = dir[dirName];
|
|
106
|
+
if (tarEntry.type === "directory") {
|
|
107
|
+
dir[fileName] = {};
|
|
108
|
+
} else {
|
|
109
|
+
dir[fileName] = tarEntry.data;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return root;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
var modules, filesystem;
|
|
116
|
+
var init_yosys_resources = __esm({
|
|
117
|
+
"gen/yosys-resources.js"() {
|
|
118
|
+
init_dist();
|
|
119
|
+
modules = {
|
|
120
|
+
"yosys.core.wasm": new URL("./yosys.core.wasm", import.meta.url),
|
|
121
|
+
"yosys.core2.wasm": new URL("./yosys.core2.wasm", import.meta.url),
|
|
122
|
+
"yosys.core3.wasm": new URL("./yosys.core3.wasm", import.meta.url),
|
|
123
|
+
"yosys.core4.wasm": new URL("./yosys.core4.wasm", import.meta.url)
|
|
124
|
+
};
|
|
125
|
+
filesystem = {
|
|
126
|
+
share: unpackResources(new URL("./yosys-resources.tar", import.meta.url))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
1
131
|
// node_modules/@yowasp/runtime/lib/fetch.js
|
|
2
|
-
var
|
|
132
|
+
var fetch2;
|
|
3
133
|
if (typeof process === "object" && process.release?.name === "node") {
|
|
4
|
-
|
|
134
|
+
fetch2 = async function(url, options) {
|
|
5
135
|
if (url.protocol === "file:") {
|
|
6
|
-
const { readFile } = await import("fs/promises");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
136
|
+
const { readFile } = await import("node:fs/promises");
|
|
137
|
+
const data = await readFile(url);
|
|
138
|
+
const isWasm = url.pathname.endsWith(".wasm");
|
|
139
|
+
const headers = {
|
|
140
|
+
"content-length": data.length,
|
|
141
|
+
"content-type": isWasm ? "application/wasm" : "application/octet-stream"
|
|
142
|
+
};
|
|
143
|
+
return new Response(data, { headers });
|
|
11
144
|
} else {
|
|
12
145
|
return globalThis.fetch(url, options);
|
|
13
146
|
}
|
|
14
147
|
};
|
|
15
148
|
} else {
|
|
16
|
-
|
|
149
|
+
fetch2 = globalThis.fetch;
|
|
17
150
|
}
|
|
18
|
-
var fetch_default =
|
|
151
|
+
var fetch_default = fetch2;
|
|
19
152
|
|
|
20
153
|
// node_modules/@yowasp/runtime/lib/wasi-virt.js
|
|
21
154
|
var Exit = class extends Error {
|
|
@@ -121,8 +254,13 @@ var TerminalInput = class {
|
|
|
121
254
|
};
|
|
122
255
|
var TerminalOutput = class {
|
|
123
256
|
};
|
|
257
|
+
var nextFilesystemId = /* @__PURE__ */ (function() {
|
|
258
|
+
let id = 0;
|
|
259
|
+
return () => id++;
|
|
260
|
+
})();
|
|
124
261
|
var File = class {
|
|
125
262
|
constructor(data = "") {
|
|
263
|
+
this.id = nextFilesystemId();
|
|
126
264
|
if (data instanceof Uint8Array) {
|
|
127
265
|
this.data = data;
|
|
128
266
|
} else if (typeof data === "string") {
|
|
@@ -135,40 +273,15 @@ var File = class {
|
|
|
135
273
|
return this.data.length;
|
|
136
274
|
}
|
|
137
275
|
};
|
|
138
|
-
var ReadStream = class extends InputStream {
|
|
139
|
-
constructor(file, offset) {
|
|
140
|
-
super();
|
|
141
|
-
this.file = file;
|
|
142
|
-
this.offset = offset;
|
|
143
|
-
}
|
|
144
|
-
read(len) {
|
|
145
|
-
const data = this.file.data.subarray(Number(this.offset), Number(this.offset + len));
|
|
146
|
-
this.offset += len;
|
|
147
|
-
return data;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var WriteStream = class extends OutputStream {
|
|
151
|
-
constructor(file, offset) {
|
|
152
|
-
super();
|
|
153
|
-
this.file = file;
|
|
154
|
-
this.offset = offset;
|
|
155
|
-
}
|
|
156
|
-
write(contents) {
|
|
157
|
-
const newData = new Uint8Array(this.file.data.length + contents.length);
|
|
158
|
-
newData.set(this.file.data);
|
|
159
|
-
newData.subarray(Number(this.offset)).set(contents);
|
|
160
|
-
this.file.data = newData;
|
|
161
|
-
this.offset += BigInt(contents.length);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
276
|
var Directory = class _Directory {
|
|
165
277
|
constructor(files = {}) {
|
|
278
|
+
this.id = nextFilesystemId();
|
|
166
279
|
this.files = files;
|
|
167
280
|
}
|
|
168
281
|
get size() {
|
|
169
282
|
return Object.keys(this.files).length;
|
|
170
283
|
}
|
|
171
|
-
traverse(path,
|
|
284
|
+
traverse(path, { create = null, remove = false } = {}) {
|
|
172
285
|
let entry = this;
|
|
173
286
|
let separatorAt = -1;
|
|
174
287
|
do {
|
|
@@ -177,7 +290,7 @@ var Directory = class _Directory {
|
|
|
177
290
|
const files = entry.files;
|
|
178
291
|
separatorAt = path.indexOf("/");
|
|
179
292
|
const segment = separatorAt === -1 ? path : path.substring(0, separatorAt);
|
|
180
|
-
if (separatorAt === -1 &&
|
|
293
|
+
if (separatorAt === -1 && remove)
|
|
181
294
|
delete files[segment];
|
|
182
295
|
else if (segment === "" || segment === ".")
|
|
183
296
|
;
|
|
@@ -185,10 +298,12 @@ var Directory = class _Directory {
|
|
|
185
298
|
;
|
|
186
299
|
else if (Object.hasOwn(files, segment))
|
|
187
300
|
entry = files[segment];
|
|
188
|
-
else if (
|
|
301
|
+
else if (create === "directory" || create !== null && separatorAt !== -1)
|
|
189
302
|
entry = files[segment] = new _Directory({});
|
|
190
|
-
else if (
|
|
303
|
+
else if (create === "file")
|
|
191
304
|
entry = files[segment] = new File(new Uint8Array());
|
|
305
|
+
else if (create instanceof File || create instanceof _Directory)
|
|
306
|
+
entry = files[segment] = create;
|
|
192
307
|
else
|
|
193
308
|
throw "no-entry";
|
|
194
309
|
path = path.substring(separatorAt + 1);
|
|
@@ -196,6 +311,33 @@ var Directory = class _Directory {
|
|
|
196
311
|
return entry;
|
|
197
312
|
}
|
|
198
313
|
};
|
|
314
|
+
var ReadStream = class extends InputStream {
|
|
315
|
+
constructor(file, offset) {
|
|
316
|
+
super();
|
|
317
|
+
this.file = file;
|
|
318
|
+
this.offset = offset;
|
|
319
|
+
}
|
|
320
|
+
read(len) {
|
|
321
|
+
const data = this.file.data.subarray(Number(this.offset), Number(this.offset + len));
|
|
322
|
+
this.offset += len;
|
|
323
|
+
return data;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
var WriteStream = class extends OutputStream {
|
|
327
|
+
constructor(file, offset) {
|
|
328
|
+
super();
|
|
329
|
+
this.file = file;
|
|
330
|
+
this.offset = offset;
|
|
331
|
+
}
|
|
332
|
+
write(contents) {
|
|
333
|
+
const offset = Number(this.offset);
|
|
334
|
+
const newData = new Uint8Array(Math.max(this.file.data.length, offset + contents.length));
|
|
335
|
+
newData.set(this.file.data);
|
|
336
|
+
newData.subarray(offset).set(contents);
|
|
337
|
+
this.file.data = newData;
|
|
338
|
+
this.offset += BigInt(contents.length);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
199
341
|
var Descriptor = class _Descriptor {
|
|
200
342
|
constructor(entry) {
|
|
201
343
|
this.entry = entry;
|
|
@@ -210,7 +352,7 @@ var Descriptor = class _Descriptor {
|
|
|
210
352
|
return {};
|
|
211
353
|
}
|
|
212
354
|
metadataHash() {
|
|
213
|
-
return { upper: 0, lower:
|
|
355
|
+
return { upper: 0, lower: this.entry.id };
|
|
214
356
|
}
|
|
215
357
|
metadataHashAt(_pathFlags, path) {
|
|
216
358
|
if (!(this.entry instanceof Directory))
|
|
@@ -242,7 +384,7 @@ var Descriptor = class _Descriptor {
|
|
|
242
384
|
openAt(_pathFlags, path, openFlags, _descriptorFlags) {
|
|
243
385
|
if (!(this.entry instanceof Directory))
|
|
244
386
|
throw "invalid";
|
|
245
|
-
const openEntry = this.entry.traverse(path,
|
|
387
|
+
const openEntry = this.entry.traverse(path, openFlags.create ? { create: "file" } : {});
|
|
246
388
|
if (openFlags.directory) {
|
|
247
389
|
if (!(openEntry instanceof Directory))
|
|
248
390
|
throw "not-directory";
|
|
@@ -272,6 +414,18 @@ var Descriptor = class _Descriptor {
|
|
|
272
414
|
writeViaStream(offset) {
|
|
273
415
|
return new WriteStream(this.entry, offset);
|
|
274
416
|
}
|
|
417
|
+
setSize(size) {
|
|
418
|
+
if (this.entry instanceof Directory)
|
|
419
|
+
throw "is-directory";
|
|
420
|
+
size = Number(size);
|
|
421
|
+
if (size > this.entry.data.length) {
|
|
422
|
+
const newData = new Uint8Array(size);
|
|
423
|
+
newData.set(this.entry.data);
|
|
424
|
+
this.entry.data = newData;
|
|
425
|
+
} else if (size < this.entry.data.length) {
|
|
426
|
+
this.entry.data = this.entry.data.subarray(0, size);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
275
429
|
readDirectory() {
|
|
276
430
|
return new DirectoryEntryStream(this.entry);
|
|
277
431
|
}
|
|
@@ -281,15 +435,28 @@ var Descriptor = class _Descriptor {
|
|
|
281
435
|
unlinkFileAt(path) {
|
|
282
436
|
const pathEntry = this.entry.traverse(path);
|
|
283
437
|
if (pathEntry instanceof Directory)
|
|
284
|
-
|
|
438
|
+
throw "is-directory";
|
|
285
439
|
this.entry.traverse(path, { remove: true });
|
|
286
440
|
}
|
|
287
441
|
removeDirectoryAt(path) {
|
|
288
442
|
const pathEntry = this.entry.traverse(path);
|
|
289
443
|
if (!(pathEntry instanceof Directory))
|
|
290
|
-
|
|
444
|
+
throw "not-directory";
|
|
291
445
|
this.entry.traverse(path, { remove: true });
|
|
292
446
|
}
|
|
447
|
+
readlinkAt(path) {
|
|
448
|
+
const _pathEntry = this.entry.traverse(path);
|
|
449
|
+
throw "invalid";
|
|
450
|
+
}
|
|
451
|
+
renameAt(oldPath, newDescriptor, newPath) {
|
|
452
|
+
if (!(this.entry instanceof Directory))
|
|
453
|
+
throw "not-directory";
|
|
454
|
+
if (!(newDescriptor.entry instanceof Directory))
|
|
455
|
+
throw "not-directory";
|
|
456
|
+
const oldEntry = this.entry.traverse(oldPath);
|
|
457
|
+
this.entry.traverse(newPath, { create: oldEntry });
|
|
458
|
+
this.entry.traverse(oldPath, { remove: true });
|
|
459
|
+
}
|
|
293
460
|
};
|
|
294
461
|
var DirectoryEntryStream = class {
|
|
295
462
|
constructor(directory) {
|
|
@@ -400,8 +567,7 @@ var Environment = class {
|
|
|
400
567
|
filesystemErrorCode() {
|
|
401
568
|
},
|
|
402
569
|
getDirectories() {
|
|
403
|
-
if ($this.root === null)
|
|
404
|
-
return [];
|
|
570
|
+
if ($this.root === null) return [];
|
|
405
571
|
return [[new Descriptor($this.root), "/"]];
|
|
406
572
|
}
|
|
407
573
|
}
|
|
@@ -457,6 +623,8 @@ async function fetchObject(obj, fetchFn) {
|
|
|
457
623
|
promises.push(Promise.resolve([key, value]));
|
|
458
624
|
} else if (value instanceof URL) {
|
|
459
625
|
promises.push(fetchFn(value).then((fetched) => [key, fetched]));
|
|
626
|
+
} else if (value instanceof Function) {
|
|
627
|
+
promises.push(await value(fetchFn).then((fetched) => [key, fetched]));
|
|
460
628
|
} else {
|
|
461
629
|
promises.push(fetchObject(value, fetchFn).then((fetched) => [key, fetched]));
|
|
462
630
|
}
|
|
@@ -465,43 +633,92 @@ async function fetchObject(obj, fetchFn) {
|
|
|
465
633
|
obj[key] = value;
|
|
466
634
|
return obj;
|
|
467
635
|
}
|
|
468
|
-
function fetchWebAssembly(url) {
|
|
469
|
-
|
|
636
|
+
function fetchWebAssembly(url, monitorProgress) {
|
|
637
|
+
const response = fetch_default(url).then(monitorProgress);
|
|
638
|
+
if (WebAssembly.compileStreaming !== void 0) {
|
|
639
|
+
return response.then(WebAssembly.compileStreaming);
|
|
640
|
+
} else {
|
|
641
|
+
return response.then((resp) => resp.arrayBuffer()).then(WebAssembly.compile);
|
|
642
|
+
}
|
|
470
643
|
}
|
|
471
|
-
function fetchUint8Array(url) {
|
|
472
|
-
|
|
644
|
+
function fetchUint8Array(url, monitorProgress) {
|
|
645
|
+
const response = fetch_default(url).then(monitorProgress);
|
|
646
|
+
return response.then((resp) => resp.arrayBuffer()).then((buf) => new Uint8Array(buf));
|
|
473
647
|
}
|
|
474
|
-
function fetchResources({ modules, filesystem }) {
|
|
648
|
+
function fetchResources({ modules: modules2, filesystem: filesystem2 }, fetchProgress, application) {
|
|
649
|
+
let monitorProgress = (response) => response;
|
|
650
|
+
if (fetchProgress !== void 0) {
|
|
651
|
+
const progress = /* @__PURE__ */ new Map();
|
|
652
|
+
const notifyProgress = () => {
|
|
653
|
+
let cumTotalLength = 0, cumDoneLength = 0;
|
|
654
|
+
for (const { totalLength, doneLength } of progress.values()) {
|
|
655
|
+
cumTotalLength += totalLength;
|
|
656
|
+
cumDoneLength += doneLength;
|
|
657
|
+
}
|
|
658
|
+
fetchProgress({
|
|
659
|
+
source: application,
|
|
660
|
+
totalLength: cumTotalLength,
|
|
661
|
+
doneLength: cumDoneLength
|
|
662
|
+
});
|
|
663
|
+
};
|
|
664
|
+
monitorProgress = (response) => {
|
|
665
|
+
let totalLength = +response.headers.get("content-length");
|
|
666
|
+
let doneLength = 0;
|
|
667
|
+
progress.set(response, { totalLength, doneLength });
|
|
668
|
+
notifyProgress();
|
|
669
|
+
const monitorStream = new TransformStream({
|
|
670
|
+
transform(chunk, controller) {
|
|
671
|
+
controller.enqueue(chunk);
|
|
672
|
+
doneLength += chunk.length;
|
|
673
|
+
progress.set(response, { totalLength, doneLength });
|
|
674
|
+
notifyProgress();
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
return new Response(response.body.pipeThrough(monitorStream), response);
|
|
678
|
+
};
|
|
679
|
+
}
|
|
475
680
|
return Promise.all([
|
|
476
|
-
fetchObject(
|
|
477
|
-
fetchObject(
|
|
478
|
-
]).then(([
|
|
479
|
-
return { modules:
|
|
681
|
+
fetchObject(modules2, (url) => fetchWebAssembly(url, monitorProgress)),
|
|
682
|
+
fetchObject(filesystem2, (url) => fetchUint8Array(url, monitorProgress))
|
|
683
|
+
]).then(([modules3, filesystem3]) => {
|
|
684
|
+
return { modules: modules3, filesystem: filesystem3 };
|
|
480
685
|
});
|
|
481
686
|
}
|
|
482
687
|
var Application = class {
|
|
688
|
+
#resources;
|
|
689
|
+
#resourceData;
|
|
690
|
+
#instantiate;
|
|
691
|
+
#argv0;
|
|
483
692
|
constructor(resources, instantiate2, argv0) {
|
|
484
|
-
this
|
|
485
|
-
this
|
|
486
|
-
this
|
|
487
|
-
this
|
|
693
|
+
this.#resources = resources;
|
|
694
|
+
this.#resourceData = null;
|
|
695
|
+
this.#instantiate = instantiate2;
|
|
696
|
+
this.#argv0 = argv0;
|
|
697
|
+
}
|
|
698
|
+
get argv0() {
|
|
699
|
+
return this.#argv0;
|
|
488
700
|
}
|
|
489
701
|
// The `printLine` option is deprecated and not documented but still accepted for compatibility.
|
|
490
702
|
run(args = null, files = {}, options = {}) {
|
|
491
|
-
if (this
|
|
703
|
+
if (this.#resourceData === null) {
|
|
492
704
|
if (options.synchronously)
|
|
493
705
|
throw new Error("Cannot run application synchronously unless resources are prefetched first; use `await run()` to do so");
|
|
494
|
-
|
|
495
|
-
|
|
706
|
+
const defaultFetchProgress = ({ source, totalLength, doneLength }) => {
|
|
707
|
+
const percent = (100 * doneLength / totalLength).toFixed(0);
|
|
708
|
+
console.log(`${source.argv0}: fetched ${percent}% (${doneLength} / ${totalLength})`);
|
|
709
|
+
};
|
|
710
|
+
const fetchProgress = options.fetchProgress ?? defaultFetchProgress;
|
|
711
|
+
return this.#resources().then((resourceObject) => fetchResources(resourceObject, fetchProgress, this)).then((resourceData) => {
|
|
712
|
+
this.#resourceData = resourceData;
|
|
496
713
|
return this.run(args, files, options);
|
|
497
714
|
});
|
|
498
715
|
}
|
|
499
716
|
if (args === null)
|
|
500
717
|
return;
|
|
501
718
|
const environment = new Environment();
|
|
502
|
-
environment.args = [this
|
|
719
|
+
environment.args = [this.#argv0].concat(args);
|
|
503
720
|
environment.root = directoryFromTree(files);
|
|
504
|
-
for (const [dirName, dirContents] of Object.entries(this
|
|
721
|
+
for (const [dirName, dirContents] of Object.entries(this.#resourceData.filesystem))
|
|
505
722
|
environment.root.files[dirName] = directoryFromTree(dirContents);
|
|
506
723
|
const lineBufferedConsole = lineBuffered(options.printLine ?? console.log);
|
|
507
724
|
environment.stdin = options.stdin === void 0 ? null : options.stdin;
|
|
@@ -517,7 +734,7 @@ var Application = class {
|
|
|
517
734
|
if (e instanceof Exit && e.code !== 0)
|
|
518
735
|
error = e;
|
|
519
736
|
}
|
|
520
|
-
for (const dirName of Object.keys(this
|
|
737
|
+
for (const dirName of Object.keys(this.#resourceData.filesystem))
|
|
521
738
|
delete environment.root.files[dirName];
|
|
522
739
|
files = directoryIntoTree(environment.root, { decodeASCII: options.decodeASCII ?? true });
|
|
523
740
|
if (error !== null) {
|
|
@@ -527,13 +744,13 @@ var Application = class {
|
|
|
527
744
|
return files;
|
|
528
745
|
}
|
|
529
746
|
};
|
|
530
|
-
const getCoreModule = (filename) => this
|
|
747
|
+
const getCoreModule = (filename) => this.#resourceData.modules[filename];
|
|
531
748
|
const imports = { runtime: environment.exports };
|
|
532
749
|
if (options.synchronously) {
|
|
533
750
|
const instantiateCore = (module, imports2) => new WebAssembly.Instance(module, imports2);
|
|
534
|
-
return runCommand(this
|
|
751
|
+
return runCommand(this.#instantiate(getCoreModule, imports, instantiateCore));
|
|
535
752
|
} else {
|
|
536
|
-
return this
|
|
753
|
+
return this.#instantiate(getCoreModule, imports).then(runCommand);
|
|
537
754
|
}
|
|
538
755
|
}
|
|
539
756
|
};
|
|
@@ -550,10 +767,8 @@ var curResourceBorrows = [];
|
|
|
550
767
|
var dv = new DataView(new ArrayBuffer());
|
|
551
768
|
var dataView = (mem) => dv.buffer === mem.buffer ? dv : dv = new DataView(mem.buffer);
|
|
552
769
|
function getErrorPayload(e) {
|
|
553
|
-
if (e && hasOwnProperty.call(e, "payload"))
|
|
554
|
-
|
|
555
|
-
if (e instanceof Error)
|
|
556
|
-
throw e;
|
|
770
|
+
if (e && hasOwnProperty.call(e, "payload")) return e.payload;
|
|
771
|
+
if (e instanceof Error) throw e;
|
|
557
772
|
return e;
|
|
558
773
|
}
|
|
559
774
|
var handleTables = [];
|
|
@@ -576,8 +791,7 @@ function rscTableRemove(table, handle) {
|
|
|
576
791
|
const val = table[(handle << 1) + 1];
|
|
577
792
|
const own = (val & T_FLAG) !== 0;
|
|
578
793
|
const rep = val & ~T_FLAG;
|
|
579
|
-
if (val === 0 || (scope & T_FLAG) !== 0)
|
|
580
|
-
throw new TypeError("Invalid handle");
|
|
794
|
+
if (val === 0 || (scope & T_FLAG) !== 0) throw new TypeError("Invalid handle");
|
|
581
795
|
table[handle << 1] = table[0] | T_FLAG;
|
|
582
796
|
table[0] = handle | T_FLAG;
|
|
583
797
|
return { rep, scope, own };
|
|
@@ -594,8 +808,7 @@ var utf8Decoder = new TextDecoder();
|
|
|
594
808
|
var utf8Encoder = new TextEncoder();
|
|
595
809
|
var utf8EncodedLen = 0;
|
|
596
810
|
function utf8Encode(s, realloc, memory) {
|
|
597
|
-
if (typeof s !== "string")
|
|
598
|
-
throw new TypeError("expected a string");
|
|
811
|
+
if (typeof s !== "string") throw new TypeError("expected a string");
|
|
599
812
|
if (s.length === 0) {
|
|
600
813
|
utf8EncodedLen = 0;
|
|
601
814
|
return 1;
|
|
@@ -645,7 +858,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
645
858
|
} = monotonicClock;
|
|
646
859
|
const { getRandomBytes } = random;
|
|
647
860
|
const { now: now$1 } = wallClock;
|
|
648
|
-
let gen = function* init() {
|
|
861
|
+
let gen = (function* init() {
|
|
649
862
|
let exports0;
|
|
650
863
|
let exports1;
|
|
651
864
|
function trampoline0() {
|
|
@@ -5090,8 +5303,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5090
5303
|
if (handleEntry.own) {
|
|
5091
5304
|
const rsc = captureTable7.get(handleEntry.rep);
|
|
5092
5305
|
if (rsc) {
|
|
5093
|
-
if (rsc[symbolDispose])
|
|
5094
|
-
rsc[symbolDispose]();
|
|
5306
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5095
5307
|
captureTable7.delete(handleEntry.rep);
|
|
5096
5308
|
} else if (DirectoryEntryStream2[symbolCabiDispose]) {
|
|
5097
5309
|
DirectoryEntryStream2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5103,8 +5315,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5103
5315
|
if (handleEntry.own) {
|
|
5104
5316
|
const rsc = captureTable3.get(handleEntry.rep);
|
|
5105
5317
|
if (rsc) {
|
|
5106
|
-
if (rsc[symbolDispose])
|
|
5107
|
-
rsc[symbolDispose]();
|
|
5318
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5108
5319
|
captureTable3.delete(handleEntry.rep);
|
|
5109
5320
|
} else if (OutputStream2[symbolCabiDispose]) {
|
|
5110
5321
|
OutputStream2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5116,8 +5327,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5116
5327
|
if (handleEntry.own) {
|
|
5117
5328
|
const rsc = captureTable0.get(handleEntry.rep);
|
|
5118
5329
|
if (rsc) {
|
|
5119
|
-
if (rsc[symbolDispose])
|
|
5120
|
-
rsc[symbolDispose]();
|
|
5330
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5121
5331
|
captureTable0.delete(handleEntry.rep);
|
|
5122
5332
|
} else if (Error$1[symbolCabiDispose]) {
|
|
5123
5333
|
Error$1[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5129,8 +5339,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5129
5339
|
if (handleEntry.own) {
|
|
5130
5340
|
const rsc = captureTable2.get(handleEntry.rep);
|
|
5131
5341
|
if (rsc) {
|
|
5132
|
-
if (rsc[symbolDispose])
|
|
5133
|
-
rsc[symbolDispose]();
|
|
5342
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5134
5343
|
captureTable2.delete(handleEntry.rep);
|
|
5135
5344
|
} else if (InputStream2[symbolCabiDispose]) {
|
|
5136
5345
|
InputStream2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5142,8 +5351,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5142
5351
|
if (handleEntry.own) {
|
|
5143
5352
|
const rsc = captureTable6.get(handleEntry.rep);
|
|
5144
5353
|
if (rsc) {
|
|
5145
|
-
if (rsc[symbolDispose])
|
|
5146
|
-
rsc[symbolDispose]();
|
|
5354
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5147
5355
|
captureTable6.delete(handleEntry.rep);
|
|
5148
5356
|
} else if (Descriptor2[symbolCabiDispose]) {
|
|
5149
5357
|
Descriptor2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5155,8 +5363,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5155
5363
|
if (handleEntry.own) {
|
|
5156
5364
|
const rsc = captureTable1.get(handleEntry.rep);
|
|
5157
5365
|
if (rsc) {
|
|
5158
|
-
if (rsc[symbolDispose])
|
|
5159
|
-
rsc[symbolDispose]();
|
|
5366
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5160
5367
|
captureTable1.delete(handleEntry.rep);
|
|
5161
5368
|
} else if (Pollable[symbolCabiDispose]) {
|
|
5162
5369
|
Pollable[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5168,8 +5375,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5168
5375
|
if (handleEntry.own) {
|
|
5169
5376
|
const rsc = captureTable4.get(handleEntry.rep);
|
|
5170
5377
|
if (rsc) {
|
|
5171
|
-
if (rsc[symbolDispose])
|
|
5172
|
-
rsc[symbolDispose]();
|
|
5378
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5173
5379
|
captureTable4.delete(handleEntry.rep);
|
|
5174
5380
|
} else if (TerminalInput2[symbolCabiDispose]) {
|
|
5175
5381
|
TerminalInput2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5181,8 +5387,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5181
5387
|
if (handleEntry.own) {
|
|
5182
5388
|
const rsc = captureTable5.get(handleEntry.rep);
|
|
5183
5389
|
if (rsc) {
|
|
5184
|
-
if (rsc[symbolDispose])
|
|
5185
|
-
rsc[symbolDispose]();
|
|
5390
|
+
if (rsc[symbolDispose]) rsc[symbolDispose]();
|
|
5186
5391
|
captureTable5.delete(handleEntry.rep);
|
|
5187
5392
|
} else if (TerminalOutput2[symbolCabiDispose]) {
|
|
5188
5393
|
TerminalOutput2[symbolCabiDispose](handleEntry.rep);
|
|
@@ -5411,7 +5616,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5411
5616
|
run
|
|
5412
5617
|
};
|
|
5413
5618
|
return { run: run020, "wasi:cli/run@0.2.0": run020 };
|
|
5414
|
-
}();
|
|
5619
|
+
})();
|
|
5415
5620
|
let promise, resolve, reject;
|
|
5416
5621
|
function runNext(value) {
|
|
5417
5622
|
try {
|
|
@@ -5420,19 +5625,14 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5420
5625
|
({ value, done } = gen.next(value));
|
|
5421
5626
|
} while (!(value instanceof Promise) && !done);
|
|
5422
5627
|
if (done) {
|
|
5423
|
-
if (resolve)
|
|
5424
|
-
|
|
5425
|
-
else
|
|
5426
|
-
return value;
|
|
5628
|
+
if (resolve) resolve(value);
|
|
5629
|
+
else return value;
|
|
5427
5630
|
}
|
|
5428
|
-
if (!promise)
|
|
5429
|
-
promise = new Promise((_resolve, _reject) => (resolve = _resolve, reject = _reject));
|
|
5631
|
+
if (!promise) promise = new Promise((_resolve, _reject) => (resolve = _resolve, reject = _reject));
|
|
5430
5632
|
value.then((nextVal) => done ? resolve() : runNext(nextVal), reject);
|
|
5431
5633
|
} catch (e) {
|
|
5432
|
-
if (reject)
|
|
5433
|
-
|
|
5434
|
-
else
|
|
5435
|
-
throw e;
|
|
5634
|
+
if (reject) reject(e);
|
|
5635
|
+
else throw e;
|
|
5436
5636
|
}
|
|
5437
5637
|
}
|
|
5438
5638
|
const maybeSyncReturn = runNext(null);
|
|
@@ -5440,10 +5640,10 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
5440
5640
|
}
|
|
5441
5641
|
|
|
5442
5642
|
// lib/api.js
|
|
5443
|
-
var yosys = new Application(() =>
|
|
5643
|
+
var yosys = new Application(() => Promise.resolve().then(() => (init_yosys_resources(), yosys_resources_exports)), instantiate, "yowasp-yosys");
|
|
5444
5644
|
var runYosys = yosys.run.bind(yosys);
|
|
5445
5645
|
var commands = { "yosys": runYosys };
|
|
5446
|
-
var version = "0.59.
|
|
5646
|
+
var version = "0.59.84-dev.1025";
|
|
5447
5647
|
export {
|
|
5448
5648
|
Exit,
|
|
5449
5649
|
commands,
|
|
Binary file
|
package/gen/yosys.core.wasm
CHANGED
|
Binary file
|
package/lib/api.d.ts
CHANGED
|
@@ -8,12 +8,16 @@ export type InputStream =
|
|
|
8
8
|
export type OutputStream =
|
|
9
9
|
(bytes: Uint8Array | null) => void;
|
|
10
10
|
|
|
11
|
+
export type ProgressCallback =
|
|
12
|
+
(event: { source: object, totalLength: number, doneLength: number }) => void;
|
|
13
|
+
|
|
11
14
|
export type RunOptions = {
|
|
12
15
|
stdin?: InputStream | null;
|
|
13
16
|
stdout?: OutputStream | null;
|
|
14
17
|
stderr?: OutputStream | null;
|
|
15
18
|
decodeASCII?: boolean;
|
|
16
19
|
synchronously?: boolean;
|
|
20
|
+
fetchProgress?: ProgressCallback;
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
export type Command =
|