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

Avoid Module creation for Constant Gate scenarios #481

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

mjayasim9
Copy link
Contributor

Description & Motivation

#429

Related Issue(s)

#429

Testing

Added test cases to check if the result of '&', '|' and '~' operations are as expected for constant input scenarios.

Backwards-compatibility

Is this a breaking change that will not be backwards-compatible? If yes, how so?

No.

Documentation

Does the change require any updates to documentation? If so, where? Are they included?

No.

lib/src/signals/logic.dart Outdated Show resolved Hide resolved
lib/src/signals/logic.dart Outdated Show resolved Hide resolved
lib/src/signals/logic.dart Outdated Show resolved Hide resolved
@mkorbel1 mkorbel1 linked an issue Apr 5, 2024 that may be closed by this pull request
lib/src/signals/logic.dart Outdated Show resolved Hide resolved
lib/src/signals/logic.dart Show resolved Hide resolved
test/gate_test.dart Outdated Show resolved Hide resolved
test/gate_test.dart Outdated Show resolved Hide resolved
test/gate_test.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@mkorbel1 mkorbel1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very good, and the tests make sense to me for &, |, and ~


/// Logical bitwise AND.
Logic operator &(Logic other) => And2Gate(this, other).out;
Logic operator &(Logic other) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon review, I realized that perhaps operators could be overridden on Const class instead of these special cases here.

For example:

if(other is Const) {
return other & this;
}

Then in Const you can just override @override Logic operator &(Logic other) to perform the const version of things.

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.

Avoid module creation for simple constant scenarios in gates
2 participants