1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
use crate::linter::{Rule, RuleResult}; use sv_parser::{unwrap_node, AlwaysKeyword, RefNode, SyntaxTree}; pub struct LevelSensitiveAlways; impl Rule for LevelSensitiveAlways { fn check(&self, _syntax_tree: &SyntaxTree, node: &RefNode) -> RuleResult { match node { RefNode::AlwaysConstruct(x) => { let (ref a, ref b) = x.nodes; let always = unwrap_node!(a, AlwaysKeyword).unwrap(); let edge = unwrap_node!(b, EdgeIdentifier); match always { RefNode::AlwaysKeyword(AlwaysKeyword::Always(_)) => { if edge.is_some() { RuleResult::Pass } else { RuleResult::Fail } } _ => RuleResult::Pass, } } _ => RuleResult::Pass, } } fn name(&self) -> String { String::from("level_sensitive_always") } fn hint(&self) -> String { String::from("level sensitive `always` must be `always_comb`") } fn reason(&self) -> String { String::from("`always` can't detect blocking/non-blocking mistake") } }