-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from remes-codasip/rule-procedural-continuous…
…-assignment New rule `procedural_continuous_assignment`
- Loading branch information
Showing
16 changed files
with
215 additions
and
2 deletions.
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
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
21 changes: 21 additions & 0 deletions
21
md/syntaxrules-explanation-procedural_continuous_assignment.md
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,21 @@ | ||
Continuous assignment, e.g. `assign x = y;` outside of any `always` process, | ||
continuously drives the LHS and changes with any change on the RHS. | ||
The same keyword `assign` has different meaning when used within an `always` | ||
process (or `always_ff`, `always_comb`, `initial`, etc.) where it can be used | ||
to override procedural assignments. | ||
Using this construct in a procedural block (`always*`) which is only triggered | ||
on changes to signals in the sensitivity list may not be synthesizable. | ||
|
||
This SystemVerilog language feature is being considered for deprecation, as | ||
noted in IEEE1800-2017 Annex C, because it is easily abused and difficult to | ||
implement while not providing additional capability. | ||
Users are strongly encouraged to migrate their cod to use one of the alternate | ||
methods of procedural or continuous assignments. | ||
|
||
See also: | ||
- **non_blocking_assignment_in_always_comb** - Useful companion rule. | ||
- **blocking_assignment_in_always_ff** - Useful companion rule. | ||
|
||
The most relevant clauses of IEEE1800-2017 are: | ||
- 10.6.1 The assign and deassign procedural statements | ||
- Annex C.4 Constructs identified for deprecation |
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
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,38 @@ | ||
use crate::config::ConfigOption; | ||
use crate::linter::{SyntaxRule, SyntaxRuleResult}; | ||
use sv_parser::{NodeEvent, RefNode, SyntaxTree}; | ||
|
||
#[derive(Default)] | ||
pub struct ProceduralContinuousAssignment; | ||
|
||
impl SyntaxRule for ProceduralContinuousAssignment { | ||
fn check( | ||
&mut self, | ||
_syntax_tree: &SyntaxTree, | ||
event: &NodeEvent, | ||
_option: &ConfigOption, | ||
) -> SyntaxRuleResult { | ||
let node = match event { | ||
NodeEvent::Enter(x) => x, | ||
NodeEvent::Leave(_) => { | ||
return SyntaxRuleResult::Pass; | ||
} | ||
}; | ||
match node { | ||
RefNode::ProceduralContinuousAssignmentAssign(_) => SyntaxRuleResult::Fail, | ||
_ => SyntaxRuleResult::Pass, | ||
} | ||
} | ||
|
||
fn name(&self) -> String { | ||
String::from("procedural_continuous_assignment") | ||
} | ||
|
||
fn hint(&self, _option: &ConfigOption) -> String { | ||
String::from("Move `assign` out of `always` block.") | ||
} | ||
|
||
fn reason(&self) -> String { | ||
String::from("Procedural continuous assigments are not synthesizable.") | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
testcases/syntaxrules/fail/procedural_continuous_assignment.sv
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,19 @@ | ||
module M; | ||
always @* | ||
assign c = a + b; | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always_comb | ||
assign c = a + b; | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always_latch | ||
assign c = a + b; | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always_ff @(posedge clk) | ||
assign c = a + b; | ||
endmodule |
18 changes: 18 additions & 0 deletions
18
testcases/syntaxrules/pass/procedural_continuous_assignment.sv
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,18 @@ | ||
module M; | ||
assign c = a + b; // Continuous assignment | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always_ff @(posedge clk) | ||
c <= a + b; // Procedural non-blocking assignment | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always_comb | ||
c = a + b; // Procedural blocking assignment | ||
endmodule | ||
//////////////////////////////////////////////////////////////////////////////// | ||
module M; | ||
always @* | ||
c = a + b; // Procedural blocking assignment, Verilog 2001 | ||
endmodule |