Skip to content

Conversation

@malmeloo
Copy link
Contributor

Exposes a new constructor argument to HeadlessCircuit that allows customization of attributes for specific cells. These attributes extend or overwrite the attributes that are set by default for the various models.

As an example, the below code would make the fill color for all And gates light green:

const cellAttrs = {
    'And': {
        'body': {'fill': 'lightgreen'}
    }
}

const circuit = new digitaljs.Circuit(input, {cellAttributes: cellAttrs});

A current limitation of this feature is that it relies on the types as passed to the JointJS cells, which makes it more difficult to specify the attributes for specific Yosys prims (e.g. And instead of $and). It would be possible to split off the current lookup table used in getCellType, but another solution (which I would prefer) is to convert the current .define('type', ...) structures into proper class inheritance, similar to what the tutorial does here. That would allow users to get the type using getCellType(...).type, and even allow getting rid of that lookup table altogether by making the Yosys primitive a static field on the models.

Let me know what you think 🙂

@malmeloo
Copy link
Contributor Author

I've just pushed a commit that implements the first solution to the limitation discussed above. That allows for the following syntax:

const cellAttrs = {
    [digitaljs.getCellTypeStr('$and')]: {
        'body': {'fill': 'lightgreen'}
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant