Skip to content

Commit 86f98ac

Browse files
authored
Merge pull request tilk#6 from yuyichao/export
Export a yosys2digitaljs function to do the full conversion
2 parents d6c61e9 + e8180f7 commit 86f98ac

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,18 @@ export async function verilator_lint(filenames: string[], dirname?: string, opti
11771177
}
11781178
}
11791179

1180+
export function yosys2digitaljs(obj: Yosys.Output, options: Options = {}): Digitaljs.TopModule {
1181+
const portmaps = order_ports(obj);
1182+
const out = yosys_to_digitaljs(obj, portmaps, options);
1183+
const toporder = topsort(module_deps(obj));
1184+
toporder.pop();
1185+
const toplevel = toporder.pop();
1186+
const output: Digitaljs.TopModule = { subcircuits: {}, ... out[toplevel] };
1187+
for (const x of toporder)
1188+
output.subcircuits[x] = out[x];
1189+
return output;
1190+
}
1191+
11801192
export async function process(filenames: string[], dirname?: string, options: Options = {}): Promise<Output> {
11811193
const optimize_simp = options.optimize ? "; opt" : "; opt_clean";
11821194
const optimize = options.optimize ? "; opt -full" : "; opt_clean";
@@ -1203,13 +1215,7 @@ export async function process(filenames: string[], dirname?: string, options: Op
12031215
}
12041216
obj = JSON.parse(fs.readFileSync(tmpjson, 'utf8'));
12051217
await promisify(fs.unlink)(tmpjson);
1206-
const portmaps = order_ports(obj);
1207-
const out = yosys_to_digitaljs(obj, portmaps, options);
1208-
const toporder = topsort(module_deps(obj));
1209-
toporder.pop();
1210-
const toplevel = toporder.pop();
1211-
const output: Digitaljs.TopModule = { subcircuits: {}, ... out[toplevel] };
1212-
for (const x of toporder) output.subcircuits[x] = out[x];
1218+
const output = yosys2digitaljs(obj, options);
12131219
const ret: Output = {
12141220
output: output,
12151221
yosys_output: obj,

0 commit comments

Comments
 (0)