Skip to content

Commit

Permalink
Move constants and splits/joins option to skin
Browse files Browse the repository at this point in the history
  • Loading branch information
kasbah committed Jan 4, 2018
1 parent aaf5e07 commit 1562705
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 1 addition & 2 deletions bin/netlistsvg.js
Expand Up @@ -24,13 +24,12 @@ function main(netlistpath, outputPath, skinPath) {
fs.readFile(netlistpath, function(err, netlist_data) {
if (err) throw err;
var netlist = json5.parse(netlist_data);
var analog = /analog/.test(skinPath);
lib.render(skin_data, netlist, function(err, svg_data) {
if (err) throw err;
fs.writeFile(outputPath, svg_data, 'utf-8', function(err) {
if (err) throw err;
});
}, analog);
});
});
});
}
Expand Down
3 changes: 1 addition & 2 deletions demo/demo.js
Expand Up @@ -26,10 +26,9 @@ skins.forEach(function(skinPath, i) {

function render() {
var netlist = json5.parse(textarea.value);
var analog = /analog/.test(skinSelect.value);
netlistSvg.render(skinSelect.value, netlist, function(e, svg) {
svgArea.src = 'data:image/svg+xml,' + encodeURIComponent(svg);
}, analog);
});
}

function format() {
Expand Down
2 changes: 2 additions & 0 deletions lib/analog.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions lib/index.js
Expand Up @@ -9,8 +9,9 @@ var onml = require('onml'),
var elk = new ELK();


function render(skin_data, yosys_netlist, done, analog) {
function render(skin_data, yosys_netlist, done) {
var skin = onml.p(skin_data);
var layoutProps = getProperties(skin);

// Find top module
var module_name = null;
Expand All @@ -25,17 +26,18 @@ function render(skin_data, yosys_netlist, done, analog) {
}

var module = getReformattedModule(yosys_netlist.modules[module_name]);
if (!analog) {
if (layoutProps.constants !== false) {
// this can be skipped if there are no 0's or 1's
addConstants(module);
}
if (layoutProps.splitsAndJoins !== false) {
// this can be skipped if there are no splits or joins
addSplitsJoins(module);
}
createWires(module);
var kgraph = buildKGraph(module, module_name, skin);
//fs.writeJsonSync('kgraph_in.json', kgraph);
//kgraph = fs.readJsonSync('kgraph_in.json');
var layoutProps = getProperties(skin);

elk.layout(kgraph, {layoutOptions: layoutProps})
.then(function(g) {
Expand All @@ -55,6 +57,12 @@ function getProperties(skin)
if (!isNaN(val)) {
return Number(val);
}
if (val === 'true') {
return true;
}
if (val === 'false') {
return false;
}
return val;
});
}
Expand Down

0 comments on commit 1562705

Please sign in to comment.