Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customization of cell attributes #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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