-
Notifications
You must be signed in to change notification settings - Fork 68
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
mjayasim9
wants to merge
8
commits into
intel:main
Choose a base branch
from
mjayasim9:ConstGates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
292bf2d
Avoid Module creation for Constant Gate scenarios
mjayasim9 81734f2
Removed extra import
mjayasim9 efa4b95
Added changes based on comments
mjayasim9 7a3974a
Merge branch 'main' of https://github.com/mjayasim9/rohd into ConstGates
mjayasim9 cbf0c26
Merge branch 'intel:main' into ConstGates
mjayasim9 8e7789b
Added fixes based on feedback
mjayasim9 abb0d87
Merge branch 'main' of https://github.com/mjayasim9/rohd into ConstGates
mjayasim9 4393d10
Merge branch 'ConstGates' of https://github.com/mjayasim9/rohd into C…
mjayasim9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,6 +353,109 @@ void main() { | |
}); | ||
}); | ||
|
||
group('Const input Gate test', () { | ||
test('NotGate single bit Constant input', () async { | ||
final normalLogic = Logic(); | ||
final const0 = Const(LogicValue.zero, width: 1); | ||
final constX = Const(LogicValue.x, width: 1); | ||
final const1 = Const(LogicValue.one, width: 1); | ||
normalLogic.put(LogicValue.one); | ||
|
||
expect(~const0, isA<Const>()); | ||
expect((~const0).value, equals(LogicValue.one)); | ||
|
||
expect(~constX, isA<Const>()); | ||
expect((~constX).value, equals(LogicValue.x)); | ||
|
||
expect(~const1, isA<Const>()); | ||
expect((~const1).value, equals(LogicValue.zero)); | ||
}); | ||
|
||
test('NotGate Multi bit Constant input', () async { | ||
final const1 = Const(bin('1111'), width: 4); | ||
final const4 = Const(bin('0100'), width: 4); | ||
|
||
expect(~const1, isA<Const>()); | ||
expect((~const1).value, equals(LogicValue.of(LogicValue.zero, width: 4))); | ||
|
||
expect(~const4, isA<Logic>()); | ||
expect((~const4).value, equals(LogicValue.of(11, width: 4))); | ||
}); | ||
|
||
test('And2Gate Single bit Constant input', () async { | ||
final normalLogic = Logic(); | ||
final const0 = Const(LogicValue.zero); | ||
final logicX = Logic(); | ||
final const1 = Const(LogicValue.one); | ||
normalLogic.put(LogicValue.one); | ||
logicX.put(LogicValue.x); | ||
|
||
expect(normalLogic & const0, isA<Const>()); | ||
expect((normalLogic & const0).value, equals(LogicValue.zero)); | ||
expect(logicX & const0, isA<Const>()); | ||
expect((logicX & const0).value, equals(LogicValue.zero)); | ||
expect(normalLogic & const1, isA<Logic>()); | ||
expect((normalLogic & const1).value, equals(normalLogic.value)); | ||
expect(normalLogic & logicX, isA<Logic>()); | ||
expect((normalLogic & logicX).value, equals(LogicValue.x)); | ||
expect(const0 & const1, isA<Const>()); | ||
}); | ||
|
||
test('And2Gate Multi bit Constant input', () async { | ||
final const1 = Const(bin('1111'), width: 4); | ||
final const4 = Const(bin('0100'), width: 4); | ||
final logic0 = Logic(width: 4)..put(LogicValue.zero); | ||
final logic1 = Logic(width: 4)..put(LogicValue.one); | ||
final logicX = Logic(width: 4)..put(LogicValue.x); | ||
|
||
expect(const1 & const4, isA<Const>()); | ||
expect((const1 & const4).value, equals(LogicValue.of('0100', width: 4))); | ||
|
||
expect(logic0 & const1, isA<Logic>()); | ||
expect((logic0 & const1).value, equals(LogicValue.of('0000', width: 4))); | ||
|
||
expect(logic1 & const1, isA<Logic>()); | ||
expect((logic1 & const1).value, equals(LogicValue.of('0001', width: 4))); | ||
|
||
expect(logicX & const1, isA<Logic>()); | ||
expect((logicX & const1).value, equals(LogicValue.of('xxxx', width: 4))); | ||
}); | ||
|
||
test('OR2Gate Single bit Constant input', () async { | ||
final a = Logic(); | ||
final b = Const(LogicValue.zero, width: 1); | ||
final c = Const(LogicValue.x, width: 1); | ||
final d = Const(LogicValue.one, width: 1); | ||
final z = Const('11111', width: 5); | ||
final y = Const(LogicValue.of('11x01', width: 5)); | ||
a.put(LogicValue.one); | ||
|
||
expect(a | b, isA<Logic>()); | ||
expect((a | b).value, equals(a.value)); | ||
|
||
expect(a | c, isA<Logic>()); | ||
expect((a | c).value, equals(LogicValue.one)); | ||
|
||
expect(a | d, isA<Logic>()); | ||
expect((a | d).value, equals(LogicValue.one)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. anything |
||
|
||
expect(y | z, isA<Logic>()); | ||
expect((y | z).value, equals(LogicValue.of('11111', width: 5))); | ||
}); | ||
|
||
test('OR2Gate Multi bit Constant input', () async { | ||
final a = Const(LogicValue.of(LogicValue.zero, width: 4)); | ||
final b = Const(bin('1111'), width: 4); | ||
final c = Const(bin('0100'), width: 4); | ||
|
||
expect(a | c, isA<Logic>()); | ||
expect((a | c).value, equals(c.value)); | ||
|
||
expect(b | c, isA<Const>()); | ||
expect((b | c).value, equals(LogicValue.filled(4, LogicValue.one))); | ||
}); | ||
}); | ||
|
||
group('simcompare', () { | ||
test('NotGate single bit', () async { | ||
final gtm = GateTestModule(Logic(), Logic()); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here for
or