Skip to content

Commit

Permalink
Optional optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
tilk committed Aug 4, 2019
1 parent e52c9f2 commit 54865e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,12 @@ function yosys_to_simcir_mod(name, mod, portmaps) {
return mout;
}

async function process(filenames, dirname) {
async function process(filenames, dirname, options) {
options = options || {};
const optimize = options.optimize ? "; opt -full" : "";
const tmpjson = await tmp.tmpName({ postfix: '.json' });
const yosys_result = await promisify(child_process.exec)(
'yosys -p "hierarchy; proc; fsm; memory -nomap; dff2dffe; wreduce -memx; opt -full" -o "' + tmpjson + '" ' + filenames.join(' '),
'yosys -p "hierarchy; proc; fsm; memory -nomap; dff2dffe; wreduce -memx' + optimize + '" -o "' + tmpjson + '" ' + filenames.join(' '),
{maxBuffer: 1000000, cwd: dirname || null})
.catch(exc => exc);
try {
Expand Down Expand Up @@ -683,7 +685,7 @@ function io_ui(output) {
}
}

async function process_files(data) {
async function process_files(data, options) {
const dir = await tmp.dir();
const names = [];
try {
Expand All @@ -692,7 +694,7 @@ async function process_files(data) {
await promisify(fs.writeFile)(path.resolve(dir.path, sname), content);
if (/\.(v|sv)$/.test(sname)) names.push(sname);
}
return await process(names, dir.path);
return await process(names, dir.path, options);
} finally {
for (const name of Object.keys(data)) {
await promisify(fs.unlink)(path.resolve(dir.path, name));
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yosys2digitaljs",
"version": "0.1.2",
"version": "0.1.3",
"description": "Export Yosys netlists to a logic simulator",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion process.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ if (argv._.length === 0) {
process.exit(1);
}
const yosys2digitaljs = require('./index.js');
const result = argv.tmpdir ? yosys2digitaljs.process_files(read_files(argv._)) : yosys2digitaljs.process(argv._);
const opts = {};
if (argv.optimize) opts.optimize = true;
const result = argv.tmpdir ? yosys2digitaljs.process_files(read_files(argv._), opts) : yosys2digitaljs.process(argv._, null, opts);
result.then(res => {
if (argv.html) {
console.log(header);
Expand Down

0 comments on commit 54865e3

Please sign in to comment.