-
Notifications
You must be signed in to change notification settings - Fork 281
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
[Moore] Add evenOp to handle event controls. #7154
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//===- TimingControl.cpp - Slang timing control conversion ----------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "ImportVerilogInternals.h" | ||
#include "slang/ast/TimingControl.h" | ||
using namespace circt; | ||
using namespace ImportVerilog; | ||
namespace { | ||
struct TimingCtrlVisitor { | ||
Context &context; | ||
Location loc; | ||
OpBuilder &builder; | ||
|
||
TimingCtrlVisitor(Context &context, Location loc) | ||
: context(context), loc(loc), builder(context.builder) {} | ||
|
||
LogicalResult visit(const slang::ast::SignalEventControl &ctrl) { | ||
// TODO: When updating slang to the latest version, we will handle | ||
// "iffCondition". | ||
auto loc = context.convertLocation(ctrl.sourceRange.start()); | ||
auto input = context.convertRvalueExpression(ctrl.expr); | ||
builder.create<moore::EventOp>(loc, static_cast<moore::Edge>(ctrl.edge), | ||
input); | ||
return success(); | ||
} | ||
|
||
LogicalResult visit(const slang::ast::ImplicitEventControl &ctrl) { | ||
return success(); | ||
} | ||
|
||
LogicalResult visit(const slang::ast::EventListControl &ctrl) { | ||
for (auto *event : ctrl.as<slang::ast::EventListControl>().events) { | ||
if (failed(context.convertTimingControl(*event))) | ||
return failure(); | ||
} | ||
return success(); | ||
} | ||
|
||
/// Emit an error for all other timing controls. | ||
template <typename T> | ||
LogicalResult visit(T &&node) { | ||
mlir::emitError(loc, "unspported timing control: ") | ||
<< slang::ast::toString(node.kind); | ||
return failure(); | ||
} | ||
|
||
LogicalResult visitInvalid(const slang::ast::TimingControl &ctrl) { | ||
mlir::emitError(loc, "invalid timing control"); | ||
return failure(); | ||
} | ||
}; | ||
} // namespace | ||
|
||
LogicalResult | ||
Context::convertTimingControl(const slang::ast::TimingControl &timingControl) { | ||
auto loc = convertLocation(timingControl.sourceRange.start()); | ||
TimingCtrlVisitor visitor{*this, loc}; | ||
return timingControl.visit(visitor); | ||
} |
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
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.
Very cool! Can you add a test for something like
always @(posedge x, negedge y iff z)
? If we don't support those yet -- which would be totally fine -- we should at least emit an error message. I think this might be the case already, but it would be great to check that.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.
I notice the
iff
(conditional event controls) is supported at slang v0.6, but nothing in the slang AST. For example: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.
There is a bug in the
iff
condition processing, and there is no printing support for it inslang
before the patch that was introduced after the 6th release.Currently AST for your example looks like this:
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.
patch which fixed this is here - MikePopoloski/slang@2d42130
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.
oh~ Thanks! I used slang that I had installed locally. It's my mistake.
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.
By the way, we use slang v3.0 as the CIRCT library at present. 😅
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.
😅 Yeah, once we get a reasonably complete SV pipeline together, we can start to look into gradually bumping to newer versions of Slang. I tried going to v4 at some point, but the required C++ version was too high compared to the CI runners that CIRCT CI ran on. It's probably going to be easier to work against v3 until we have something that we're happy with, and then make up for the difference to v4/5/6 after that.