Skip to content

Commit

Permalink
Include yosys out/err in exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Feb 19, 2019
1 parent 10bf738 commit 05ccd67
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,23 +641,30 @@ async function process(filenames, dirname) {
const tmpjson = await tmp.tmpName({ postfix: '.json' });
const yosys_result = await promisify(child_process.exec)(
'yosys -p "hierarchy; proc; fsm; memory -nomap" -o "' + tmpjson + '" ' + filenames.join(' '),
{maxBuffer: 1000000, cwd: dirname || null});
const obj = JSON.parse(fs.readFileSync(tmpjson, 'utf8'));
await promisify(fs.unlink)(tmpjson);
const portmaps = order_ports(obj);
const out = yosys_to_simcir(obj, portmaps);
const toporder = topsort(module_deps(obj));
toporder.pop();
const toplevel = toporder.pop();
const output = out[toplevel];
output.subcircuits = {};
for (const x of toporder) output.subcircuits[x] = out[x];
return {
status: true,
output: output,
yosys_stdout: yosys_result.stdout,
yosys_stderr: yosys_result.stderr
};
{maxBuffer: 1000000, cwd: dirname || null})
.catch(exc => exc);
try {
if (yosys_result instanceof Error) throw yosys_result;
const obj = JSON.parse(fs.readFileSync(tmpjson, 'utf8'));
await promisify(fs.unlink)(tmpjson);
const portmaps = order_ports(obj);
const out = yosys_to_simcir(obj, portmaps);
const toporder = topsort(module_deps(obj));
toporder.pop();
const toplevel = toporder.pop();
const output = out[toplevel];
output.subcircuits = {};
for (const x of toporder) output.subcircuits[x] = out[x];
return {
output: output,
yosys_stdout: yosys_result.stdout,
yosys_stderr: yosys_result.stderr
};
} catch (exc) {
exc.yosys_stdout = yosys_result.stdout;
exc.yosys_stderr = yosys_result.stderr;
throw exc;
}
}

function io_ui(output) {
Expand Down

0 comments on commit 05ccd67

Please sign in to comment.