-
Notifications
You must be signed in to change notification settings - Fork 304
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
[Calyx] Implement combinational groups #1736
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d27e52c
[Calyx] Implement combinational groups
mortbopet 0e12945
remove some whitespace
mortbopet fb2c163
Fix 'comb_group' => 'comb group' in emitter
mortbopet 8fe3f32
Be explicit about optional values
mortbopet 0af4cb6
Disallow CombGroupOp in calyx.enable
mortbopet b7b9416
Missing newline
mortbopet e323024
Some nits
mortbopet 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
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
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 |
---|---|---|
|
@@ -130,7 +130,7 @@ struct Emitter { | |
void emitWires(WiresOp op); | ||
|
||
// Group emission | ||
void emitGroup(GroupOp group); | ||
void emitGroup(GroupInterface group); | ||
|
||
// Control emission | ||
void emitControl(ControlOp control); | ||
|
@@ -265,10 +265,10 @@ struct Emitter { | |
|
||
/// Emits a port for a Group. | ||
template <typename OpTy> | ||
void emitGroupPort(GroupOp group, OpTy op, StringRef portHole) { | ||
void emitGroupPort(GroupInterface group, OpTy op, StringRef portHole) { | ||
assert((isa<GroupGoOp>(op) || isa<GroupDoneOp>(op)) && | ||
"Required to be a group port."); | ||
indent() << group.sym_name() << LSquare() << portHole << RSquare() | ||
indent() << group.symName().getValue() << LSquare() << portHole << RSquare() | ||
<< equals(); | ||
if (op.guard()) { | ||
emitValue(op.guard(), /*isIndented=*/false); | ||
|
@@ -297,7 +297,8 @@ struct Emitter { | |
.template Case<IfOp, WhileOp>([&](auto op) { | ||
indent() << (isa<IfOp>(op) ? "if " : "while "); | ||
emitValue(op.cond(), /*isIndented=*/false); | ||
os << " with " << op.groupName(); | ||
if (auto groupName = op.groupName(); groupName.hasValue()) | ||
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. Nice use of if statement with initializer :) |
||
os << " with " << groupName.getValue(); | ||
emitCalyxBody([&]() { emitCalyxControl(op); }); | ||
}) | ||
.template Case<EnableOp>([&](auto op) { emitEnable(op); }) | ||
|
@@ -497,7 +498,7 @@ void Emitter::emitWires(WiresOp op) { | |
emitCalyxSection("wires", [&]() { | ||
for (auto &&bodyOp : *op.getBody()) { | ||
TypeSwitch<Operation *>(&bodyOp) | ||
.Case<GroupOp>([&](auto op) { emitGroup(op); }) | ||
.Case<GroupInterface>([&](auto op) { emitGroup(op); }) | ||
.Case<AssignOp>([&](auto op) { emitAssignment(op); }) | ||
.Case<hw::ConstantOp, comb::AndOp, comb::OrOp, comb::XorOp>( | ||
[&](auto op) { /* Do nothing. */ }) | ||
|
@@ -508,7 +509,7 @@ void Emitter::emitWires(WiresOp op) { | |
}); | ||
} | ||
|
||
void Emitter::emitGroup(GroupOp group) { | ||
void Emitter::emitGroup(GroupInterface group) { | ||
auto emitGroupBody = [&]() { | ||
for (auto &&bodyOp : *group.getBody()) { | ||
TypeSwitch<Operation *>(&bodyOp) | ||
|
@@ -522,7 +523,8 @@ void Emitter::emitGroup(GroupOp group) { | |
}); | ||
} | ||
}; | ||
emitCalyxSection("group", emitGroupBody, group.sym_name()); | ||
auto prefix = Twine(isa<CombGroupOp>(group) ? "comb " : "") + "group"; | ||
emitCalyxSection(prefix.str(), emitGroupBody, group.symName().getValue()); | ||
} | ||
|
||
void Emitter::emitEnable(EnableOp enable) { | ||
|
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.
Nice!!