Change crate structure
This commit is contained in:
parent
719c7eaa11
commit
03de070220
@ -1,6 +1,8 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"sv-parser",
|
"sv-parser",
|
||||||
|
"sv-parser-syntaxtree",
|
||||||
|
"sv-parser-parser",
|
||||||
"sv-parser-macros",
|
"sv-parser-macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
16
sv-parser-parser/Cargo.toml
Normal file
16
sv-parser-parser/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "sv-parser-parser"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["dalance <dalance@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
trace = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
nom = "5.0.0"
|
||||||
|
nom-packrat = "0.1.17"
|
||||||
|
str-concat = "*"
|
||||||
|
sv-parser-syntaxtree = { path = "../sv-parser-syntaxtree" }
|
||||||
|
sv-parser-macros = { path = "../sv-parser-macros" }
|
@ -1,88 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssertionItem {
|
|
||||||
Concurrent(Box<ConcurrentAssertionItem>),
|
|
||||||
Immediate(Box<DeferredImmediateAssetionItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DeferredImmediateAssetionItem {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(BlockIdentifier, Symbol)>,
|
|
||||||
DeferredImmediateAssertionStatement,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProceduralAssertionStatement {
|
|
||||||
Concurrent(Box<ConcurrentAssertionStatement>),
|
|
||||||
Immediate(Box<ImmediateAssetionStatement>),
|
|
||||||
Checker(Box<CheckerInstantiation>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImmediateAssetionStatement {
|
|
||||||
Simple(Box<SimpleImmediateAssertionStatement>),
|
|
||||||
Deferred(Box<DeferredImmediateAssertionStatement>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SimpleImmediateAssertionStatement {
|
|
||||||
Assert(Box<SimpleImmediateAssertStatement>),
|
|
||||||
Assume(Box<SimpleImmediateAssumeStatement>),
|
|
||||||
Cover(Box<SimpleImmediateCoverStatement>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimpleImmediateAssertStatement {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimpleImmediateAssumeStatement {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimpleImmediateCoverStatement {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DeferredImmediateAssertionStatement {
|
|
||||||
Assert(Box<DeferredImmediateAssertStatement>),
|
|
||||||
Assume(Box<DeferredImmediateAssumeStatement>),
|
|
||||||
Cover(Box<DeferredImmediateCoverStatement>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DeferredImmediateAssertStatement {
|
|
||||||
pub nodes: (Keyword, AssertTiming, Paren<Expression>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DeferredImmediateAssumeStatement {
|
|
||||||
pub nodes: (Keyword, AssertTiming, Paren<Expression>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DeferredImmediateCoverStatement {
|
|
||||||
pub nodes: (Keyword, AssertTiming, Paren<Expression>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssertTiming {
|
|
||||||
Zero(Box<Symbol>),
|
|
||||||
Final(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -99,14 +15,18 @@ pub(crate) fn assertion_item(s: Span) -> IResult<Span, AssertionItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn deferred_immediate_assertion_item(s: Span) -> IResult<Span, DeferredImmediateAssetionItem> {
|
pub(crate) fn deferred_immediate_assertion_item(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, DeferredImmediateAssetionItem> {
|
||||||
let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?;
|
let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?;
|
||||||
let (s, b) = deferred_immediate_assertion_statement(s)?;
|
let (s, b) = deferred_immediate_assertion_statement(s)?;
|
||||||
Ok((s, DeferredImmediateAssetionItem { nodes: (a, b) }))
|
Ok((s, DeferredImmediateAssetionItem { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn procedural_assertion_statement(s: Span) -> IResult<Span, ProceduralAssertionStatement> {
|
pub(crate) fn procedural_assertion_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ProceduralAssertionStatement> {
|
||||||
alt((
|
alt((
|
||||||
map(concurrent_assertion_statement, |x| {
|
map(concurrent_assertion_statement, |x| {
|
||||||
ProceduralAssertionStatement::Concurrent(Box::new(x))
|
ProceduralAssertionStatement::Concurrent(Box::new(x))
|
||||||
@ -150,7 +70,9 @@ pub(crate) fn simple_immediate_assertion_statement(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn simple_immediate_assert_statement(s: Span) -> IResult<Span, SimpleImmediateAssertStatement> {
|
pub(crate) fn simple_immediate_assert_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SimpleImmediateAssertStatement> {
|
||||||
let (s, a) = keyword("assert")(s)?;
|
let (s, a) = keyword("assert")(s)?;
|
||||||
let (s, b) = paren(expression)(s)?;
|
let (s, b) = paren(expression)(s)?;
|
||||||
let (s, c) = action_block(s)?;
|
let (s, c) = action_block(s)?;
|
||||||
@ -158,7 +80,9 @@ pub(crate) fn simple_immediate_assert_statement(s: Span) -> IResult<Span, Simple
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn simple_immediate_assume_statement(s: Span) -> IResult<Span, SimpleImmediateAssumeStatement> {
|
pub(crate) fn simple_immediate_assume_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SimpleImmediateAssumeStatement> {
|
||||||
let (s, a) = keyword("assume")(s)?;
|
let (s, a) = keyword("assume")(s)?;
|
||||||
let (s, b) = paren(expression)(s)?;
|
let (s, b) = paren(expression)(s)?;
|
||||||
let (s, c) = action_block(s)?;
|
let (s, c) = action_block(s)?;
|
||||||
@ -166,7 +90,9 @@ pub(crate) fn simple_immediate_assume_statement(s: Span) -> IResult<Span, Simple
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn simple_immediate_cover_statement(s: Span) -> IResult<Span, SimpleImmediateCoverStatement> {
|
pub(crate) fn simple_immediate_cover_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SimpleImmediateCoverStatement> {
|
||||||
let (s, a) = keyword("cover")(s)?;
|
let (s, a) = keyword("cover")(s)?;
|
||||||
let (s, b) = paren(expression)(s)?;
|
let (s, b) = paren(expression)(s)?;
|
||||||
let (s, c) = statement_or_null(s)?;
|
let (s, c) = statement_or_null(s)?;
|
||||||
@ -245,5 +171,3 @@ pub(crate) fn assert_timing(s: Span) -> IResult<Span, AssertTiming> {
|
|||||||
map(keyword("final"), |x| AssertTiming::Final(Box::new(x))),
|
map(keyword("final"), |x| AssertTiming::Final(Box::new(x))),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,137 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CaseStatement {
|
|
||||||
Normal(Box<CaseStatementNormal>),
|
|
||||||
Matches(Box<CaseStatementMatches>),
|
|
||||||
Inside(Box<CaseStatementInside>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseStatementNormal {
|
|
||||||
pub nodes: (
|
|
||||||
Option<UniquePriority>,
|
|
||||||
CaseKeyword,
|
|
||||||
Paren<CaseExpression>,
|
|
||||||
CaseItem,
|
|
||||||
Vec<CaseItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseStatementMatches {
|
|
||||||
pub nodes: (
|
|
||||||
Option<UniquePriority>,
|
|
||||||
CaseKeyword,
|
|
||||||
Paren<CaseExpression>,
|
|
||||||
Keyword,
|
|
||||||
CasePatternItem,
|
|
||||||
Vec<CasePatternItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseStatementInside {
|
|
||||||
pub nodes: (
|
|
||||||
Option<UniquePriority>,
|
|
||||||
Keyword,
|
|
||||||
Paren<CaseExpression>,
|
|
||||||
Keyword,
|
|
||||||
CaseInsideItem,
|
|
||||||
Vec<CaseInsideItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CaseKeyword {
|
|
||||||
Case(Box<Keyword>),
|
|
||||||
Casez(Box<Keyword>),
|
|
||||||
Casex(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseExpression {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CaseItem {
|
|
||||||
NonDefault(Box<CaseItemNondefault>),
|
|
||||||
Default(Box<CaseItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseItemNondefault {
|
|
||||||
pub nodes: (List<Symbol, CaseItemExpression>, Symbol, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseItemDefault {
|
|
||||||
pub nodes: (Keyword, Option<Symbol>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CasePatternItem {
|
|
||||||
NonDefault(Box<CasePatternItemNondefault>),
|
|
||||||
Default(Box<CaseItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CasePatternItemNondefault {
|
|
||||||
pub nodes: (
|
|
||||||
Pattern,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
Symbol,
|
|
||||||
StatementOrNull,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CaseInsideItem {
|
|
||||||
NonDefault(Box<CaseInsideItemNondefault>),
|
|
||||||
Default(Box<CaseItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseInsideItemNondefault {
|
|
||||||
pub nodes: (OpenRangeList, Symbol, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseItemExpression {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RandcaseStatement {
|
|
||||||
pub nodes: (Keyword, RandcaseItem, Vec<RandcaseItem>, Keyword),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RandcaseItem {
|
|
||||||
pub nodes: (Expression, Symbol, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OpenRangeList {
|
|
||||||
pub nodes: (List<Symbol, OpenValueRange>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OpenValueRange {
|
|
||||||
pub nodes: (ValueRange,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,193 +1,7 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClockingDeclaration {
|
|
||||||
Local(Box<ClockingDeclarationLocal>),
|
|
||||||
Global(Box<ClockingDeclarationGlobal>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDeclarationLocal {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Default>,
|
|
||||||
Keyword,
|
|
||||||
Option<ClockingIdentifier>,
|
|
||||||
ClockingEvent,
|
|
||||||
Symbol,
|
|
||||||
Vec<ClockingItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ClockingIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Default {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDeclarationGlobal {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
Option<ClockingIdentifier>,
|
|
||||||
ClockingEvent,
|
|
||||||
Symbol,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ClockingIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClockingEvent {
|
|
||||||
Identifier(Box<ClockingEventIdentifier>),
|
|
||||||
Expression(Box<ClockingEventExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingEventIdentifier {
|
|
||||||
pub nodes: (Symbol, Identifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingEventExpression {
|
|
||||||
pub nodes: (Symbol, Paren<EventExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClockingItem {
|
|
||||||
Default(Box<ClockingItemDefault>),
|
|
||||||
Direction(Box<ClockingItemDirection>),
|
|
||||||
Assertion(Box<ClockingItemAssertion>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingItemDefault {
|
|
||||||
pub nodes: (Keyword, DefaultSkew, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingItemDirection {
|
|
||||||
pub nodes: (ClockingDirection, ListOfClockingDeclAssign, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingItemAssertion {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, AssertionItemDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DefaultSkew {
|
|
||||||
Input(Box<DefaultSkewInput>),
|
|
||||||
Output(Box<DefaultSkewOutput>),
|
|
||||||
InputOutput(Box<DefaultSkewInputOutput>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DefaultSkewInput {
|
|
||||||
pub nodes: (Keyword, ClockingSkew),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DefaultSkewOutput {
|
|
||||||
pub nodes: (Keyword, ClockingSkew),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DefaultSkewInputOutput {
|
|
||||||
pub nodes: (Keyword, ClockingSkew, Keyword, ClockingSkew),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClockingDirection {
|
|
||||||
Input(Box<ClockingDirectionInput>),
|
|
||||||
Output(Box<ClockingDirectionOutput>),
|
|
||||||
InputOutput(Box<ClockingDirectionInputOutput>),
|
|
||||||
Inout(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDirectionInput {
|
|
||||||
pub nodes: (Keyword, Option<ClockingSkew>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDirectionOutput {
|
|
||||||
pub nodes: (Keyword, Option<ClockingSkew>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDirectionInputOutput {
|
|
||||||
pub nodes: (Keyword, Option<ClockingSkew>, Keyword, Option<ClockingSkew>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfClockingDeclAssign {
|
|
||||||
pub nodes: (List<Symbol, ClockingDeclAssign>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDeclAssign {
|
|
||||||
pub nodes: (SignalIdentifier, Option<(Symbol, Expression)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClockingSkew {
|
|
||||||
Edge(Box<ClockingSkewEdge>),
|
|
||||||
DelayControl(Box<DelayControl>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingSkewEdge {
|
|
||||||
pub nodes: (EdgeIdentifier, Option<DelayControl>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingDrive {
|
|
||||||
pub nodes: (ClockvarExpression, Symbol, Option<CycleDelay>, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CycleDelay {
|
|
||||||
Integral(Box<CycleDelayIntegral>),
|
|
||||||
Identifier(Box<CycleDelayIdentifier>),
|
|
||||||
Expression(Box<CycleDelayExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayIntegral {
|
|
||||||
pub nodes: (Symbol, IntegralNumber),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayIdentifier {
|
|
||||||
pub nodes: (Symbol, Identifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayExpression {
|
|
||||||
pub nodes: (Symbol, Paren<Expression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Clockvar {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockvarExpression {
|
|
||||||
pub nodes: (Clockvar, Select),
|
|
||||||
}
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn clocking_declaration(s: Span) -> IResult<Span, ClockingDeclaration> {
|
pub(crate) fn clocking_declaration(s: Span) -> IResult<Span, ClockingDeclaration> {
|
||||||
alt((clocking_declaration_local, clocking_declaration_global))(s)
|
alt((clocking_declaration_local, clocking_declaration_global))(s)
|
||||||
@ -489,5 +303,3 @@ pub(crate) fn clockvar_expression(s: Span) -> IResult<Span, ClockvarExpression>
|
|||||||
let (s, b) = select(s)?;
|
let (s, b) = select(s)?;
|
||||||
Ok((s, ClockvarExpression { nodes: (a, b) }))
|
Ok((s, ClockvarExpression { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,47 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConditionalStatement {
|
|
||||||
pub nodes: (
|
|
||||||
Option<UniquePriority>,
|
|
||||||
Keyword,
|
|
||||||
Paren<CondPredicate>,
|
|
||||||
StatementOrNull,
|
|
||||||
Vec<(Keyword, Keyword, Paren<CondPredicate>, StatementOrNull)>,
|
|
||||||
Option<(Keyword, StatementOrNull)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UniquePriority {
|
|
||||||
Unique(Box<Keyword>),
|
|
||||||
Unique0(Box<Keyword>),
|
|
||||||
Priority(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CondPredicate {
|
|
||||||
pub nodes: (List<Symbol, ExpressionOrCondPattern>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ExpressionOrCondPattern {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
CondPattern(Box<CondPattern>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CondPattern {
|
|
||||||
pub nodes: (Expression, Keyword, Pattern),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,57 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ContinuousAssign {
|
|
||||||
Net(Box<ContinuousAssignNet>),
|
|
||||||
Variable(Box<ContinuousAssignVariable>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ContinuousAssignNet {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<DriveStrength>,
|
|
||||||
Option<Delay3>,
|
|
||||||
ListOfNetAssignments,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ContinuousAssignVariable {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<DelayControl>,
|
|
||||||
ListOfVariableAssignments,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfNetAssignments {
|
|
||||||
pub nodes: (List<Symbol, NetAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfVariableAssignments {
|
|
||||||
pub nodes: (List<Symbol, VariableAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetAlias {
|
|
||||||
pub nodes: (Keyword, NetLvalue, Symbol, List<Symbol, NetLvalue>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetAssignment {
|
|
||||||
pub nodes: (NetLvalue, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,107 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum LoopStatement {
|
|
||||||
Forever(Box<LoopStatementForever>),
|
|
||||||
Repeat(Box<LoopStatementRepeat>),
|
|
||||||
While(Box<LoopStatementWhile>),
|
|
||||||
For(Box<LoopStatementFor>),
|
|
||||||
DoWhile(Box<LoopStatementDoWhile>),
|
|
||||||
Foreach(Box<LoopStatementForeach>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementForever {
|
|
||||||
pub nodes: (Keyword, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementRepeat {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementWhile {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementFor {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
Option<ForInitialization>,
|
|
||||||
Symbol,
|
|
||||||
Option<Expression>,
|
|
||||||
Symbol,
|
|
||||||
Option<ForStep>,
|
|
||||||
)>,
|
|
||||||
StatementOrNull,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementDoWhile {
|
|
||||||
pub nodes: (Keyword, StatementOrNull, Keyword, Paren<Expression>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopStatementForeach {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(PsOrHierarchicalArrayIdentifier, Bracket<LoopVariables>)>,
|
|
||||||
Statement,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ForInitialization {
|
|
||||||
ListOfVariableAssignments(Box<ListOfVariableAssignments>),
|
|
||||||
Declaration(Box<ForInitializationDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ForInitializationDeclaration {
|
|
||||||
pub nodes: (List<Symbol, ForVariableDeclaration>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ForVariableDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Var>,
|
|
||||||
DataType,
|
|
||||||
List<Symbol, (VariableIdentifier, Symbol, Expression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Var {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ForStep {
|
|
||||||
pub nodes: (List<Symbol, ForStepAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ForStepAssignment {
|
|
||||||
OperatorAssignment(Box<OperatorAssignment>),
|
|
||||||
IncOrDecExpression(Box<IncOrDecExpression>),
|
|
||||||
FunctionSubroutineCall(Box<FunctionSubroutineCall>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopVariables {
|
|
||||||
pub nodes: (List<Symbol, Option<IndexVariableIdentifier>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -257,5 +154,3 @@ pub(crate) fn loop_variables(s: Span) -> IResult<Span, LoopVariables> {
|
|||||||
let (s, a) = list(symbol(","), opt(index_variable_identifier))(s)?;
|
let (s, a) = list(symbol(","), opt(index_variable_identifier))(s)?;
|
||||||
Ok((s, LoopVariables { nodes: (a,) }))
|
Ok((s, LoopVariables { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
26
sv-parser-parser/src/behavioral_statements/mod.rs
Normal file
26
sv-parser-parser/src/behavioral_statements/mod.rs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
pub mod assertion_statements;
|
||||||
|
pub mod case_statements;
|
||||||
|
pub mod clocking_block;
|
||||||
|
pub mod conditional_statements;
|
||||||
|
pub mod continuous_assignment_and_net_alias_statements;
|
||||||
|
pub mod looping_statements;
|
||||||
|
pub mod parallel_and_sequential_blocks;
|
||||||
|
pub mod patterns;
|
||||||
|
pub mod procedural_blocks_and_assignments;
|
||||||
|
pub mod randsequence;
|
||||||
|
pub mod statements;
|
||||||
|
pub mod subroutine_call_statements;
|
||||||
|
pub mod timing_control_statements;
|
||||||
|
pub(crate) use assertion_statements::*;
|
||||||
|
pub(crate) use case_statements::*;
|
||||||
|
pub(crate) use clocking_block::*;
|
||||||
|
pub(crate) use conditional_statements::*;
|
||||||
|
pub(crate) use continuous_assignment_and_net_alias_statements::*;
|
||||||
|
pub(crate) use looping_statements::*;
|
||||||
|
pub(crate) use parallel_and_sequential_blocks::*;
|
||||||
|
pub(crate) use patterns::*;
|
||||||
|
pub(crate) use procedural_blocks_and_assignments::*;
|
||||||
|
pub(crate) use randsequence::*;
|
||||||
|
pub(crate) use statements::*;
|
||||||
|
pub(crate) use subroutine_call_statements::*;
|
||||||
|
pub(crate) use timing_control_statements::*;
|
@ -1,54 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ActionBlock {
|
|
||||||
StatementOrNull(Box<StatementOrNull>),
|
|
||||||
Else(Box<ActionBlockElse>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ActionBlockElse {
|
|
||||||
pub nodes: (Option<Statement>, Keyword, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SeqBlock {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, BlockIdentifier)>,
|
|
||||||
Vec<BlockItemDeclaration>,
|
|
||||||
Vec<StatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, BlockIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParBlock {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, BlockIdentifier)>,
|
|
||||||
Vec<BlockItemDeclaration>,
|
|
||||||
Vec<StatementOrNull>,
|
|
||||||
JoinKeyword,
|
|
||||||
Option<(Symbol, BlockIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum JoinKeyword {
|
|
||||||
Join(Box<Keyword>),
|
|
||||||
JoinAny(Box<Keyword>),
|
|
||||||
JoinNone(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,116 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Pattern {
|
|
||||||
Variable(Box<PatternVariable>),
|
|
||||||
Asterisk(Box<Symbol>),
|
|
||||||
ConstantExpression(Box<ConstantExpression>),
|
|
||||||
Tagged(Box<PatternTagged>),
|
|
||||||
List(Box<PatternList>),
|
|
||||||
IdentifierList(Box<PatternIdentifierList>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PatternVariable {
|
|
||||||
pub nodes: (Symbol, VariableIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PatternTagged {
|
|
||||||
pub nodes: (Keyword, MemberIdentifier, Option<Pattern>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PatternList {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, Pattern>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PatternIdentifierList {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, (MemberIdentifier, Symbol, Pattern)>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssignmentPattern {
|
|
||||||
List(Box<AssignmentPatternList>),
|
|
||||||
Structure(Box<AssignmentPatternStructure>),
|
|
||||||
Array(Box<AssignmentPatternArray>),
|
|
||||||
Repeat(Box<AssignmentPatternRepeat>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternList {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, Expression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternStructure {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, (StructurePatternKey, Symbol, Expression)>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternArray {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, (ArrayPatternKey, Symbol, Expression)>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternRepeat {
|
|
||||||
pub nodes: (ApostropheBrace<(ConstantExpression, Brace<List<Symbol, Expression>>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum StructurePatternKey {
|
|
||||||
MemberIdentifier(Box<MemberIdentifier>),
|
|
||||||
AssignmentPatternKey(Box<AssignmentPatternKey>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ArrayPatternKey {
|
|
||||||
ConstantExpression(Box<ConstantExpression>),
|
|
||||||
AssignmentPatternKey(Box<AssignmentPatternKey>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssignmentPatternKey {
|
|
||||||
SimpleType(Box<SimpleType>),
|
|
||||||
Default(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternExpression {
|
|
||||||
pub nodes: (Option<AssignmentPatternExpressionType>, AssignmentPattern),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssignmentPatternExpressionType {
|
|
||||||
PsTypeIdentifier(Box<PsTypeIdentifier>),
|
|
||||||
PsParameterIdentifier(Box<PsParameterIdentifier>),
|
|
||||||
IntegerAtomType(Box<IntegerAtomType>),
|
|
||||||
TypeReference(Box<TypeReference>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantAssignmentPatternExpression {
|
|
||||||
pub nodes: (AssignmentPatternExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternNetLvalue {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, NetLvalue>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentPatternVariableLvalue {
|
|
||||||
pub nodes: (ApostropheBrace<List<Symbol, VariableLvalue>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -307,5 +195,3 @@ pub(crate) fn assignment_pattern_variable_lvalue(
|
|||||||
let (s, a) = apostrophe_brace(list(symbol(","), variable_lvalue))(s)?;
|
let (s, a) = apostrophe_brace(list(symbol(","), variable_lvalue))(s)?;
|
||||||
Ok((s, AssignmentPatternVariableLvalue { nodes: (a,) }))
|
Ok((s, AssignmentPatternVariableLvalue { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,127 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InitialConstruct {
|
|
||||||
pub nodes: (Keyword, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AlwaysConstruct {
|
|
||||||
pub nodes: (AlwaysKeyword, Statement),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AlwaysKeyword {
|
|
||||||
Always(Box<Keyword>),
|
|
||||||
AlwaysComb(Box<Keyword>),
|
|
||||||
AlwaysLatch(Box<Keyword>),
|
|
||||||
AlwaysFf(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FinalConstruct {
|
|
||||||
pub nodes: (Keyword, FunctionStatement),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BlockingAssignment {
|
|
||||||
Variable(Box<BlockingAssignmentVariable>),
|
|
||||||
NonrangeVariable(Box<BlockingAssignmentNonrangeVariable>),
|
|
||||||
HierarchicalVariable(Box<BlockingAssignmentHierarchicalVariable>),
|
|
||||||
OperatorAssignment(Box<OperatorAssignment>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockingAssignmentVariable {
|
|
||||||
pub nodes: (VariableLvalue, Symbol, DelayOrEventControl, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockingAssignmentNonrangeVariable {
|
|
||||||
pub nodes: (NonrangeVariableLvalue, Symbol, DynamicArrayNew),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockingAssignmentHierarchicalVariable {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ImplicitClassHandleOrClassScopeOrPackageScope>,
|
|
||||||
HierarchicalVariableIdentifier,
|
|
||||||
Select,
|
|
||||||
Symbol,
|
|
||||||
ClassNew,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OperatorAssignment {
|
|
||||||
pub nodes: (VariableLvalue, AssignmentOperator, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssignmentOperator {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonblockingAssignment {
|
|
||||||
pub nodes: (
|
|
||||||
VariableLvalue,
|
|
||||||
Symbol,
|
|
||||||
Option<DelayOrEventControl>,
|
|
||||||
Expression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProceduralContinuousAssignment {
|
|
||||||
Assign(Box<ProceduralContinuousAssignmentAssign>),
|
|
||||||
Deassign(Box<ProceduralContinuousAssignmentDeassign>),
|
|
||||||
ForceVariable(Box<ProceduralContinuousAssignmentForceVariable>),
|
|
||||||
ForceNet(Box<ProceduralContinuousAssignmentForceNet>),
|
|
||||||
ReleaseVariable(Box<ProceduralContinuousAssignmentReleaseVariable>),
|
|
||||||
ReleaseNet(Box<ProceduralContinuousAssignmentReleaseNet>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentAssign {
|
|
||||||
pub nodes: (Keyword, VariableAssignment),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentDeassign {
|
|
||||||
pub nodes: (Keyword, VariableLvalue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentForceVariable {
|
|
||||||
pub nodes: (Keyword, VariableAssignment),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentForceNet {
|
|
||||||
pub nodes: (Keyword, NetAssignment),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentReleaseVariable {
|
|
||||||
pub nodes: (Keyword, VariableLvalue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralContinuousAssignmentReleaseNet {
|
|
||||||
pub nodes: (Keyword, NetLvalue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableAssignment {
|
|
||||||
pub nodes: (VariableLvalue, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -202,7 +79,9 @@ pub(crate) fn blocking_assignment_nonrange_variable(s: Span) -> IResult<Span, Bl
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn blocking_assignment_hierarchical_variable(s: Span) -> IResult<Span, BlockingAssignment> {
|
pub(crate) fn blocking_assignment_hierarchical_variable(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, BlockingAssignment> {
|
||||||
let (s, a) = opt(implicit_class_handle_or_class_scope_or_package_scope)(s)?;
|
let (s, a) = opt(implicit_class_handle_or_class_scope_or_package_scope)(s)?;
|
||||||
let (s, b) = hierarchical_variable_identifier(s)?;
|
let (s, b) = hierarchical_variable_identifier(s)?;
|
||||||
let (s, c) = select(s)?;
|
let (s, c) = select(s)?;
|
||||||
@ -260,7 +139,9 @@ pub(crate) fn nonblocking_assignment(s: Span) -> IResult<Span, NonblockingAssign
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn procedural_continuous_assignment(s: Span) -> IResult<Span, ProceduralContinuousAssignment> {
|
pub(crate) fn procedural_continuous_assignment(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ProceduralContinuousAssignment> {
|
||||||
alt((
|
alt((
|
||||||
procedural_continuous_assignment_assign,
|
procedural_continuous_assignment_assign,
|
||||||
procedural_continuous_assignment_deassign,
|
procedural_continuous_assignment_deassign,
|
||||||
@ -362,19 +243,3 @@ pub(crate) fn variable_assignment(s: Span) -> IResult<Span, VariableAssignment>
|
|||||||
let (s, c) = expression(s)?;
|
let (s, c) = expression(s)?;
|
||||||
Ok((s, VariableAssignment { nodes: (a, b, c) }))
|
Ok((s, VariableAssignment { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_blocking_assignment() {
|
|
||||||
parser_test!(
|
|
||||||
blocking_assignment,
|
|
||||||
"idest = new [3] (isrc)",
|
|
||||||
Ok((_, BlockingAssignment::NonrangeVariable(_)))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RandsequenceStatement {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<Option<ProductionIdentifier>>,
|
|
||||||
Production,
|
|
||||||
Vec<Production>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Production {
|
|
||||||
pub nodes: (
|
|
||||||
Option<DataTypeOrVoid>,
|
|
||||||
ProductionIdentifier,
|
|
||||||
Option<Paren<TfPortList>>,
|
|
||||||
Symbol,
|
|
||||||
List<Symbol, RsRule>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsRule {
|
|
||||||
pub nodes: (
|
|
||||||
RsProductionList,
|
|
||||||
Option<(Symbol, WeightSpecification, Option<RsCodeBlock>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RsProductionList {
|
|
||||||
Prod(Box<RsProductionListProd>),
|
|
||||||
Join(Box<RsProductionListJoin>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsProductionListProd {
|
|
||||||
pub nodes: (RsProd, Vec<RsProd>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsProductionListJoin {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
Option<Paren<Expression>>,
|
|
||||||
ProductionItem,
|
|
||||||
ProductionItem,
|
|
||||||
Vec<ProductionItem>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum WeightSpecification {
|
|
||||||
IntegralNumber(Box<IntegralNumber>),
|
|
||||||
PsIdentifier(Box<PsIdentifier>),
|
|
||||||
Expression(Box<WeightSpecificationExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WeightSpecificationExpression {
|
|
||||||
pub nodes: (Paren<Expression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsCodeBlock {
|
|
||||||
pub nodes: (Brace<(Vec<DataDeclaration>, Vec<StatementOrNull>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RsProd {
|
|
||||||
ProductionItem(Box<ProductionItem>),
|
|
||||||
RsCodeBlock(Box<RsCodeBlock>),
|
|
||||||
RsIfElse(Box<RsIfElse>),
|
|
||||||
RsRepeat(Box<RsRepeat>),
|
|
||||||
RsCase(Box<RsCase>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProductionItem {
|
|
||||||
pub nodes: (ProductionIdentifier, Option<Paren<ListOfArguments>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsIfElse {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<Expression>,
|
|
||||||
ProductionItem,
|
|
||||||
Option<(Keyword, ProductionItem)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsRepeat {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, ProductionItem),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsCase {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<CaseExpression>,
|
|
||||||
RsCaseItem,
|
|
||||||
Vec<RsCaseItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RsCaseItem {
|
|
||||||
NonDefault(Box<RsCaseItemNondefault>),
|
|
||||||
Default(Box<RsCaseItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsCaseItemNondefault {
|
|
||||||
pub nodes: (
|
|
||||||
List<Symbol, CaseItemExpression>,
|
|
||||||
Symbol,
|
|
||||||
ProductionItem,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RsCaseItemDefault {
|
|
||||||
pub nodes: (Keyword, Option<Symbol>, ProductionItem, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,77 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum StatementOrNull {
|
|
||||||
Statement(Box<Statement>),
|
|
||||||
Attribute(Box<StatementOrNullAttribute>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StatementOrNullAttribute {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Statement {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(BlockIdentifier, Symbol)>,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
StatementItem,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum StatementItem {
|
|
||||||
BlockingAssignment(Box<(BlockingAssignment, Symbol)>),
|
|
||||||
NonblockingAssignment(Box<(NonblockingAssignment, Symbol)>),
|
|
||||||
ProceduralContinuousAssignment(Box<(ProceduralContinuousAssignment, Symbol)>),
|
|
||||||
CaseStatement(Box<CaseStatement>),
|
|
||||||
ConditionalStatement(Box<ConditionalStatement>),
|
|
||||||
IncOrDecExpression(Box<(IncOrDecExpression, Symbol)>),
|
|
||||||
SubroutineCallStatement(Box<SubroutineCallStatement>),
|
|
||||||
DisableStatement(Box<DisableStatement>),
|
|
||||||
EventTrigger(Box<EventTrigger>),
|
|
||||||
LoopStatement(Box<LoopStatement>),
|
|
||||||
JumpStatement(Box<JumpStatement>),
|
|
||||||
ParBlock(Box<ParBlock>),
|
|
||||||
ProceduralTimingControlStatement(Box<ProceduralTimingControlStatement>),
|
|
||||||
SeqBlock(Box<SeqBlock>),
|
|
||||||
WaitStatement(Box<WaitStatement>),
|
|
||||||
ProceduralAssertionStatement(Box<ProceduralAssertionStatement>),
|
|
||||||
ClockingDrive(Box<(ClockingDrive, Symbol)>),
|
|
||||||
RandsequenceStatement(Box<RandsequenceStatement>),
|
|
||||||
RandcaseStatement(Box<RandcaseStatement>),
|
|
||||||
ExpectPropertyStatement(Box<ExpectPropertyStatement>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionStatement {
|
|
||||||
pub nodes: (Statement,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum FunctionStatementOrNull {
|
|
||||||
Statement(Box<FunctionStatement>),
|
|
||||||
Attribute(Box<FunctionStatementOrNullAttribute>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionStatementOrNullAttribute {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableIdentifierList {
|
|
||||||
pub nodes: (List<Symbol, VariableIdentifier>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -178,7 +105,9 @@ pub(crate) fn function_statement_or_null(s: Span) -> IResult<Span, FunctionState
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn function_statement_or_null_attribute(s: Span) -> IResult<Span, FunctionStatementOrNull> {
|
pub(crate) fn function_statement_or_null_attribute(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, FunctionStatementOrNull> {
|
||||||
let (s, a) = many0(attribute_instance)(s)?;
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
let (s, b) = symbol(";")(s)?;
|
let (s, b) = symbol(";")(s)?;
|
||||||
Ok((
|
Ok((
|
@ -1,22 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SubroutineCallStatement {
|
|
||||||
SubroutineCall(Box<(SubroutineCall, Symbol)>),
|
|
||||||
Function(Box<SubroutineCallStatementFunction>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SubroutineCallStatementFunction {
|
|
||||||
pub nodes: (Keyword, Symbol, Paren<FunctionSubroutineCall>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -31,7 +13,9 @@ pub(crate) fn subroutine_call_statement(s: Span) -> IResult<Span, SubroutineCall
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn subroutine_call_statement_function(s: Span) -> IResult<Span, SubroutineCallStatement> {
|
pub(crate) fn subroutine_call_statement_function(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SubroutineCallStatement> {
|
||||||
let (s, a) = keyword("void")(s)?;
|
let (s, a) = keyword("void")(s)?;
|
||||||
let (s, b) = symbol("'")(s)?;
|
let (s, b) = symbol("'")(s)?;
|
||||||
let (s, c) = paren(function_subroutine_call)(s)?;
|
let (s, c) = paren(function_subroutine_call)(s)?;
|
||||||
@ -43,5 +27,3 @@ pub(crate) fn subroutine_call_statement_function(s: Span) -> IResult<Span, Subro
|
|||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,214 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProceduralTimingControlStatement {
|
|
||||||
pub nodes: (ProceduralTimingControl, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DelayOrEventControl {
|
|
||||||
Delay(Box<DelayControl>),
|
|
||||||
Event(Box<EventControl>),
|
|
||||||
Repeat(Box<DelayOrEventControlRepeat>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DelayOrEventControlRepeat {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, EventControl),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DelayControl {
|
|
||||||
Delay(Box<DelayControlDelay>),
|
|
||||||
Mintypmax(Box<DelayControlMintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DelayControlDelay {
|
|
||||||
pub nodes: (Symbol, DelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DelayControlMintypmax {
|
|
||||||
pub nodes: (Symbol, Paren<MintypmaxExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EventControl {
|
|
||||||
EventIdentifier(Box<EventControlEventIdentifier>),
|
|
||||||
EventExpression(Box<EventControlEventExpression>),
|
|
||||||
Asterisk(Box<EventControlAsterisk>),
|
|
||||||
ParenAsterisk(Box<EventControlParenAsterisk>),
|
|
||||||
SequenceIdentifier(Box<EventControlSequenceIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventControlEventIdentifier {
|
|
||||||
pub nodes: (Symbol, HierarchicalEventIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventControlEventExpression {
|
|
||||||
pub nodes: (Symbol, Paren<EventExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventControlAsterisk {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventControlParenAsterisk {
|
|
||||||
pub nodes: (Symbol, Paren<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventControlSequenceIdentifier {
|
|
||||||
pub nodes: (Symbol, PsOrHierarchicalSequenceIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EventExpression {
|
|
||||||
Expression(Box<EventExpressionExpression>),
|
|
||||||
Sequence(Box<EventExpressionSequence>),
|
|
||||||
Or(Box<EventExpressionOr>),
|
|
||||||
Comma(Box<EventExpressionComma>),
|
|
||||||
Paren(Box<EventExpressionParen>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventExpressionExpression {
|
|
||||||
pub nodes: (
|
|
||||||
Option<EdgeIdentifier>,
|
|
||||||
Expression,
|
|
||||||
Option<(Keyword, Expression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventExpressionSequence {
|
|
||||||
pub nodes: (SequenceInstance, Option<(Keyword, Expression)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventExpressionOr {
|
|
||||||
pub nodes: (EventExpression, Keyword, EventExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventExpressionComma {
|
|
||||||
pub nodes: (EventExpression, Symbol, EventExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventExpressionParen {
|
|
||||||
pub nodes: (Paren<EventExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProceduralTimingControl {
|
|
||||||
DelayControl(Box<DelayControl>),
|
|
||||||
EventControl(Box<EventControl>),
|
|
||||||
CycleDelay(Box<CycleDelay>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum JumpStatement {
|
|
||||||
Return(Box<JumpStatementReturn>),
|
|
||||||
Break(Box<JumpStatementBreak>),
|
|
||||||
Continue(Box<JumpStatementContinue>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct JumpStatementReturn {
|
|
||||||
pub nodes: (Keyword, Option<Expression>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct JumpStatementBreak {
|
|
||||||
pub nodes: (Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct JumpStatementContinue {
|
|
||||||
pub nodes: (Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum WaitStatement {
|
|
||||||
Wait(Box<WaitStatementWait>),
|
|
||||||
Fork(Box<WaitStatementFork>),
|
|
||||||
Order(Box<WaitStatementOrder>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WaitStatementWait {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WaitStatementFork {
|
|
||||||
pub nodes: (Keyword, Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WaitStatementOrder {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<List<Symbol, HierarchicalIdentifier>>,
|
|
||||||
ActionBlock,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EventTrigger {
|
|
||||||
Named(Box<EventTriggerNamed>),
|
|
||||||
Nonblocking(Box<EventTriggerNonblocking>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventTriggerNamed {
|
|
||||||
pub nodes: (Symbol, HierarchicalEventIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventTriggerNonblocking {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Option<DelayOrEventControl>,
|
|
||||||
HierarchicalEventIdentifier,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DisableStatement {
|
|
||||||
Task(Box<DisableStatementTask>),
|
|
||||||
Block(Box<DisableStatementBlock>),
|
|
||||||
Fork(Box<DisableStatementFork>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DisableStatementTask {
|
|
||||||
pub nodes: (Keyword, HierarchicalTaskIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DisableStatementBlock {
|
|
||||||
pub nodes: (Keyword, HierarchicalBlockIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DisableStatementFork {
|
|
||||||
pub nodes: (Keyword, Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,671 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConcurrentAssertionItem {
|
|
||||||
Statement(Box<ConcurrentAssertionItemStatement>),
|
|
||||||
CheckerInstantiation(Box<CheckerInstantiation>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConcurrentAssertionItemStatement {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(BlockIdentifier, Symbol)>,
|
|
||||||
ConcurrentAssertionStatement,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConcurrentAssertionStatement {
|
|
||||||
AssertPropertyStatement(Box<AssertPropertyStatement>),
|
|
||||||
AssumePropertyStatement(Box<AssumePropertyStatement>),
|
|
||||||
CoverPropertyStatement(Box<CoverPropertyStatement>),
|
|
||||||
CoverSequenceStatement(Box<CoverSequenceStatement>),
|
|
||||||
RestrictPropertyStatement(Box<RestrictPropertyStatement>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssertPropertyStatement {
|
|
||||||
pub nodes: (Keyword, Keyword, Paren<PropertySpec>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssumePropertyStatement {
|
|
||||||
pub nodes: (Keyword, Keyword, Paren<PropertySpec>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverPropertyStatement {
|
|
||||||
pub nodes: (Keyword, Keyword, Paren<PropertySpec>, StatementOrNull),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExpectPropertyStatement {
|
|
||||||
pub nodes: (Keyword, Paren<PropertySpec>, ActionBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverSequenceStatement {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
Option<ClockingEvent>,
|
|
||||||
Option<(Keyword, Keyword, Paren<ExpressionOrDist>)>,
|
|
||||||
SequenceExpr,
|
|
||||||
)>,
|
|
||||||
StatementOrNull,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RestrictPropertyStatement {
|
|
||||||
pub nodes: (Keyword, Keyword, Paren<PropertySpec>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyInstance {
|
|
||||||
pub nodes: (
|
|
||||||
PsOrHierarchicalPropertyIdentifier,
|
|
||||||
Option<Paren<Option<PropertyListOfArguments>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyListOfArguments {
|
|
||||||
Ordered(Box<PropertyListOfArgumentsOrdered>),
|
|
||||||
Named(Box<PropertyListOfArgumentsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyListOfArgumentsOrdered {
|
|
||||||
pub nodes: (
|
|
||||||
List<Symbol, Option<PropertyActualArg>>,
|
|
||||||
Vec<(Symbol, Symbol, Identifier, Paren<Option<PropertyActualArg>>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyListOfArgumentsNamed {
|
|
||||||
pub nodes: (List<Symbol, (Symbol, Identifier, Paren<Option<PropertyActualArg>>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyActualArg {
|
|
||||||
PropertyExpr(Box<PropertyExpr>),
|
|
||||||
SequenceActualArg(Box<SequenceActualArg>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssertionItemDeclaration {
|
|
||||||
PropertyDeclaration(Box<PropertyDeclaration>),
|
|
||||||
SequenceDeclaration(Box<SequenceDeclaration>),
|
|
||||||
LetDeclaration(Box<LetDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
PropertyIdentifier,
|
|
||||||
Option<Paren<Option<PropertyPortList>>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<AssertionVariableDeclaration>,
|
|
||||||
PropertySpec,
|
|
||||||
Option<Symbol>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, PropertyIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyPortList {
|
|
||||||
pub nodes: (List<Symbol, PropertyPortItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyPortItem {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<(Local, Option<PropertyLvarPortDirection>)>,
|
|
||||||
Option<PropertyFormalType>,
|
|
||||||
FormalPortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, PropertyActualArg)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyLvarPortDirection {
|
|
||||||
Input(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyFormalType {
|
|
||||||
SequenceFormalType(Box<SequenceFormalType>),
|
|
||||||
Property(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertySpec {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ClockingEvent>,
|
|
||||||
Option<(Keyword, Keyword, Paren<ExpressionOrDist>)>,
|
|
||||||
PropertyExpr,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyExpr {
|
|
||||||
SequenceExpr(Box<SequenceExpr>),
|
|
||||||
Strong(Box<PropertyExprStrong>),
|
|
||||||
Weak(Box<PropertyExprWeak>),
|
|
||||||
Paren(Box<PropertyExprParen>),
|
|
||||||
Not(Box<PropertyExprNot>),
|
|
||||||
Or(Box<PropertyExprOr>),
|
|
||||||
And(Box<PropertyExprAnd>),
|
|
||||||
ImplicationOverlapped(Box<PropertyExprImplicationOverlapped>),
|
|
||||||
ImplicationNonoverlapped(Box<PropertyExprImplicationNonoverlapped>),
|
|
||||||
If(Box<PropertyExprIf>),
|
|
||||||
Case(Box<PropertyExprCase>),
|
|
||||||
FollowedByOverlapped(Box<PropertyExprFollowedByOverlapped>),
|
|
||||||
FollowedByNonoverlapped(Box<PropertyExprFollowedByNonoverlapped>),
|
|
||||||
Nexttime(Box<PropertyExprNexttime>),
|
|
||||||
SNexttime(Box<PropertyExprSNexttime>),
|
|
||||||
Always(Box<PropertyExprAlways>),
|
|
||||||
SAlways(Box<PropertyExprSAlways>),
|
|
||||||
Eventually(Box<PropertyExprEventually>),
|
|
||||||
SEventually(Box<PropertyExprSEventually>),
|
|
||||||
Until(Box<PropertyExprUntil>),
|
|
||||||
SUntil(Box<PropertyExprSUntil>),
|
|
||||||
UntilWith(Box<PropertyExprUntilWith>),
|
|
||||||
SUntilWith(Box<PropertyExprSUntilWith>),
|
|
||||||
Implies(Box<PropertyExprImplies>),
|
|
||||||
Iff(Box<PropertyExprIff>),
|
|
||||||
AcceptOn(Box<PropertyExprAcceptOn>),
|
|
||||||
RejectOn(Box<PropertyExprRejectOn>),
|
|
||||||
SyncAcceptOn(Box<PropertyExprSyncAcceptOn>),
|
|
||||||
SyncRejectOn(Box<PropertyExprSyncRejectOn>),
|
|
||||||
PropertyInstance(Box<PropertyInstance>),
|
|
||||||
ClockingEvent(Box<PropertyExprClockingEvent>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprStrong {
|
|
||||||
pub nodes: (Keyword, Paren<SequenceExpr>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprWeak {
|
|
||||||
pub nodes: (Keyword, Paren<SequenceExpr>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprParen {
|
|
||||||
pub nodes: (Paren<SequenceExpr>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprNot {
|
|
||||||
pub nodes: (Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprOr {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprAnd {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprImplicationOverlapped {
|
|
||||||
pub nodes: (SequenceExpr, Symbol, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprImplicationNonoverlapped {
|
|
||||||
pub nodes: (SequenceExpr, Symbol, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprIf {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<ExpressionOrDist>,
|
|
||||||
PropertyExpr,
|
|
||||||
Option<(Keyword, PropertyExpr)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprCase {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<ExpressionOrDist>,
|
|
||||||
PropertyCaseItem,
|
|
||||||
Vec<PropertyCaseItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprFollowedByOverlapped {
|
|
||||||
pub nodes: (SequenceExpr, Symbol, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprFollowedByNonoverlapped {
|
|
||||||
pub nodes: (SequenceExpr, Symbol, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprNexttime {
|
|
||||||
pub nodes: (Keyword, Option<Bracket<ConstantExpression>>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSNexttime {
|
|
||||||
pub nodes: (Keyword, Option<Bracket<ConstantExpression>>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprAlways {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<Bracket<CycleDelayConstRangeExpression>>,
|
|
||||||
PropertyExpr,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSAlways {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Bracket<CycleDelayConstRangeExpression>,
|
|
||||||
PropertyExpr,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprEventually {
|
|
||||||
pub nodes: (Keyword, Bracket<ConstantRange>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSEventually {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<Bracket<CycleDelayConstRangeExpression>>,
|
|
||||||
PropertyExpr,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprUntil {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSUntil {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprUntilWith {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSUntilWith {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprImplies {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprIff {
|
|
||||||
pub nodes: (PropertyExpr, Keyword, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprAcceptOn {
|
|
||||||
pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprRejectOn {
|
|
||||||
pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSyncAcceptOn {
|
|
||||||
pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprSyncRejectOn {
|
|
||||||
pub nodes: (Keyword, Paren<ExpressionOrDist>, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyExprClockingEvent {
|
|
||||||
pub nodes: (ClockingEvent, PropertyExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyCaseItem {
|
|
||||||
Nondefault(Box<PropertyCaseItemNondefault>),
|
|
||||||
Default(Box<PropertyCaseItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyCaseItemNondefault {
|
|
||||||
pub nodes: (List<Symbol, ExpressionOrDist>, Symbol, PropertyExpr, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyCaseItemDefault {
|
|
||||||
pub nodes: (Keyword, Option<Symbol>, PropertyExpr, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
SequenceIdentifier,
|
|
||||||
Option<Paren<Option<SequencePortList>>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<AssertionVariableDeclaration>,
|
|
||||||
SequenceExpr,
|
|
||||||
Option<Symbol>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, SequenceIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequencePortList {
|
|
||||||
pub nodes: (List<Symbol, SequencePortItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequencePortItem {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<(Local, Option<SequenceLvarPortDirection>)>,
|
|
||||||
Option<SequenceFormalType>,
|
|
||||||
FormalPortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, SequenceActualArg)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceLvarPortDirection {
|
|
||||||
Input(Box<Keyword>),
|
|
||||||
Inout(Box<Keyword>),
|
|
||||||
Output(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceFormalType {
|
|
||||||
DataTypeOrImplicit(Box<DataTypeOrImplicit>),
|
|
||||||
Sequence(Box<Keyword>),
|
|
||||||
Untyped(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceExpr {
|
|
||||||
CycleDelayExpr(Box<SequenceExprCycleDelayExpr>),
|
|
||||||
ExprCycleDelayExpr(Box<SequenceExprExprCycleDelayExpr>),
|
|
||||||
Expression(Box<SequenceExprExpression>),
|
|
||||||
Instance(Box<SequenceExprInstance>),
|
|
||||||
Paren(Box<SequenceExprParen>),
|
|
||||||
And(Box<SequenceExprAnd>),
|
|
||||||
Intersect(Box<SequenceExprIntersect>),
|
|
||||||
Or(Box<SequenceExprOr>),
|
|
||||||
FirstMatch(Box<SequenceExprFirstMatch>),
|
|
||||||
Throughout(Box<SequenceExprThroughout>),
|
|
||||||
Within(Box<SequenceExprWithin>),
|
|
||||||
ClockingEvent(Box<SequenceExprClockingEvent>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprCycleDelayExpr {
|
|
||||||
pub nodes: (
|
|
||||||
CycleDelayRange,
|
|
||||||
SequenceExpr,
|
|
||||||
Vec<(CycleDelayRange, SequenceExpr)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprExprCycleDelayExpr {
|
|
||||||
pub nodes: (
|
|
||||||
SequenceExpr,
|
|
||||||
CycleDelayRange,
|
|
||||||
SequenceExpr,
|
|
||||||
Vec<(CycleDelayRange, SequenceExpr)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprExpression {
|
|
||||||
pub nodes: (ExpressionOrDist, Option<BooleanAbbrev>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprInstance {
|
|
||||||
pub nodes: (SequenceInstance, Option<SequenceAbbrev>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprParen {
|
|
||||||
pub nodes: (
|
|
||||||
Paren<(SequenceExpr, Vec<(Symbol, SequenceMatchItem)>)>,
|
|
||||||
Option<SequenceAbbrev>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprAnd {
|
|
||||||
pub nodes: (SequenceExpr, Keyword, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprIntersect {
|
|
||||||
pub nodes: (SequenceExpr, Keyword, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprOr {
|
|
||||||
pub nodes: (SequenceExpr, Keyword, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprFirstMatch {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(SequenceExpr, Vec<(Symbol, SequenceMatchItem)>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprThroughout {
|
|
||||||
pub nodes: (ExpressionOrDist, Keyword, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprWithin {
|
|
||||||
pub nodes: (SequenceExpr, Keyword, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceExprClockingEvent {
|
|
||||||
pub nodes: (ClockingEvent, SequenceExpr),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CycleDelayRange {
|
|
||||||
Primary(Box<CycleDelayRangePrimary>),
|
|
||||||
Expression(Box<CycleDelayRangeExpression>),
|
|
||||||
Asterisk(Box<CycleDelayRangeAsterisk>),
|
|
||||||
Plus(Box<CycleDelayRangePlus>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayRangePrimary {
|
|
||||||
pub nodes: (Symbol, ConstantPrimary),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayRangeExpression {
|
|
||||||
pub nodes: (Symbol, Bracket<CycleDelayConstRangeExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayRangeAsterisk {
|
|
||||||
pub nodes: (Symbol, Bracket<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayRangePlus {
|
|
||||||
pub nodes: (Symbol, Bracket<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceMethodCall {
|
|
||||||
pub nodes: (SequenceInstance, Symbol, MethodIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceMatchItem {
|
|
||||||
OperatorAssignment(Box<OperatorAssignment>),
|
|
||||||
IncOrDecExpression(Box<IncOrDecExpression>),
|
|
||||||
SubroutineCall(Box<SubroutineCall>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceInstance {
|
|
||||||
pub nodes: (
|
|
||||||
PsOrHierarchicalSequenceIdentifier,
|
|
||||||
Option<Paren<Option<SequenceListOfArguments>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceListOfArguments {
|
|
||||||
Ordered(Box<SequenceListOfArgumentsOrdered>),
|
|
||||||
Named(Box<SequenceListOfArgumentsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceListOfArgumentsOrdered {
|
|
||||||
pub nodes: (
|
|
||||||
List<Symbol, Option<SequenceActualArg>>,
|
|
||||||
Vec<(Symbol, Symbol, Identifier, Paren<Option<SequenceActualArg>>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceListOfArgumentsNamed {
|
|
||||||
pub nodes: (List<Symbol, (Symbol, Identifier, Paren<Option<SequenceActualArg>>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SequenceActualArg {
|
|
||||||
EventExpression(Box<EventExpression>),
|
|
||||||
SequenceExpr(Box<SequenceExpr>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BooleanAbbrev {
|
|
||||||
ConsecutiveRepetition(Box<ConsecutiveRepetition>),
|
|
||||||
NonConsecutiveRepetition(Box<NonConsecutiveRepetition>),
|
|
||||||
GotoRepetition(Box<GotoRepetition>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceAbbrev {
|
|
||||||
pub nodes: (ConsecutiveRepetition,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConsecutiveRepetition {
|
|
||||||
Expression(Box<ConsecutiveRepetitionExpression>),
|
|
||||||
Asterisk(Box<ConsecutiveRepetitionAsterisk>),
|
|
||||||
Plus(Box<ConsecutiveRepetitionPlus>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConsecutiveRepetitionExpression {
|
|
||||||
pub nodes: (Bracket<(Symbol, ConstOrRangeExpression)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConsecutiveRepetitionAsterisk {
|
|
||||||
pub nodes: (Bracket<Symbol>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConsecutiveRepetitionPlus {
|
|
||||||
pub nodes: (Bracket<Symbol>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonConsecutiveRepetition {
|
|
||||||
pub nodes: (Bracket<(Symbol, ConstOrRangeExpression)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GotoRepetition {
|
|
||||||
pub nodes: (Bracket<(Symbol, ConstOrRangeExpression)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstOrRangeExpression {
|
|
||||||
ConstantExpression(Box<ConstantExpression>),
|
|
||||||
CycleDelayConstRangeExpression(Box<CycleDelayConstRangeExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CycleDelayConstRangeExpression {
|
|
||||||
Binary(Box<CycleDelayConstRangeExpressionBinary>),
|
|
||||||
Dollar(Box<CycleDelayConstRangeExpressionDollar>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayConstRangeExpressionBinary {
|
|
||||||
pub nodes: (ConstantExpression, Symbol, ConstantExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CycleDelayConstRangeExpressionDollar {
|
|
||||||
pub nodes: (ConstantExpression, Symbol, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExpressionOrDist {
|
|
||||||
pub nodes: (Expression, Option<(Keyword, Brace<DistList>)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssertionVariableDeclaration {
|
|
||||||
pub nodes: (VarDataType, ListOfVariableDeclAssignments, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -680,7 +13,9 @@ pub(crate) fn concurrent_assertion_item(s: Span) -> IResult<Span, ConcurrentAsse
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn concurrent_assertion_item_statement(s: Span) -> IResult<Span, ConcurrentAssertionItem> {
|
pub(crate) fn concurrent_assertion_item_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ConcurrentAssertionItem> {
|
||||||
let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?;
|
let (s, a) = opt(pair(block_identifier, symbol(":")))(s)?;
|
||||||
let (s, b) = concurrent_assertion_statement(s)?;
|
let (s, b) = concurrent_assertion_statement(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
@ -692,7 +27,9 @@ pub(crate) fn concurrent_assertion_item_statement(s: Span) -> IResult<Span, Conc
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn concurrent_assertion_statement(s: Span) -> IResult<Span, ConcurrentAssertionStatement> {
|
pub(crate) fn concurrent_assertion_statement(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ConcurrentAssertionStatement> {
|
||||||
alt((
|
alt((
|
||||||
map(assert_property_statement, |x| {
|
map(assert_property_statement, |x| {
|
||||||
ConcurrentAssertionStatement::AssertPropertyStatement(Box::new(x))
|
ConcurrentAssertionStatement::AssertPropertyStatement(Box::new(x))
|
||||||
@ -814,7 +151,9 @@ pub(crate) fn property_list_of_arguments(s: Span) -> IResult<Span, PropertyListO
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(MaybeRecursive)]
|
#[parser(MaybeRecursive)]
|
||||||
pub(crate) fn property_list_of_arguments_ordered(s: Span) -> IResult<Span, PropertyListOfArguments> {
|
pub(crate) fn property_list_of_arguments_ordered(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, PropertyListOfArguments> {
|
||||||
let (s, a) = list(symbol(","), opt(property_actual_arg))(s)?;
|
let (s, a) = list(symbol(","), opt(property_actual_arg))(s)?;
|
||||||
let (s, b) = many0(tuple((
|
let (s, b) = many0(tuple((
|
||||||
symbol(","),
|
symbol(","),
|
||||||
@ -1658,7 +997,9 @@ pub(crate) fn sequence_list_of_arguments(s: Span) -> IResult<Span, SequenceListO
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(MaybeRecursive)]
|
#[parser(MaybeRecursive)]
|
||||||
pub(crate) fn sequence_list_of_arguments_ordered(s: Span) -> IResult<Span, SequenceListOfArguments> {
|
pub(crate) fn sequence_list_of_arguments_ordered(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SequenceListOfArguments> {
|
||||||
let (s, a) = list(symbol(","), opt(sequence_actual_arg))(s)?;
|
let (s, a) = list(symbol(","), opt(sequence_actual_arg))(s)?;
|
||||||
let (s, b) = many0(tuple((
|
let (s, b) = many0(tuple((
|
||||||
symbol(","),
|
symbol(","),
|
||||||
@ -1829,7 +1170,9 @@ pub(crate) fn expression_or_dist(s: Span) -> IResult<Span, ExpressionOrDist> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn assertion_variable_declaration(s: Span) -> IResult<Span, AssertionVariableDeclaration> {
|
pub(crate) fn assertion_variable_declaration(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, AssertionVariableDeclaration> {
|
||||||
let (s, a) = var_data_type(s)?;
|
let (s, a) = var_data_type(s)?;
|
||||||
let (s, b) = list_of_variable_decl_assignments(s)?;
|
let (s, b) = list_of_variable_decl_assignments(s)?;
|
||||||
let (s, c) = symbol(";")(s)?;
|
let (s, c) = symbol(";")(s)?;
|
@ -1,38 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BlockItemDeclaration {
|
|
||||||
Data(Box<BlockItemDeclarationData>),
|
|
||||||
LocalParameter(Box<BlockItemDeclarationLocalParameter>),
|
|
||||||
Parameter(Box<BlockItemDeclarationParameter>),
|
|
||||||
Let(Box<BlockItemDeclarationLet>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockItemDeclarationData {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, DataDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockItemDeclarationLocalParameter {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, LocalParameterDeclaration, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockItemDeclarationParameter {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ParameterDeclaration, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockItemDeclarationLet {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, LetDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -57,7 +23,9 @@ pub(crate) fn block_item_declaration_data(s: Span) -> IResult<Span, BlockItemDec
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn block_item_declaration_local_parameter(s: Span) -> IResult<Span, BlockItemDeclaration> {
|
pub(crate) fn block_item_declaration_local_parameter(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, BlockItemDeclaration> {
|
||||||
let (s, a) = many0(attribute_instance)(s)?;
|
let (s, a) = many0(attribute_instance)(s)?;
|
||||||
let (s, b) = local_parameter_declaration(s)?;
|
let (s, b) = local_parameter_declaration(s)?;
|
||||||
let (s, c) = symbol(";")(s)?;
|
let (s, c) = symbol(";")(s)?;
|
@ -1,477 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
CovergroupIdentifier,
|
|
||||||
Option<Paren<Option<TfPortList>>>,
|
|
||||||
Option<CoverageEvent>,
|
|
||||||
Symbol,
|
|
||||||
Vec<CoverageSpecOrOption>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, CovergroupIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CoverageSpecOrOption {
|
|
||||||
Spec(Box<CoverageSpecOrOptionSpec>),
|
|
||||||
Option(Box<CoverageSpecOrOptionOption>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageSpecOrOptionSpec {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, CoverageSpec),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageSpecOrOptionOption {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, CoverageOption, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CoverageOption {
|
|
||||||
Option(Box<CoverageOptionOption>),
|
|
||||||
TypeOption(Box<CoverageOptionTypeOption>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageOptionOption {
|
|
||||||
pub nodes: (Keyword, Symbol, MemberIdentifier, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageOptionTypeOption {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Symbol,
|
|
||||||
MemberIdentifier,
|
|
||||||
Symbol,
|
|
||||||
ConstantExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CoverageSpec {
|
|
||||||
CoverPoint(Box<CoverPoint>),
|
|
||||||
CoverCross(Box<CoverCross>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CoverageEvent {
|
|
||||||
ClockingEvent(Box<ClockingEvent>),
|
|
||||||
Sample(Box<CoverageEventSample>),
|
|
||||||
At(Box<CoverageEventAt>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageEventSample {
|
|
||||||
pub nodes: (Keyword, Keyword, Keyword, Paren<Option<TfPortList>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverageEventAt {
|
|
||||||
pub nodes: (Symbol, Paren<BlockEventExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BlockEventExpression {
|
|
||||||
Or(Box<BlockEventExpressionOr>),
|
|
||||||
Begin(Box<BlockEventExpressionBegin>),
|
|
||||||
End(Box<BlockEventExpressionEnd>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockEventExpressionOr {
|
|
||||||
pub nodes: (BlockEventExpression, Keyword, BlockEventExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockEventExpressionBegin {
|
|
||||||
pub nodes: (Keyword, HierarchicalBtfIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockEventExpressionEnd {
|
|
||||||
pub nodes: (Keyword, HierarchicalBtfIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum HierarchicalBtfIdentifier {
|
|
||||||
HierarchicalTfIdentifier(Box<HierarchicalTfIdentifier>),
|
|
||||||
HierarchicalBlockIdentifier(Box<HierarchicalBlockIdentifier>),
|
|
||||||
Method(Box<HierarchicalBtfIdentifierMethod>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalBtfIdentifierMethod {
|
|
||||||
pub nodes: (Option<HierarchicalIdentifierOrClassScope>, MethodIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum HierarchicalIdentifierOrClassScope {
|
|
||||||
HierarchicalIdentifier(Box<(HierarchicalIdentifier, Symbol)>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverPoint {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(Option<DataTypeOrImplicit>, CoverPointIdentifier, Symbol)>,
|
|
||||||
Keyword,
|
|
||||||
Expression,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
BinsOrEmpty,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BinsOrEmpty {
|
|
||||||
NonEmpty(Box<BinsOrEmptyNonEmpty>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrEmptyNonEmpty {
|
|
||||||
pub nodes: (Brace<(Vec<AttributeInstance>, Vec<(BinsOrOptions, Symbol)>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BinsOrOptions {
|
|
||||||
CoverageOption(Box<CoverageOption>),
|
|
||||||
Covergroup(Box<BinsOrOptionsCovergroup>),
|
|
||||||
CoverPoint(Box<BinsOrOptionsCoverPoint>),
|
|
||||||
SetCovergroup(Box<BinsOrOptionsSetCovergroup>),
|
|
||||||
TransList(Box<BinsOrOptionsTransList>),
|
|
||||||
Default(Box<BinsOrOptionsDefault>),
|
|
||||||
DefaultSequence(Box<BinsOrOptionsDefaultSequence>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsCovergroup {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Wildcard>,
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Option<Bracket<Option<CovergroupExpression>>>,
|
|
||||||
Symbol,
|
|
||||||
Brace<CovergroupRangeList>,
|
|
||||||
Option<(Keyword, Paren<WithCovergroupExpression>)>,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Wildcard {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsCoverPoint {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Wildcard>,
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Option<Bracket<Option<CovergroupExpression>>>,
|
|
||||||
Symbol,
|
|
||||||
CoverPointIdentifier,
|
|
||||||
Keyword,
|
|
||||||
Paren<WithCovergroupExpression>,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsSetCovergroup {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Wildcard>,
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Option<Bracket<Option<CovergroupExpression>>>,
|
|
||||||
Symbol,
|
|
||||||
SetCovergroupExpression,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsTransList {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Wildcard>,
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Option<(Symbol, Symbol)>,
|
|
||||||
Symbol,
|
|
||||||
TransList,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsDefault {
|
|
||||||
pub nodes: (
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Option<Bracket<Option<CovergroupExpression>>>,
|
|
||||||
Symbol,
|
|
||||||
Keyword,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsOrOptionsDefaultSequence {
|
|
||||||
pub nodes: (
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Symbol,
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BinsKeyword {
|
|
||||||
Bins(Box<Keyword>),
|
|
||||||
IllegalBins(Box<Keyword>),
|
|
||||||
IgnoreBins(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransList {
|
|
||||||
pub nodes: (List<Symbol, Paren<TransSet>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransSet {
|
|
||||||
pub nodes: (List<Symbol, TransRangeList>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TransRangeList {
|
|
||||||
TransItem(Box<TransItem>),
|
|
||||||
Asterisk(Box<TransRangeListAsterisk>),
|
|
||||||
Arrow(Box<TransRangeListArrow>),
|
|
||||||
Equal(Box<TransRangeListEqual>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransRangeListAsterisk {
|
|
||||||
pub nodes: (TransItem, Bracket<(Symbol, RepeatRange)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransRangeListArrow {
|
|
||||||
pub nodes: (TransItem, Bracket<(Symbol, RepeatRange)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransRangeListEqual {
|
|
||||||
pub nodes: (TransItem, Bracket<(Symbol, RepeatRange)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TransItem {
|
|
||||||
pub nodes: (CovergroupRangeList,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RepeatRange {
|
|
||||||
CovergroupExpression(Box<CovergroupExpression>),
|
|
||||||
Binary(Box<RepeatRangeBinary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RepeatRangeBinary {
|
|
||||||
pub nodes: (CovergroupExpression, Symbol, CovergroupExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverCross {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(CrossIdentifier, Symbol)>,
|
|
||||||
Keyword,
|
|
||||||
ListOfCrossItems,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
CrossBody,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfCrossItems {
|
|
||||||
pub nodes: (CrossItem, List<Symbol, CrossItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CrossItem {
|
|
||||||
CoverPointIdentifier(Box<CoverPointIdentifier>),
|
|
||||||
VariableIdentifier(Box<VariableIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CrossBody {
|
|
||||||
NonEmpty(Box<CrossBodyNonEmpty>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CrossBodyNonEmpty {
|
|
||||||
pub nodes: (Brace<Vec<(CrossBodyItem, Symbol)>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CrossBodyItem {
|
|
||||||
FunctionDeclaration(Box<FunctionDeclaration>),
|
|
||||||
BinsSelectionOrOption(Box<(BinsSelectionOrOption, Symbol)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BinsSelectionOrOption {
|
|
||||||
Coverage(Box<BinsSelectionOrOptionCoverage>),
|
|
||||||
Bins(Box<BinsSelectionOrOptionBins>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsSelectionOrOptionCoverage {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, CoverageOption),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsSelectionOrOptionBins {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, BinsSelection),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsSelection {
|
|
||||||
pub nodes: (
|
|
||||||
BinsKeyword,
|
|
||||||
BinIdentifier,
|
|
||||||
Symbol,
|
|
||||||
SelectExpression,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SelectExpression {
|
|
||||||
SelectCondition(Box<SelectCondition>),
|
|
||||||
Not(Box<SelectExpressionNot>),
|
|
||||||
And(Box<SelectExpressionAnd>),
|
|
||||||
Or(Box<SelectExpressionOr>),
|
|
||||||
Paren(Box<SelectExpressionParen>),
|
|
||||||
With(Box<SelectExpressionWith>),
|
|
||||||
CrossIdentifier(Box<CrossIdentifier>),
|
|
||||||
CrossSet(Box<SelectExpressionCrossSet>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionNot {
|
|
||||||
pub nodes: (Symbol, SelectCondition),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionAnd {
|
|
||||||
pub nodes: (SelectExpression, Symbol, SelectExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionOr {
|
|
||||||
pub nodes: (SelectExpression, Symbol, SelectExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionParen {
|
|
||||||
pub nodes: (Paren<SelectExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionWith {
|
|
||||||
pub nodes: (
|
|
||||||
SelectExpression,
|
|
||||||
Keyword,
|
|
||||||
Paren<WithCovergroupExpression>,
|
|
||||||
Option<(Keyword, IntegerCovergroupExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectExpressionCrossSet {
|
|
||||||
pub nodes: (
|
|
||||||
CrossSetExpression,
|
|
||||||
Option<(Keyword, IntegerCovergroupExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SelectCondition {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<BinsExpression>,
|
|
||||||
Option<(Keyword, Brace<CovergroupRangeList>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BinsExpression {
|
|
||||||
VariableIdentifier(Box<VariableIdentifier>),
|
|
||||||
CoverPoint(Box<BinsExpressionCoverPoint>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinsExpressionCoverPoint {
|
|
||||||
pub nodes: (CoverPointIdentifier, Option<(Symbol, BinIdentifier)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupRangeList {
|
|
||||||
pub nodes: (List<Symbol, CovergroupValueRange>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CovergroupValueRange {
|
|
||||||
CovergroupExpression(Box<CovergroupExpression>),
|
|
||||||
Binary(Box<CovergroupValueRangeBinary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupValueRangeBinary {
|
|
||||||
pub nodes: (Bracket<(CovergroupExpression, Symbol, CovergroupExpression)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WithCovergroupExpression {
|
|
||||||
pub nodes: (CovergroupExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SetCovergroupExpression {
|
|
||||||
pub nodes: (CovergroupExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IntegerCovergroupExpression {
|
|
||||||
pub nodes: (CovergroupExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CrossSetExpression {
|
|
||||||
pub nodes: (CovergroupExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupExpression {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -651,7 +178,9 @@ pub(crate) fn hierarchical_btf_identifier(s: Span) -> IResult<Span, Hierarchical
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn hierarchical_btf_identifier_method(s: Span) -> IResult<Span, HierarchicalBtfIdentifier> {
|
pub(crate) fn hierarchical_btf_identifier_method(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, HierarchicalBtfIdentifier> {
|
||||||
let (s, a) = opt(hierarchical_identifier_or_class_scope)(s)?;
|
let (s, a) = opt(hierarchical_identifier_or_class_scope)(s)?;
|
||||||
let (s, b) = method_identifier(s)?;
|
let (s, b) = method_identifier(s)?;
|
||||||
Ok((
|
Ok((
|
@ -1,149 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DefparamAssignment {
|
|
||||||
pub nodes: (
|
|
||||||
HierarchicalParameterIdentifier,
|
|
||||||
Symbol,
|
|
||||||
ConstantMintypmaxExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetDeclAssignment {
|
|
||||||
pub nodes: (
|
|
||||||
NetIdentifier,
|
|
||||||
Vec<UnpackedDimension>,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParamAssignment {
|
|
||||||
pub nodes: (
|
|
||||||
ParameterIdentifier,
|
|
||||||
Vec<UnpackedDimension>,
|
|
||||||
Option<(Symbol, ConstantParamExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SpecparamAssignment {
|
|
||||||
Mintypmax(Box<SpecparamAssignmentMintypmax>),
|
|
||||||
PulseControlSpecparam(Box<PulseControlSpecparam>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SpecparamAssignmentMintypmax {
|
|
||||||
pub nodes: (SpecparamIdentifier, Symbol, ConstantMintypmaxExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TypeAssignment {
|
|
||||||
pub nodes: (TypeIdentifier, Option<(Symbol, DataType)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PulseControlSpecparam {
|
|
||||||
WithoutDescriptor(Box<PulseControlSpecparamWithoutDescriptor>),
|
|
||||||
WithDescriptor(Box<PulseControlSpecparamWithDescriptor>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulseControlSpecparamWithoutDescriptor {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Symbol,
|
|
||||||
Paren<(RejectLimitValue, Option<(Symbol, ErrorLimitValue)>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulseControlSpecparamWithDescriptor {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
SpecifyInputTerminalDescriptor,
|
|
||||||
Symbol,
|
|
||||||
SpecifyOutputTerminalDescriptor,
|
|
||||||
Symbol,
|
|
||||||
Paren<(RejectLimitValue, Option<(Symbol, ErrorLimitValue)>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ErrorLimitValue {
|
|
||||||
pub nodes: (LimitValue,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RejectLimitValue {
|
|
||||||
pub nodes: (LimitValue,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LimitValue {
|
|
||||||
pub nodes: (ConstantMintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum VariableDeclAssignment {
|
|
||||||
Variable(Box<VariableDeclAssignmentVariable>),
|
|
||||||
DynamicArray(Box<VariableDeclAssignmentDynamicArray>),
|
|
||||||
Class(Box<VariableDeclAssignmentClass>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableDeclAssignmentVariable {
|
|
||||||
pub nodes: (
|
|
||||||
VariableIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableDeclAssignmentDynamicArray {
|
|
||||||
pub nodes: (
|
|
||||||
DynamicArrayVariableIdentifier,
|
|
||||||
UnsizedDimension,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, DynamicArrayNew)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableDeclAssignmentClass {
|
|
||||||
pub nodes: (ClassVariableIdentifier, Option<(Symbol, ClassNew)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassNew {
|
|
||||||
Argument(Box<ClassNewArgument>),
|
|
||||||
Expression(Box<ClassNewExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassNewArgument {
|
|
||||||
pub nodes: (Option<ClassScope>, Keyword, Option<Paren<ListOfArguments>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassNewExpression {
|
|
||||||
pub nodes: (Keyword, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DynamicArrayNew {
|
|
||||||
pub nodes: (Keyword, Bracket<Expression>, Option<Paren<Expression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -208,7 +63,9 @@ pub(crate) fn pulse_control_specparam(s: Span) -> IResult<Span, PulseControlSpec
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn pulse_control_specparam_without_descriptor(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
pub(crate) fn pulse_control_specparam_without_descriptor(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, PulseControlSpecparam> {
|
||||||
let (s, a) = symbol("PATHPULSE$")(s)?;
|
let (s, a) = symbol("PATHPULSE$")(s)?;
|
||||||
let (s, b) = symbol("=")(s)?;
|
let (s, b) = symbol("=")(s)?;
|
||||||
let (s, c) = paren(pair(
|
let (s, c) = paren(pair(
|
||||||
@ -224,7 +81,9 @@ pub(crate) fn pulse_control_specparam_without_descriptor(s: Span) -> IResult<Spa
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn pulse_control_specparam_with_descriptor(s: Span) -> IResult<Span, PulseControlSpecparam> {
|
pub(crate) fn pulse_control_specparam_with_descriptor(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, PulseControlSpecparam> {
|
||||||
let (s, a) = symbol("PATHPULSE$")(s)?;
|
let (s, a) = symbol("PATHPULSE$")(s)?;
|
||||||
let (s, b) = specify_input_terminal_descriptor(s)?;
|
let (s, b) = specify_input_terminal_descriptor(s)?;
|
||||||
let (s, c) = symbol("$")(s)?;
|
let (s, c) = symbol("$")(s)?;
|
||||||
@ -283,7 +142,9 @@ pub(crate) fn variable_decl_assignment_variable(s: Span) -> IResult<Span, Variab
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn variable_decl_assignment_dynamic_array(s: Span) -> IResult<Span, VariableDeclAssignment> {
|
pub(crate) fn variable_decl_assignment_dynamic_array(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, VariableDeclAssignment> {
|
||||||
let (s, a) = dynamic_array_variable_identifier(s)?;
|
let (s, a) = dynamic_array_variable_identifier(s)?;
|
||||||
let (s, b) = unsized_dimension(s)?;
|
let (s, b) = unsized_dimension(s)?;
|
||||||
let (s, c) = many0(variable_dimension)(s)?;
|
let (s, c) = many0(variable_dimension)(s)?;
|
@ -1,94 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfDefparamAssignments {
|
|
||||||
pub nodes: (List<Symbol, DefparamAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfGenvarIdentifiers {
|
|
||||||
pub nodes: (List<Symbol, GenvarIdentifier>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfInterfaceIdentifiers {
|
|
||||||
pub nodes: (List<Symbol, (InterfaceIdentifier, Vec<UnpackedDimension>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfNetDeclAssignments {
|
|
||||||
pub nodes: (List<Symbol, NetDeclAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfParamAssignments {
|
|
||||||
pub nodes: (List<Symbol, ParamAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPortIdentifiers {
|
|
||||||
pub nodes: (List<Symbol, (PortIdentifier, Vec<UnpackedDimension>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfUdpPortIdentifiers {
|
|
||||||
pub nodes: (List<Symbol, PortIdentifier>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfSpecparamAssignments {
|
|
||||||
pub nodes: (List<Symbol, SpecparamAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfTfVariableIdentifiers {
|
|
||||||
pub nodes: (
|
|
||||||
List<
|
|
||||||
Symbol,
|
|
||||||
(
|
|
||||||
PortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfTypeAssignments {
|
|
||||||
pub nodes: (List<Symbol, TypeAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfVariableDeclAssignments {
|
|
||||||
pub nodes: (List<Symbol, VariableDeclAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfVariableIdentifiers {
|
|
||||||
pub nodes: (List<Symbol, (VariableIdentifier, Vec<VariableDimension>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfVariablePortIdentifiers {
|
|
||||||
pub nodes: (
|
|
||||||
List<
|
|
||||||
Symbol,
|
|
||||||
(
|
|
||||||
PortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -147,7 +57,9 @@ pub(crate) fn list_of_specparam_assignments(s: Span) -> IResult<Span, ListOfSpec
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn list_of_tf_variable_identifiers(s: Span) -> IResult<Span, ListOfTfVariableIdentifiers> {
|
pub(crate) fn list_of_tf_variable_identifiers(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfTfVariableIdentifiers> {
|
||||||
let (s, a) = list(
|
let (s, a) = list(
|
||||||
symbol(","),
|
symbol(","),
|
||||||
triple(
|
triple(
|
||||||
@ -166,7 +78,9 @@ pub(crate) fn list_of_type_assignments(s: Span) -> IResult<Span, ListOfTypeAssig
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn list_of_variable_decl_assignments(s: Span) -> IResult<Span, ListOfVariableDeclAssignments> {
|
pub(crate) fn list_of_variable_decl_assignments(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfVariableDeclAssignments> {
|
||||||
let (s, a) = list(symbol(","), variable_decl_assignment)(s)?;
|
let (s, a) = list(symbol(","), variable_decl_assignment)(s)?;
|
||||||
Ok((s, ListOfVariableDeclAssignments { nodes: (a,) }))
|
Ok((s, ListOfVariableDeclAssignments { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
@ -181,7 +95,9 @@ pub(crate) fn list_of_variable_identifiers(s: Span) -> IResult<Span, ListOfVaria
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn list_of_variable_port_identifiers(s: Span) -> IResult<Span, ListOfVariablePortIdentifiers> {
|
pub(crate) fn list_of_variable_port_identifiers(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfVariablePortIdentifiers> {
|
||||||
let (s, a) = list(
|
let (s, a) = list(
|
||||||
symbol(","),
|
symbol(","),
|
||||||
triple(
|
triple(
|
@ -1,72 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UnpackedDimension {
|
|
||||||
Range(Box<UnpackedDimensionRange>),
|
|
||||||
Expression(Box<UnpackedDimensionExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UnpackedDimensionRange {
|
|
||||||
pub nodes: (Bracket<ConstantRange>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UnpackedDimensionExpression {
|
|
||||||
pub nodes: (Bracket<ConstantExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PackedDimension {
|
|
||||||
Range(Box<PackedDimensionRange>),
|
|
||||||
UnsizedDimension(Box<UnsizedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PackedDimensionRange {
|
|
||||||
pub nodes: (Bracket<ConstantRange>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AssociativeDimension {
|
|
||||||
DataType(Box<AssociativeDimensionDataType>),
|
|
||||||
Asterisk(Box<AssociativeDimensionAsterisk>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssociativeDimensionDataType {
|
|
||||||
pub nodes: (Bracket<DataType>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AssociativeDimensionAsterisk {
|
|
||||||
pub nodes: (Bracket<Symbol>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum VariableDimension {
|
|
||||||
UnsizedDimension(Box<UnsizedDimension>),
|
|
||||||
UnpackedDimension(Box<UnpackedDimension>),
|
|
||||||
AssociativeDimension(Box<AssociativeDimension>),
|
|
||||||
QueueDimension(Box<QueueDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct QueueDimension {
|
|
||||||
pub nodes: (Bracket<(Symbol, Option<(Symbol, ConstantExpression)>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UnsizedDimension {
|
|
||||||
pub nodes: (Symbol, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,65 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Delay3 {
|
|
||||||
Single(Box<Delay3Single>),
|
|
||||||
Mintypmax(Box<Delay3Mintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Delay3Single {
|
|
||||||
pub nodes: (Symbol, DelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Delay3Mintypmax {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Paren<(
|
|
||||||
MintypmaxExpression,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
MintypmaxExpression,
|
|
||||||
Option<(Symbol, MintypmaxExpression)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Delay2 {
|
|
||||||
Single(Box<Delay2Single>),
|
|
||||||
Mintypmax(Box<Delay2Mintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Delay2Single {
|
|
||||||
pub nodes: (Symbol, DelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Delay2Mintypmax {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Paren<(MintypmaxExpression, Option<(Symbol, MintypmaxExpression)>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DelayValue {
|
|
||||||
UnsignedNumber(Box<UnsignedNumber>),
|
|
||||||
RealNumber(Box<RealNumber>),
|
|
||||||
PsIdentifier(Box<PsIdentifier>),
|
|
||||||
TimeLiteral(Box<TimeLiteral>),
|
|
||||||
Step1(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,157 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum FunctionDataTypeOrImplicit {
|
|
||||||
DataTypeOrVoid(Box<DataTypeOrVoid>),
|
|
||||||
ImplicitDataType(Box<ImplicitDataType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionDeclaration {
|
|
||||||
pub nodes: (Keyword, Option<Lifetime>, FunctionBodyDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum FunctionBodyDeclaration {
|
|
||||||
WithoutPort(Box<FunctionBodyDeclarationWithoutPort>),
|
|
||||||
WithPort(Box<FunctionBodyDeclarationWithPort>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionBodyDeclarationWithoutPort {
|
|
||||||
pub nodes: (
|
|
||||||
Option<FunctionDataTypeOrImplicit>,
|
|
||||||
Option<InterfaceIdentifierOrClassScope>,
|
|
||||||
FunctionIdentifier,
|
|
||||||
Symbol,
|
|
||||||
Vec<TfItemDeclaration>,
|
|
||||||
Vec<FunctionStatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, FunctionIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionBodyDeclarationWithPort {
|
|
||||||
pub nodes: (
|
|
||||||
Option<FunctionDataTypeOrImplicit>,
|
|
||||||
Option<InterfaceIdentifierOrClassScope>,
|
|
||||||
FunctionIdentifier,
|
|
||||||
Paren<Option<TfPortList>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<BlockItemDeclaration>,
|
|
||||||
Vec<FunctionStatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, FunctionIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfaceIdentifierOrClassScope {
|
|
||||||
InterfaceIdentifier(Box<(InterfaceIdentifier, Symbol)>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionPrototype {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
DataTypeOrVoid,
|
|
||||||
FunctionIdentifier,
|
|
||||||
Option<Paren<Option<TfPortList>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DpiImportExport {
|
|
||||||
ImportFunction(Box<DpiImportExportImportFunction>),
|
|
||||||
ImportTask(Box<DpiImportExportImportTask>),
|
|
||||||
ExportFunction(Box<DpiImportExportExportFunction>),
|
|
||||||
ExportTask(Box<DpiImportExportExportTask>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiImportExportImportFunction {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
DpiSpecString,
|
|
||||||
Option<DpiFunctionImportProperty>,
|
|
||||||
Option<(CIdentifier, Symbol)>,
|
|
||||||
DpiFunctionProto,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiImportExportImportTask {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
DpiSpecString,
|
|
||||||
Option<DpiTaskImportProperty>,
|
|
||||||
Option<(CIdentifier, Symbol)>,
|
|
||||||
DpiTaskProto,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiImportExportExportFunction {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
DpiSpecString,
|
|
||||||
Option<(CIdentifier, Symbol)>,
|
|
||||||
Keyword,
|
|
||||||
FunctionIdentifier,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiImportExportExportTask {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
DpiSpecString,
|
|
||||||
Option<(CIdentifier, Symbol)>,
|
|
||||||
Keyword,
|
|
||||||
TaskIdentifier,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DpiSpecString {
|
|
||||||
DpiC(Box<Keyword>),
|
|
||||||
Dpi(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DpiFunctionImportProperty {
|
|
||||||
Context(Box<Keyword>),
|
|
||||||
Pure(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DpiTaskImportProperty {
|
|
||||||
Context(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiFunctionProto {
|
|
||||||
pub nodes: (FunctionPrototype,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DpiTaskProto {
|
|
||||||
pub nodes: (TaskPrototype,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -184,7 +31,9 @@ pub(crate) fn function_body_declaration(s: Span) -> IResult<Span, FunctionBodyDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(Ambiguous)]
|
#[parser(Ambiguous)]
|
||||||
pub(crate) fn function_body_declaration_without_port(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
pub(crate) fn function_body_declaration_without_port(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, FunctionBodyDeclaration> {
|
||||||
let (s, a) = ambiguous_opt(function_data_type_or_implicit)(s)?;
|
let (s, a) = ambiguous_opt(function_data_type_or_implicit)(s)?;
|
||||||
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
let (s, c) = function_identifier(s)?;
|
let (s, c) = function_identifier(s)?;
|
||||||
@ -202,7 +51,9 @@ pub(crate) fn function_body_declaration_without_port(s: Span) -> IResult<Span, F
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(Ambiguous)]
|
#[parser(Ambiguous)]
|
||||||
pub(crate) fn function_body_declaration_with_port(s: Span) -> IResult<Span, FunctionBodyDeclaration> {
|
pub(crate) fn function_body_declaration_with_port(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, FunctionBodyDeclaration> {
|
||||||
let (s, a) = ambiguous_opt(function_data_type_or_implicit)(s)?;
|
let (s, a) = ambiguous_opt(function_data_type_or_implicit)(s)?;
|
||||||
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
let (s, b) = opt(interface_identifier_or_class_scope)(s)?;
|
||||||
let (s, c) = function_identifier(s)?;
|
let (s, c) = function_identifier(s)?;
|
@ -1,89 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportDeclaration {
|
|
||||||
pub nodes: (Keyword, List<Symbol, ModportItem>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportItem {
|
|
||||||
pub nodes: (
|
|
||||||
ModportIdentifier,
|
|
||||||
Paren<List<Symbol, ModportPortsDeclaraton>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModportPortsDeclaraton {
|
|
||||||
Simple(Box<ModportPortsDeclaratonSimple>),
|
|
||||||
Tf(Box<ModportPortsDeclaratonTf>),
|
|
||||||
Clocking(Box<ModportPortsDeclaratonClocking>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportPortsDeclaratonSimple {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModportSimplePortsDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportPortsDeclaratonTf {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModportTfPortsDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportPortsDeclaratonClocking {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModportClockingDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportClockingDeclaration {
|
|
||||||
pub nodes: (Keyword, ClockingIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportSimplePortsDeclaration {
|
|
||||||
pub nodes: (PortDirection, List<Symbol, ModportSimplePort>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModportSimplePort {
|
|
||||||
Ordered(Box<ModportSimplePortOrdered>),
|
|
||||||
Named(Box<ModportSimplePortNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportSimplePortOrdered {
|
|
||||||
pub nodes: (PortIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportSimplePortNamed {
|
|
||||||
pub nodes: (Symbol, PortIdentifier, Paren<Option<Expression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportTfPortsDeclaration {
|
|
||||||
pub nodes: (ImportExport, List<Symbol, ModportTfPort>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModportTfPort {
|
|
||||||
MethodPrototype(Box<MethodPrototype>),
|
|
||||||
TfIdentifier(Box<TfIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImportExport {
|
|
||||||
Import(Box<Keyword>),
|
|
||||||
Export(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -151,7 +66,9 @@ pub(crate) fn modport_clocking_declaration(s: Span) -> IResult<Span, ModportCloc
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn modport_simple_ports_declaration(s: Span) -> IResult<Span, ModportSimplePortsDeclaration> {
|
pub(crate) fn modport_simple_ports_declaration(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ModportSimplePortsDeclaration> {
|
||||||
let (s, a) = port_direction(s)?;
|
let (s, a) = port_direction(s)?;
|
||||||
let (s, b) = list(symbol(","), modport_simple_port)(s)?;
|
let (s, b) = list(symbol(","), modport_simple_port)(s)?;
|
||||||
Ok((s, ModportSimplePortsDeclaration { nodes: (a, b) }))
|
Ok((s, ModportSimplePortsDeclaration { nodes: (a, b) }))
|
@ -1,84 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
LetIdentifier,
|
|
||||||
Option<Paren<Option<LetPortList>>>,
|
|
||||||
Symbol,
|
|
||||||
Expression,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetPortList {
|
|
||||||
pub nodes: (List<Symbol, LetPortItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetPortItem {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<LetFormalType>,
|
|
||||||
FormalPortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum LetFormalType {
|
|
||||||
DataTypeOrImplicit(Box<DataTypeOrImplicit>),
|
|
||||||
Untyped(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetExpression {
|
|
||||||
pub nodes: (
|
|
||||||
Option<PackageScope>,
|
|
||||||
LetIdentifier,
|
|
||||||
Option<Paren<Option<LetListOfArguments>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum LetListOfArguments {
|
|
||||||
Ordered(Box<LetListOfArgumentsOrdered>),
|
|
||||||
Named(Box<LetListOfArgumentsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetListOfArgumentsOrdered {
|
|
||||||
pub nodes: (
|
|
||||||
List<Symbol, Option<LetActualArg>>,
|
|
||||||
Vec<(Symbol, Symbol, Identifier, Paren<Option<LetActualArg>>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetListOfArgumentsNamed {
|
|
||||||
pub nodes: (List<Symbol, (Symbol, Identifier, Paren<Option<LetActualArg>>)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LetActualArg {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
32
sv-parser-parser/src/declarations/mod.rs
Normal file
32
sv-parser-parser/src/declarations/mod.rs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
pub mod assertion_declarations;
|
||||||
|
pub mod block_item_declarations;
|
||||||
|
pub mod covergroup_declarations;
|
||||||
|
pub mod declaration_assignments;
|
||||||
|
pub mod declaration_lists;
|
||||||
|
pub mod declaration_ranges;
|
||||||
|
pub mod delays;
|
||||||
|
pub mod function_declarations;
|
||||||
|
pub mod interface_declarations;
|
||||||
|
pub mod let_declarations;
|
||||||
|
pub mod module_parameter_declarations;
|
||||||
|
pub mod net_and_variable_types;
|
||||||
|
pub mod port_declarations;
|
||||||
|
pub mod strengths;
|
||||||
|
pub mod task_declarations;
|
||||||
|
pub mod type_declarations;
|
||||||
|
pub(crate) use assertion_declarations::*;
|
||||||
|
pub(crate) use block_item_declarations::*;
|
||||||
|
pub(crate) use covergroup_declarations::*;
|
||||||
|
pub(crate) use declaration_assignments::*;
|
||||||
|
pub(crate) use declaration_lists::*;
|
||||||
|
pub(crate) use declaration_ranges::*;
|
||||||
|
pub(crate) use delays::*;
|
||||||
|
pub(crate) use function_declarations::*;
|
||||||
|
pub(crate) use interface_declarations::*;
|
||||||
|
pub(crate) use let_declarations::*;
|
||||||
|
pub(crate) use module_parameter_declarations::*;
|
||||||
|
pub(crate) use net_and_variable_types::*;
|
||||||
|
pub(crate) use port_declarations::*;
|
||||||
|
pub(crate) use strengths::*;
|
||||||
|
pub(crate) use task_declarations::*;
|
||||||
|
pub(crate) use type_declarations::*;
|
@ -0,0 +1,82 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn local_parameter_declaration(s: Span) -> IResult<Span, LocalParameterDeclaration> {
|
||||||
|
alt((
|
||||||
|
local_parameter_declaration_param,
|
||||||
|
local_parameter_declaration_type,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser(Ambiguous)]
|
||||||
|
pub(crate) fn local_parameter_declaration_param(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, LocalParameterDeclaration> {
|
||||||
|
let (s, a) = keyword("localparam")(s)?;
|
||||||
|
let (s, b) = ambiguous_opt(data_type_or_implicit)(s)?;
|
||||||
|
let (s, c) = list_of_param_assignments(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
LocalParameterDeclaration::Param(Box::new(LocalParameterDeclarationParam {
|
||||||
|
nodes: (a, b, c),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn local_parameter_declaration_type(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, LocalParameterDeclaration> {
|
||||||
|
let (s, a) = keyword("localparam")(s)?;
|
||||||
|
let (s, b) = keyword("type")(s)?;
|
||||||
|
let (s, c) = list_of_type_assignments(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
LocalParameterDeclaration::Type(Box::new(LocalParameterDeclarationType {
|
||||||
|
nodes: (a, b, c),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn parameter_declaration(s: Span) -> IResult<Span, ParameterDeclaration> {
|
||||||
|
alt((parameter_declaration_param, parameter_declaration_type))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser(Ambiguous)]
|
||||||
|
pub(crate) fn parameter_declaration_param(s: Span) -> IResult<Span, ParameterDeclaration> {
|
||||||
|
let (s, a) = keyword("parameter")(s)?;
|
||||||
|
let (s, b) = ambiguous_opt(data_type_or_implicit)(s)?;
|
||||||
|
let (s, c) = list_of_param_assignments(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ParameterDeclaration::Param(Box::new(ParameterDeclarationParam { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn parameter_declaration_type(s: Span) -> IResult<Span, ParameterDeclaration> {
|
||||||
|
let (s, a) = keyword("parameter")(s)?;
|
||||||
|
let (s, b) = keyword("type")(s)?;
|
||||||
|
let (s, c) = list_of_type_assignments(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
ParameterDeclaration::Type(Box::new(ParameterDeclarationType { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn specparam_declaration(s: Span) -> IResult<Span, SpecparamDeclaration> {
|
||||||
|
let (s, a) = keyword("specparam")(s)?;
|
||||||
|
let (s, b) = opt(packed_dimension)(s)?;
|
||||||
|
let (s, c) = list_of_specparam_assignments(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
SpecparamDeclaration {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
},
|
||||||
|
))
|
||||||
|
}
|
@ -1,288 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CastingType {
|
|
||||||
SimpleType(Box<SimpleType>),
|
|
||||||
ConstantPrimary(Box<ConstantPrimary>),
|
|
||||||
Signing(Box<Signing>),
|
|
||||||
String(Box<Keyword>),
|
|
||||||
Const(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DataType {
|
|
||||||
Vector(Box<DataTypeVector>),
|
|
||||||
Atom(Box<DataTypeAtom>),
|
|
||||||
NonIntegerType(Box<NonIntegerType>),
|
|
||||||
StructUnion(Box<DataTypeStructUnion>),
|
|
||||||
Enum(Box<DataTypeEnum>),
|
|
||||||
String(Box<Keyword>),
|
|
||||||
Chandle(Box<Keyword>),
|
|
||||||
Virtual(Box<DataTypeVirtual>),
|
|
||||||
Type(Box<DataTypeType>),
|
|
||||||
ClassType(Box<ClassType>),
|
|
||||||
Event(Box<Keyword>),
|
|
||||||
PsCovergroupIdentifier(Box<PsCovergroupIdentifier>),
|
|
||||||
TypeReference(Box<TypeReference>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeVector {
|
|
||||||
pub nodes: (IntegerVectorType, Option<Signing>, Vec<PackedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeAtom {
|
|
||||||
pub nodes: (IntegerAtomType, Option<Signing>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeStructUnion {
|
|
||||||
pub nodes: (
|
|
||||||
StructUnion,
|
|
||||||
Option<(Packed, Option<Signing>)>,
|
|
||||||
Brace<(StructUnionMember, Vec<StructUnionMember>)>,
|
|
||||||
Vec<PackedDimension>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Packed {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeEnum {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<EnumBaseType>,
|
|
||||||
Brace<List<Symbol, EnumNameDeclaration>>,
|
|
||||||
Vec<PackedDimension>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeVirtual {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<Interface>,
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Option<ParameterValueAssignment>,
|
|
||||||
Option<(Symbol, ModportIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Interface {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataTypeType {
|
|
||||||
pub nodes: (
|
|
||||||
Option<PackageScopeOrClassScope>,
|
|
||||||
TypeIdentifier,
|
|
||||||
Vec<PackedDimension>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DataTypeOrImplicit {
|
|
||||||
DataType(Box<DataType>),
|
|
||||||
ImplicitDataType(Box<ImplicitDataType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ImplicitDataType {
|
|
||||||
pub nodes: (Option<Signing>, Vec<PackedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EnumBaseType {
|
|
||||||
Atom(Box<EnumBaseTypeAtom>),
|
|
||||||
Vector(Box<EnumBaseTypeVector>),
|
|
||||||
Type(Box<EnumBaseTypeType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnumBaseTypeAtom {
|
|
||||||
pub nodes: (IntegerAtomType, Option<Signing>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnumBaseTypeVector {
|
|
||||||
pub nodes: (IntegerVectorType, Option<Signing>, Option<PackedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnumBaseTypeType {
|
|
||||||
pub nodes: (TypeIdentifier, Option<PackedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnumNameDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
EnumIdentifier,
|
|
||||||
Option<Bracket<(IntegralNumber, Option<(Symbol, IntegralNumber)>)>>,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassScope {
|
|
||||||
pub nodes: (ClassType, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassType {
|
|
||||||
pub nodes: (
|
|
||||||
PsClassIdentifier,
|
|
||||||
Option<ParameterValueAssignment>,
|
|
||||||
Vec<(Symbol, ClassIdentifier, Option<ParameterValueAssignment>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum IntegerType {
|
|
||||||
IntegerVectorType(Box<IntegerVectorType>),
|
|
||||||
IntegerAtomType(Box<IntegerAtomType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum IntegerAtomType {
|
|
||||||
Byte(Box<Keyword>),
|
|
||||||
Shortint(Box<Keyword>),
|
|
||||||
Int(Box<Keyword>),
|
|
||||||
Longint(Box<Keyword>),
|
|
||||||
Integer(Box<Keyword>),
|
|
||||||
Time(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum IntegerVectorType {
|
|
||||||
Bit(Box<Keyword>),
|
|
||||||
Logic(Box<Keyword>),
|
|
||||||
Reg(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NonIntegerType {
|
|
||||||
Shortreal(Box<Keyword>),
|
|
||||||
Real(Box<Keyword>),
|
|
||||||
Realtime(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NetType {
|
|
||||||
Supply0(Box<Keyword>),
|
|
||||||
Supply1(Box<Keyword>),
|
|
||||||
Tri(Box<Keyword>),
|
|
||||||
Triand(Box<Keyword>),
|
|
||||||
Trior(Box<Keyword>),
|
|
||||||
Trireg(Box<Keyword>),
|
|
||||||
Tri0(Box<Keyword>),
|
|
||||||
Tri1(Box<Keyword>),
|
|
||||||
Uwire(Box<Keyword>),
|
|
||||||
Wire(Box<Keyword>),
|
|
||||||
Wand(Box<Keyword>),
|
|
||||||
Wor(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NetPortType {
|
|
||||||
DataType(Box<NetPortTypeDataType>),
|
|
||||||
NetTypeIdentifier(Box<NetTypeIdentifier>),
|
|
||||||
Interconnect(Box<NetPortTypeInterconnect>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetPortTypeDataType {
|
|
||||||
pub nodes: (Option<NetType>, DataTypeOrImplicit),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetPortTypeInterconnect {
|
|
||||||
pub nodes: (Keyword, ImplicitDataType),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariablePortType {
|
|
||||||
pub nodes: (VarDataType,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum VarDataType {
|
|
||||||
DataType(Box<DataType>),
|
|
||||||
Var(Box<VarDataTypeVar>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VarDataTypeVar {
|
|
||||||
pub nodes: (Keyword, DataTypeOrImplicit),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Signing {
|
|
||||||
Signed(Box<Keyword>),
|
|
||||||
Unsigned(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SimpleType {
|
|
||||||
IntegerType(Box<IntegerType>),
|
|
||||||
NonIntegerType(Box<NonIntegerType>),
|
|
||||||
PsTypeIdentifier(Box<PsTypeIdentifier>),
|
|
||||||
PsParameterIdentifier(Box<PsParameterIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StructUnionMember {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<RandomQualifier>,
|
|
||||||
DataTypeOrVoid,
|
|
||||||
ListOfVariableDeclAssignments,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DataTypeOrVoid {
|
|
||||||
DataType(Box<DataType>),
|
|
||||||
Void(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum StructUnion {
|
|
||||||
Struct(Box<Keyword>),
|
|
||||||
Union(Box<Keyword>),
|
|
||||||
UnionTagged(Box<(Keyword, Keyword)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TypeReference {
|
|
||||||
Expression(Box<TypeReferenceExpression>),
|
|
||||||
DataType(Box<TypeReferenceDataType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TypeReferenceExpression {
|
|
||||||
pub nodes: (Keyword, Paren<Expression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TypeReferenceDataType {
|
|
||||||
pub nodes: (Keyword, Paren<DataType>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -701,44 +417,3 @@ pub(crate) fn type_reference_data_type(s: Span) -> IResult<Span, TypeReference>
|
|||||||
TypeReference::DataType(Box::new(TypeReferenceDataType { nodes: (a, b) })),
|
TypeReference::DataType(Box::new(TypeReferenceDataType { nodes: (a, b) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_data_type() {
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"struct { bit [7:0] opcode; bit [23:0] addr; }",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"struct packed signed { int a; shortint b; byte c; bit [7:0] d; }",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"union { int i; shortreal f; } ",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"struct { bit isfloat; union { int i; shortreal f; } n; }",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"union packed { s_atmcell acell; bit [423:0] bit_slice; bit [52:0][7:0] byte_slice; }",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
data_type,
|
|
||||||
"union tagged { void Invalid; int Valid; }",
|
|
||||||
Ok((_, DataType::StructUnion(_)))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InoutDeclaration {
|
|
||||||
pub nodes: (Keyword, Option<NetPortType>, ListOfPortIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InputDeclaration {
|
|
||||||
Net(Box<InputDeclarationNet>),
|
|
||||||
Variable(Box<InputDeclarationVariable>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InputDeclarationNet {
|
|
||||||
pub nodes: (Keyword, Option<NetPortType>, ListOfPortIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InputDeclarationVariable {
|
|
||||||
pub nodes: (Keyword, VariablePortType, ListOfVariableIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum OutputDeclaration {
|
|
||||||
Net(Box<OutputDeclarationNet>),
|
|
||||||
Variable(Box<OutputDeclarationVariable>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputDeclarationNet {
|
|
||||||
pub nodes: (Keyword, Option<NetPortType>, ListOfPortIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputDeclarationVariable {
|
|
||||||
pub nodes: (Keyword, VariablePortType, ListOfVariablePortIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfacePortDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Option<(Symbol, ModportIdentifier)>,
|
|
||||||
ListOfInterfaceIdentifiers,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RefDeclaration {
|
|
||||||
pub nodes: (Keyword, VariablePortType, ListOfVariableIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -155,17 +97,3 @@ pub(crate) fn implicit_var(s: Span) -> IResult<Span, VariablePortType> {
|
|||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_inout_declaration() {
|
|
||||||
parser_test!(inout_declaration, "inout a", Ok((_, _)));
|
|
||||||
parser_test!(inout_declaration, "inout [7:0] a", Ok((_, _)));
|
|
||||||
parser_test!(inout_declaration, "inout signed [7:0] a", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DriveStrength {
|
|
||||||
Strength01(Box<DriveStrength01>),
|
|
||||||
Strength10(Box<DriveStrength10>),
|
|
||||||
Strength0z(Box<DriveStrength0z>),
|
|
||||||
Strength1z(Box<DriveStrength1z>),
|
|
||||||
Strengthz0(Box<DriveStrengthz0>),
|
|
||||||
Strengthz1(Box<DriveStrengthz1>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrength01 {
|
|
||||||
pub nodes: (Paren<(Strength0, Symbol, Strength1)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrength10 {
|
|
||||||
pub nodes: (Paren<(Strength1, Symbol, Strength0)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrength0z {
|
|
||||||
pub nodes: (Paren<(Strength0, Symbol, Keyword)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrength1z {
|
|
||||||
pub nodes: (Paren<(Strength1, Symbol, Keyword)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrengthz1 {
|
|
||||||
pub nodes: (Paren<(Keyword, Symbol, Strength1)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DriveStrengthz0 {
|
|
||||||
pub nodes: (Paren<(Keyword, Symbol, Strength0)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Strength0 {
|
|
||||||
Supply0(Box<Keyword>),
|
|
||||||
Strong0(Box<Keyword>),
|
|
||||||
Pull0(Box<Keyword>),
|
|
||||||
Weak0(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Strength1 {
|
|
||||||
Supply1(Box<Keyword>),
|
|
||||||
Strong1(Box<Keyword>),
|
|
||||||
Pull1(Box<Keyword>),
|
|
||||||
Weak1(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ChargeStrength {
|
|
||||||
Small(Box<ChargeStrengthSmall>),
|
|
||||||
Medium(Box<ChargeStrengthMedium>),
|
|
||||||
Large(Box<ChargeStrengthLarge>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ChargeStrengthSmall {
|
|
||||||
pub nodes: (Paren<Keyword>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ChargeStrengthMedium {
|
|
||||||
pub nodes: (Paren<Keyword>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ChargeStrengthLarge {
|
|
||||||
pub nodes: (Paren<Keyword>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -207,27 +123,3 @@ pub(crate) fn charge_strength_large(s: Span) -> IResult<Span, ChargeStrength> {
|
|||||||
ChargeStrength::Large(Box::new(ChargeStrengthLarge { nodes: (a,) })),
|
ChargeStrength::Large(Box::new(ChargeStrengthLarge { nodes: (a,) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_drive_strength() {
|
|
||||||
parser_test!(drive_strength, "(supply0, strong1)", Ok((_, _)));
|
|
||||||
parser_test!(drive_strength, "(pull1, weak0)", Ok((_, _)));
|
|
||||||
parser_test!(drive_strength, "(pull0, highz1)", Ok((_, _)));
|
|
||||||
parser_test!(drive_strength, "(weak1, highz0)", Ok((_, _)));
|
|
||||||
parser_test!(drive_strength, "(highz0, supply1)", Ok((_, _)));
|
|
||||||
parser_test!(drive_strength, "(highz1, strong0)", Ok((_, _)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_charge_strength() {
|
|
||||||
parser_test!(charge_strength, "( small)", Ok((_, _)));
|
|
||||||
parser_test!(charge_strength, "( medium )", Ok((_, _)));
|
|
||||||
parser_test!(charge_strength, "(large)", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,99 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaskDeclaration {
|
|
||||||
pub nodes: (Keyword, Option<Lifetime>, TaskBodyDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TaskBodyDeclaration {
|
|
||||||
WithoutPort(Box<TaskBodyDeclarationWithoutPort>),
|
|
||||||
WithPort(Box<TaskBodyDeclarationWithPort>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaskBodyDeclarationWithoutPort {
|
|
||||||
pub nodes: (
|
|
||||||
Option<InterfaceIdentifierOrClassScope>,
|
|
||||||
TaskIdentifier,
|
|
||||||
Symbol,
|
|
||||||
Vec<TfItemDeclaration>,
|
|
||||||
Vec<StatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, TaskIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaskBodyDeclarationWithPort {
|
|
||||||
pub nodes: (
|
|
||||||
Option<InterfaceIdentifierOrClassScope>,
|
|
||||||
TaskIdentifier,
|
|
||||||
Paren<Option<TfPortList>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<BlockItemDeclaration>,
|
|
||||||
Vec<StatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, TaskIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TfItemDeclaration {
|
|
||||||
BlockItemDeclaration(Box<BlockItemDeclaration>),
|
|
||||||
TfPortDeclaration(Box<TfPortDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TfPortList {
|
|
||||||
pub nodes: (List<Symbol, TfPortItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TfPortItem {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<TfPortDirection>,
|
|
||||||
Option<Var>,
|
|
||||||
Option<DataTypeOrImplicit>,
|
|
||||||
Option<(
|
|
||||||
PortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, Expression)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TfPortDirection {
|
|
||||||
PortDirection(Box<PortDirection>),
|
|
||||||
ConstRef(Box<(Keyword, Keyword)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TfPortDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
TfPortDirection,
|
|
||||||
Option<Var>,
|
|
||||||
Option<DataTypeOrImplicit>,
|
|
||||||
ListOfTfVariableIdentifiers,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaskPrototype {
|
|
||||||
pub nodes: (Keyword, TaskIdentifier, Option<Paren<Option<TfPortList>>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
321
sv-parser-parser/src/declarations/type_declarations.rs
Normal file
321
sv-parser-parser/src/declarations/type_declarations.rs
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn data_declaration(s: Span) -> IResult<Span, DataDeclaration> {
|
||||||
|
alt((
|
||||||
|
data_declaration_variable,
|
||||||
|
map(type_declaration, |x| {
|
||||||
|
DataDeclaration::TypeDeclaration(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(package_import_declaration, |x| {
|
||||||
|
DataDeclaration::PackageImportDeclaration(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(net_type_declaration, |x| {
|
||||||
|
DataDeclaration::NetTypeDeclaration(Box::new(x))
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser(Ambiguous)]
|
||||||
|
pub(crate) fn data_declaration_variable(s: Span) -> IResult<Span, DataDeclaration> {
|
||||||
|
let (s, a) = opt(r#const)(s)?;
|
||||||
|
let (s, b) = opt(var)(s)?;
|
||||||
|
let (s, c) = opt(lifetime)(s)?;
|
||||||
|
let (s, d) = ambiguous_opt(data_type_or_implicit)(s)?;
|
||||||
|
let (s, e) = list_of_variable_decl_assignments(s)?;
|
||||||
|
let (s, f) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
DataDeclaration::Variable(Box::new(DataDeclarationVariable {
|
||||||
|
nodes: (a, b, c, d, e, f),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn r#const(s: Span) -> IResult<Span, Const> {
|
||||||
|
let (s, a) = keyword("const")(s)?;
|
||||||
|
Ok((s, Const { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_import_declaration(s: Span) -> IResult<Span, PackageImportDeclaration> {
|
||||||
|
let (s, a) = keyword("import")(s)?;
|
||||||
|
let (s, b) = list(symbol(","), package_import_item)(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((s, PackageImportDeclaration { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_import_item(s: Span) -> IResult<Span, PackageImportItem> {
|
||||||
|
alt((package_import_item_identifier, package_import_item_asterisk))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_import_item_identifier(s: Span) -> IResult<Span, PackageImportItem> {
|
||||||
|
let (s, a) = package_identifier(s)?;
|
||||||
|
let (s, b) = symbol("::")(s)?;
|
||||||
|
let (s, c) = identifier(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PackageImportItem::Identifier(Box::new(PackageImportItemIdentifier { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_import_item_asterisk(s: Span) -> IResult<Span, PackageImportItem> {
|
||||||
|
let (s, a) = package_identifier(s)?;
|
||||||
|
let (s, b) = symbol("::")(s)?;
|
||||||
|
let (s, c) = symbol("*")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PackageImportItem::Asterisk(Box::new(PackageImportItemAsterisk { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_export_declaration(s: Span) -> IResult<Span, PackageExportDeclaration> {
|
||||||
|
alt((
|
||||||
|
package_export_declaration_asterisk,
|
||||||
|
package_export_declaration_item,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_export_declaration_asterisk(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, PackageExportDeclaration> {
|
||||||
|
let (s, a) = keyword("export")(s)?;
|
||||||
|
let (s, b) = symbol("*::*")(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PackageExportDeclaration::Asterisk(Box::new(PackageExportDeclarationAsterisk {
|
||||||
|
nodes: (a, b, c),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn package_export_declaration_item(s: Span) -> IResult<Span, PackageExportDeclaration> {
|
||||||
|
let (s, a) = keyword("export")(s)?;
|
||||||
|
let (s, b) = list(symbol(","), package_import_item)(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
PackageExportDeclaration::Item(Box::new(PackageExportDeclarationItem { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn genvar_declaration(s: Span) -> IResult<Span, GenvarDeclaration> {
|
||||||
|
let (s, a) = keyword("genvar")(s)?;
|
||||||
|
let (s, b) = list_of_genvar_identifiers(s)?;
|
||||||
|
let (s, c) = symbol(";")(s)?;
|
||||||
|
Ok((s, GenvarDeclaration { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_declaration(s: Span) -> IResult<Span, NetDeclaration> {
|
||||||
|
alt((
|
||||||
|
net_declaration_interconnect,
|
||||||
|
net_declaration_net_type,
|
||||||
|
net_declaration_net_type_identifier,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser(Ambiguous)]
|
||||||
|
pub(crate) fn net_declaration_net_type(s: Span) -> IResult<Span, NetDeclaration> {
|
||||||
|
let (s, a) = net_type(s)?;
|
||||||
|
let (s, b) = opt(strength)(s)?;
|
||||||
|
let (s, c) = opt(vector_scalar)(s)?;
|
||||||
|
let (s, d) = ambiguous_opt(data_type_or_implicit)(s)?;
|
||||||
|
let (s, e) = opt(delay3)(s)?;
|
||||||
|
let (s, f) = list_of_net_decl_assignments(s)?;
|
||||||
|
let (s, g) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetDeclaration::NetType(Box::new(NetDeclarationNetType {
|
||||||
|
nodes: (a, b, c, d, e, f, g),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn strength(s: Span) -> IResult<Span, Strength> {
|
||||||
|
alt((
|
||||||
|
map(drive_strength, |x| Strength::Drive(Box::new(x))),
|
||||||
|
map(charge_strength, |x| Strength::Charge(Box::new(x))),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn vector_scalar(s: Span) -> IResult<Span, VectorScalar> {
|
||||||
|
alt((
|
||||||
|
map(keyword("vectored"), |x| VectorScalar::Vectored(Box::new(x))),
|
||||||
|
map(keyword("scalared"), |x| VectorScalar::Scalared(Box::new(x))),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_declaration_net_type_identifier(s: Span) -> IResult<Span, NetDeclaration> {
|
||||||
|
let (s, a) = net_type_identifier(s)?;
|
||||||
|
let (s, b) = opt(delay_control)(s)?;
|
||||||
|
let (s, c) = list_of_net_decl_assignments(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetDeclaration::NetTypeIdentifier(Box::new(NetDeclarationNetTypeIdentifier {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_declaration_interconnect(s: Span) -> IResult<Span, NetDeclaration> {
|
||||||
|
let (s, a) = keyword("interconnect")(s)?;
|
||||||
|
let (s, b) = implicit_data_type(s)?;
|
||||||
|
let (s, c) = opt(pair(symbol("#"), delay_value))(s)?;
|
||||||
|
let (s, d) = net_identifier(s)?;
|
||||||
|
let (s, e) = many0(unpacked_dimension)(s)?;
|
||||||
|
let (s, f) = opt(triple(
|
||||||
|
symbol(","),
|
||||||
|
net_identifier,
|
||||||
|
many0(unpacked_dimension),
|
||||||
|
))(s)?;
|
||||||
|
let (s, g) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetDeclaration::Interconnect(Box::new(NetDeclarationInterconnect {
|
||||||
|
nodes: (a, b, c, d, e, f, g),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn type_declaration(s: Span) -> IResult<Span, TypeDeclaration> {
|
||||||
|
alt((
|
||||||
|
type_declaration_data_type,
|
||||||
|
type_declaration_interface,
|
||||||
|
type_declaration_reserved,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn type_declaration_data_type(s: Span) -> IResult<Span, TypeDeclaration> {
|
||||||
|
let (s, a) = keyword("typedef")(s)?;
|
||||||
|
let (s, b) = data_type(s)?;
|
||||||
|
let (s, c) = type_identifier(s)?;
|
||||||
|
let (s, d) = many0(variable_dimension)(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TypeDeclaration::DataType(Box::new(TypeDeclarationDataType {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn type_declaration_interface(s: Span) -> IResult<Span, TypeDeclaration> {
|
||||||
|
let (s, a) = keyword("typedef")(s)?;
|
||||||
|
let (s, b) = interface_instance_identifier(s)?;
|
||||||
|
let (s, c) = constant_bit_select(s)?;
|
||||||
|
let (s, d) = symbol(".")(s)?;
|
||||||
|
let (s, e) = type_identifier(s)?;
|
||||||
|
let (s, f) = type_identifier(s)?;
|
||||||
|
let (s, g) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TypeDeclaration::Interface(Box::new(TypeDeclarationInterface {
|
||||||
|
nodes: (a, b, c, d, e, f, g),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn type_declaration_reserved(s: Span) -> IResult<Span, TypeDeclaration> {
|
||||||
|
let (s, a) = keyword("typedef")(s)?;
|
||||||
|
let (s, b) = opt(type_declaration_keyword)(s)?;
|
||||||
|
let (s, c) = type_identifier(s)?;
|
||||||
|
let (s, d) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
TypeDeclaration::Reserved(Box::new(TypeDeclarationReserved {
|
||||||
|
nodes: (a, b, c, d),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn type_declaration_keyword(s: Span) -> IResult<Span, TypeDeclarationKeyword> {
|
||||||
|
alt((
|
||||||
|
map(keyword("enum"), |x| {
|
||||||
|
TypeDeclarationKeyword::Enum(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(keyword("struct"), |x| {
|
||||||
|
TypeDeclarationKeyword::Struct(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(keyword("union"), |x| {
|
||||||
|
TypeDeclarationKeyword::Union(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(keyword("class"), |x| {
|
||||||
|
TypeDeclarationKeyword::Class(Box::new(x))
|
||||||
|
}),
|
||||||
|
map(pair(keyword("interface"), keyword("class")), |x| {
|
||||||
|
TypeDeclarationKeyword::InterfaceClass(Box::new(x))
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_type_declaration(s: Span) -> IResult<Span, NetTypeDeclaration> {
|
||||||
|
alt((
|
||||||
|
net_type_declaration_data_type,
|
||||||
|
net_type_declaration_net_type,
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_type_declaration_data_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
|
||||||
|
let (s, a) = keyword("nettype")(s)?;
|
||||||
|
let (s, b) = data_type(s)?;
|
||||||
|
let (s, c) = net_type_identifier(s)?;
|
||||||
|
let (s, d) = opt(triple(
|
||||||
|
keyword("with"),
|
||||||
|
opt(package_scope_or_class_scope),
|
||||||
|
tf_identifier,
|
||||||
|
))(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetTypeDeclaration::DataType(Box::new(NetTypeDeclarationDataType {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_type_declaration_net_type(s: Span) -> IResult<Span, NetTypeDeclaration> {
|
||||||
|
let (s, a) = keyword("nettype")(s)?;
|
||||||
|
let (s, b) = opt(package_scope_or_class_scope)(s)?;
|
||||||
|
let (s, c) = net_type_identifier(s)?;
|
||||||
|
let (s, d) = net_type_identifier(s)?;
|
||||||
|
let (s, e) = symbol(";")(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetTypeDeclaration::NetType(Box::new(NetTypeDeclarationNetType {
|
||||||
|
nodes: (a, b, c, d, e),
|
||||||
|
})),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn lifetime(s: Span) -> IResult<Span, Lifetime> {
|
||||||
|
alt((
|
||||||
|
map(keyword("static"), |x| Lifetime::Static(Box::new(x))),
|
||||||
|
map(keyword("automatic"), |x| Lifetime::Automatic(Box::new(x))),
|
||||||
|
))(s)
|
||||||
|
}
|
@ -1,95 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Concatenation {
|
|
||||||
pub nodes: (Brace<List<Symbol, Expression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantConcatenation {
|
|
||||||
pub nodes: (Brace<List<Symbol, ConstantExpression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantMultipleConcatenation {
|
|
||||||
pub nodes: (Brace<(ConstantExpression, ConstantConcatenation)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathConcatenation {
|
|
||||||
pub nodes: (Brace<List<Symbol, ModulePathExpression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathMultipleConcatenation {
|
|
||||||
pub nodes: (Brace<(ConstantExpression, ModulePathConcatenation)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MultipleConcatenation {
|
|
||||||
pub nodes: (Brace<(Expression, Concatenation)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StreamingConcatenation {
|
|
||||||
pub nodes: (Brace<(StreamOperator, Option<SliceSize>, StreamConcatenation)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StreamOperator {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SliceSize {
|
|
||||||
SimpleType(Box<SimpleType>),
|
|
||||||
ConstantExpression(Box<ConstantExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StreamConcatenation {
|
|
||||||
pub nodes: (Brace<List<Symbol, StreamExpression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StreamExpression {
|
|
||||||
pub nodes: (Expression, Option<(Keyword, Bracket<ArrayRangeExpression>)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ArrayRangeExpression {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
Colon(Box<ArrayRangeExpressionColon>),
|
|
||||||
PlusColon(Box<ArrayRangeExpressionPlusColon>),
|
|
||||||
MinusColon(Box<ArrayRangeExpressionMinusColon>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ArrayRangeExpressionColon {
|
|
||||||
pub nodes: (Expression, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ArrayRangeExpressionPlusColon {
|
|
||||||
pub nodes: (Expression, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ArrayRangeExpressionMinusColon {
|
|
||||||
pub nodes: (Expression, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EmptyUnpackedArrayConcatenation {
|
|
||||||
pub nodes: (Symbol, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -106,7 +15,9 @@ pub(crate) fn constant_concatenation(s: Span) -> IResult<Span, ConstantConcatena
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn constant_multiple_concatenation(s: Span) -> IResult<Span, ConstantMultipleConcatenation> {
|
pub(crate) fn constant_multiple_concatenation(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ConstantMultipleConcatenation> {
|
||||||
let (s, a) = brace(pair(constant_expression, constant_concatenation))(s)?;
|
let (s, a) = brace(pair(constant_expression, constant_concatenation))(s)?;
|
||||||
Ok((s, ConstantMultipleConcatenation { nodes: (a,) }))
|
Ok((s, ConstantMultipleConcatenation { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
@ -229,5 +140,3 @@ pub(crate) fn empty_unpacked_array_concatenation(
|
|||||||
let (s, b) = symbol("}")(s)?;
|
let (s, b) = symbol("}")(s)?;
|
||||||
Ok((s, EmptyUnpackedArrayConcatenation { nodes: (a, b) }))
|
Ok((s, EmptyUnpackedArrayConcatenation { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -0,0 +1,89 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[packrat_parser]
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
|
alt((net_lvalue_identifier, net_lvalue_lvalue, net_lvalue_pattern))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_lvalue_identifier(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
|
let (s, a) = ps_or_hierarchical_net_identifier(s)?;
|
||||||
|
let (s, b) = constant_select(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetLvalue::Identifier(Box::new(NetLvalueIdentifier { nodes: (a, b) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_lvalue_pattern(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
|
let (s, a) = opt(assignment_pattern_expression_type)(s)?;
|
||||||
|
let (s, b) = assignment_pattern_net_lvalue(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetLvalue::Pattern(Box::new(NetLvaluePattern { nodes: (a, b) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn net_lvalue_lvalue(s: Span) -> IResult<Span, NetLvalue> {
|
||||||
|
let (s, a) = brace(list(symbol(","), net_lvalue))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
NetLvalue::Lvalue(Box::new(NetLvalueLvalue { nodes: (a,) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[packrat_parser]
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn variable_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
|
alt((
|
||||||
|
variable_lvalue_identifier,
|
||||||
|
variable_lvalue_lvalue,
|
||||||
|
variable_lvalue_pattern,
|
||||||
|
map(streaming_concatenation, |x| {
|
||||||
|
VariableLvalue::StreamingConcatenation(Box::new(x))
|
||||||
|
}),
|
||||||
|
))(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn variable_lvalue_identifier(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
|
let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
|
||||||
|
let (s, b) = hierarchical_variable_identifier(s)?;
|
||||||
|
let (s, c) = select(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableLvalue::Identifier(Box::new(VariableLvalueIdentifier { nodes: (a, b, c) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn variable_lvalue_pattern(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
|
let (s, a) = opt(assignment_pattern_expression_type)(s)?;
|
||||||
|
let (s, b) = assignment_pattern_variable_lvalue(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableLvalue::Pattern(Box::new(VariableLvaluePattern { nodes: (a, b) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn variable_lvalue_lvalue(s: Span) -> IResult<Span, VariableLvalue> {
|
||||||
|
let (s, a) = brace(list(symbol(","), variable_lvalue))(s)?;
|
||||||
|
Ok((
|
||||||
|
s,
|
||||||
|
VariableLvalue::Lvalue(Box::new(VariableLvalueLvalue { nodes: (a,) })),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn nonrange_variable_lvalue(s: Span) -> IResult<Span, NonrangeVariableLvalue> {
|
||||||
|
let (s, a) = opt(implicit_class_handle_or_package_scope)(s)?;
|
||||||
|
let (s, b) = hierarchical_variable_identifier(s)?;
|
||||||
|
let (s, c) = nonrange_select(s)?;
|
||||||
|
Ok((s, NonrangeVariableLvalue { nodes: (a, b, c) }))
|
||||||
|
}
|
@ -1,264 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum IncOrDecExpression {
|
|
||||||
Prefix(Box<IncOrDecExpressionPrefix>),
|
|
||||||
Suffix(Box<IncOrDecExpressionSuffix>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IncOrDecExpressionPrefix {
|
|
||||||
pub nodes: (IncOrDecOperator, Vec<AttributeInstance>, VariableLvalue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IncOrDecExpressionSuffix {
|
|
||||||
pub nodes: (VariableLvalue, Vec<AttributeInstance>, IncOrDecOperator),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConditionalExpression {
|
|
||||||
pub nodes: (
|
|
||||||
CondPredicate,
|
|
||||||
Symbol,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Expression,
|
|
||||||
Symbol,
|
|
||||||
Expression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantExpression {
|
|
||||||
ConstantPrimary(Box<ConstantPrimary>),
|
|
||||||
Unary(Box<ConstantExpressionUnary>),
|
|
||||||
Binary(Box<ConstantExpressionBinary>),
|
|
||||||
Ternary(Box<ConstantExpressionTernary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantExpressionUnary {
|
|
||||||
pub nodes: (UnaryOperator, Vec<AttributeInstance>, ConstantPrimary),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantExpressionBinary {
|
|
||||||
pub nodes: (
|
|
||||||
ConstantExpression,
|
|
||||||
BinaryOperator,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ConstantExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantExpressionTernary {
|
|
||||||
pub nodes: (
|
|
||||||
ConstantExpression,
|
|
||||||
Symbol,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ConstantExpression,
|
|
||||||
Symbol,
|
|
||||||
ConstantExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantMintypmaxExpression {
|
|
||||||
Unary(Box<ConstantExpression>),
|
|
||||||
Ternary(Box<ConstantMintypmaxExpressionTernary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantMintypmaxExpressionTernary {
|
|
||||||
pub nodes: (
|
|
||||||
ConstantExpression,
|
|
||||||
Symbol,
|
|
||||||
ConstantExpression,
|
|
||||||
Symbol,
|
|
||||||
ConstantExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantParamExpression {
|
|
||||||
ConstantMintypmaxExpression(Box<ConstantMintypmaxExpression>),
|
|
||||||
DataType(Box<DataType>),
|
|
||||||
Dollar(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ParamExpression {
|
|
||||||
MintypmaxExpression(Box<MintypmaxExpression>),
|
|
||||||
DataType(Box<DataType>),
|
|
||||||
Dollar(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantRangeExpression {
|
|
||||||
ConstantExpression(Box<ConstantExpression>),
|
|
||||||
ConstantPartSelectRange(Box<ConstantPartSelectRange>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantPartSelectRange {
|
|
||||||
ConstantRange(Box<ConstantRange>),
|
|
||||||
ConstantIndexedRange(Box<ConstantIndexedRange>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantRange {
|
|
||||||
pub nodes: (ConstantExpression, Symbol, ConstantExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantIndexedRange {
|
|
||||||
pub nodes: (ConstantExpression, Symbol, ConstantExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Expression {
|
|
||||||
Primary(Box<Primary>),
|
|
||||||
Unary(Box<ExpressionUnary>),
|
|
||||||
IncOrDecExpression(Box<IncOrDecExpression>),
|
|
||||||
OperatorAssignment(Box<ExpressionOperatorAssignment>),
|
|
||||||
Binary(Box<ExpressionBinary>),
|
|
||||||
ConditionalExpression(Box<ConditionalExpression>),
|
|
||||||
InsideExpression(Box<InsideExpression>),
|
|
||||||
TaggedUnionExpression(Box<TaggedUnionExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExpressionUnary {
|
|
||||||
pub nodes: (UnaryOperator, Vec<AttributeInstance>, Primary),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExpressionOperatorAssignment {
|
|
||||||
pub nodes: (Paren<OperatorAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExpressionBinary {
|
|
||||||
pub nodes: (
|
|
||||||
Expression,
|
|
||||||
BinaryOperator,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Expression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaggedUnionExpression {
|
|
||||||
pub nodes: (Keyword, MemberIdentifier, Option<Expression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InsideExpression {
|
|
||||||
pub nodes: (Expression, Keyword, Brace<OpenRangeList>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ValueRange {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
Binary(Box<ValueRangeBinary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ValueRangeBinary {
|
|
||||||
pub nodes: (Bracket<(Expression, Symbol, Expression)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum MintypmaxExpression {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
Ternary(Box<MintypmaxExpressionTernary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MintypmaxExpressionTernary {
|
|
||||||
pub nodes: (Expression, Symbol, Expression, Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathConditionalExpression {
|
|
||||||
pub nodes: (
|
|
||||||
ModulePathExpression,
|
|
||||||
Symbol,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModulePathExpression,
|
|
||||||
Symbol,
|
|
||||||
ModulePathExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModulePathExpression {
|
|
||||||
ModulePathPrimary(Box<ModulePathPrimary>),
|
|
||||||
Unary(Box<ModulePathExpressionUnary>),
|
|
||||||
Binary(Box<ModulePathExpressionBinary>),
|
|
||||||
ModulePathConditionalExpression(Box<ModulePathConditionalExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathExpressionUnary {
|
|
||||||
pub nodes: (
|
|
||||||
UnaryModulePathOperator,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModulePathPrimary,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathExpressionBinary {
|
|
||||||
pub nodes: (
|
|
||||||
ModulePathExpression,
|
|
||||||
BinaryModulePathOperator,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModulePathExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModulePathMintypmaxExpression {
|
|
||||||
ModulePathExpression(Box<ModulePathExpression>),
|
|
||||||
Ternary(Box<ModulePathMintypmaxExpressionTernary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathMintypmaxExpressionTernary {
|
|
||||||
pub nodes: (
|
|
||||||
ModulePathExpression,
|
|
||||||
Symbol,
|
|
||||||
ModulePathExpression,
|
|
||||||
Symbol,
|
|
||||||
ModulePathExpression,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PartSelectRange {
|
|
||||||
ConstantRange(Box<ConstantRange>),
|
|
||||||
IndexedRange(Box<IndexedRange>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IndexedRange {
|
|
||||||
pub nodes: (Expression, Symbol, ConstantExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarExpression {
|
|
||||||
pub nodes: (ConstantExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -623,7 +363,9 @@ pub(crate) fn module_path_expression_binary(s: Span) -> IResult<Span, ModulePath
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn module_path_mintypmax_expression(s: Span) -> IResult<Span, ModulePathMintypmaxExpression> {
|
pub(crate) fn module_path_mintypmax_expression(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ModulePathMintypmaxExpression> {
|
||||||
alt((
|
alt((
|
||||||
module_path_mintypmax_expression_ternary,
|
module_path_mintypmax_expression_ternary,
|
||||||
map(module_path_expression, |x| {
|
map(module_path_expression, |x| {
|
||||||
@ -674,12 +416,3 @@ pub(crate) fn genvar_expression(s: Span) -> IResult<Span, GenvarExpression> {
|
|||||||
let (s, a) = constant_expression(s)?;
|
let (s, a) = constant_expression(s)?;
|
||||||
Ok((s, GenvarExpression { nodes: (a,) }))
|
Ok((s, GenvarExpression { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test() {}
|
|
||||||
}
|
|
16
sv-parser-parser/src/expressions/mod.rs
Normal file
16
sv-parser-parser/src/expressions/mod.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pub mod concatenations;
|
||||||
|
pub mod expression_leftside_values;
|
||||||
|
pub mod expressions;
|
||||||
|
pub mod numbers;
|
||||||
|
pub mod operators;
|
||||||
|
pub mod primaries;
|
||||||
|
pub mod strings;
|
||||||
|
pub mod subroutine_calls;
|
||||||
|
pub(crate) use concatenations::*;
|
||||||
|
pub(crate) use expression_leftside_values::*;
|
||||||
|
pub(crate) use expressions::*;
|
||||||
|
pub(crate) use numbers::*;
|
||||||
|
pub(crate) use operators::*;
|
||||||
|
pub(crate) use primaries::*;
|
||||||
|
pub(crate) use strings::*;
|
||||||
|
pub(crate) use subroutine_calls::*;
|
@ -1,165 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::bytes::complete::*;
|
|
||||||
use nom::character::complete::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Number {
|
|
||||||
IntegralNumber(Box<IntegralNumber>),
|
|
||||||
RealNumber(Box<RealNumber>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum IntegralNumber {
|
|
||||||
DecimalNumber(Box<DecimalNumber>),
|
|
||||||
OctalNumber(Box<OctalNumber>),
|
|
||||||
BinaryNumber(Box<BinaryNumber>),
|
|
||||||
HexNumber(Box<HexNumber>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DecimalNumber {
|
|
||||||
UnsignedNumber(Box<UnsignedNumber>),
|
|
||||||
BaseUnsigned(Box<DecimalNumberBaseUnsigned>),
|
|
||||||
BaseXNumber(Box<DecimalNumberBaseXNumber>),
|
|
||||||
BaseZNumber(Box<DecimalNumberBaseZNumber>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DecimalNumberBaseUnsigned {
|
|
||||||
pub nodes: (Option<Size>, DecimalBase, UnsignedNumber),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DecimalNumberBaseXNumber {
|
|
||||||
pub nodes: (Option<Size>, DecimalBase, XNumber),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DecimalNumberBaseZNumber {
|
|
||||||
pub nodes: (Option<Size>, DecimalBase, ZNumber),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinaryNumber {
|
|
||||||
pub nodes: (Option<Size>, BinaryBase, BinaryValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OctalNumber {
|
|
||||||
pub nodes: (Option<Size>, OctalBase, OctalValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HexNumber {
|
|
||||||
pub nodes: (Option<Size>, HexBase, HexValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Sign {
|
|
||||||
Plus(Box<Symbol>),
|
|
||||||
Minus(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Size {
|
|
||||||
pub nodes: (NonZeroUnsignedNumber,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonZeroUnsignedNumber {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RealNumber {
|
|
||||||
FixedPointNumber(Box<FixedPointNumber>),
|
|
||||||
Floating(Box<RealNumberFloating>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RealNumberFloating {
|
|
||||||
pub nodes: (
|
|
||||||
UnsignedNumber,
|
|
||||||
Option<(Symbol, UnsignedNumber)>,
|
|
||||||
Exp,
|
|
||||||
Option<Sign>,
|
|
||||||
UnsignedNumber,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FixedPointNumber {
|
|
||||||
pub nodes: (UnsignedNumber, Symbol, UnsignedNumber),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Exp {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UnsignedNumber {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinaryValue {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OctalValue {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HexValue {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DecimalBase {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinaryBase {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OctalBase {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HexBase {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct XNumber {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ZNumber {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UnbasedUnsizedLiteral {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -468,59 +307,3 @@ pub(crate) fn unbased_unsized_literal(s: Span) -> IResult<Span, UnbasedUnsizedLi
|
|||||||
let (s, a) = alt((symbol("'0"), symbol("'1"), symbol("'z"), symbol("'x")))(s)?;
|
let (s, a) = alt((symbol("'0"), symbol("'1"), symbol("'z"), symbol("'x")))(s)?;
|
||||||
Ok((s, UnbasedUnsizedLiteral { nodes: (a,) }))
|
Ok((s, UnbasedUnsizedLiteral { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_number() {
|
|
||||||
parser_test!(number, "659", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "'o7460", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "'4af", Err(_));
|
|
||||||
parser_test!(number, "4'b1001", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "5 'D 3", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "3'b01x", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "12'hx", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "16'hz", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "8 'd -6", Err(_));
|
|
||||||
parser_test!(number, "4 'shf", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "16'sd?", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(number, "27_195_000", Ok((_, Number::IntegralNumber(_))));
|
|
||||||
parser_test!(
|
|
||||||
number,
|
|
||||||
"16'b0011_0101_0001_1111",
|
|
||||||
Ok((_, Number::IntegralNumber(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
number,
|
|
||||||
"32 'h 12ab_f001",
|
|
||||||
Ok((_, Number::IntegralNumber(_)))
|
|
||||||
);
|
|
||||||
parser_test!(number, "1.2", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "0.1", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "2394.26331", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "1.2E12", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "1.30e-2", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "0.1e-0", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "23E10", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "29E-2", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, "236.123_763_e-12", Ok((_, Number::RealNumber(_))));
|
|
||||||
parser_test!(number, ".12", Err(_));
|
|
||||||
parser_test!(number, "9.", Err(_));
|
|
||||||
parser_test!(number, "4.E3", Err(_));
|
|
||||||
parser_test!(number, ".2e-7", Err(_));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_unbased_unsized_literal() {
|
|
||||||
parser_test!(unbased_unsized_literal, "'0", Ok((_, _)));
|
|
||||||
parser_test!(unbased_unsized_literal, "'1", Ok((_, _)));
|
|
||||||
parser_test!(unbased_unsized_literal, "'x", Ok((_, _)));
|
|
||||||
parser_test!(unbased_unsized_literal, "'z", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
100
sv-parser-parser/src/expressions/operators.rs
Normal file
100
sv-parser-parser/src/expressions/operators.rs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[packrat_parser]
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn unary_operator(s: Span) -> IResult<Span, UnaryOperator> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
symbol("+"),
|
||||||
|
symbol("-"),
|
||||||
|
symbol("!"),
|
||||||
|
symbol("&"),
|
||||||
|
symbol("|"),
|
||||||
|
symbol("~&"),
|
||||||
|
symbol("~|"),
|
||||||
|
symbol("~^"),
|
||||||
|
symbol("^~"),
|
||||||
|
symbol("^"),
|
||||||
|
symbol("~"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, UnaryOperator { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn binary_operator(s: Span) -> IResult<Span, BinaryOperator> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
alt((
|
||||||
|
symbol("+"),
|
||||||
|
symbol("->"),
|
||||||
|
symbol("-"),
|
||||||
|
symbol("**"),
|
||||||
|
symbol("*"),
|
||||||
|
symbol("/"),
|
||||||
|
symbol("%"),
|
||||||
|
symbol("==="),
|
||||||
|
symbol("==?"),
|
||||||
|
symbol("=="),
|
||||||
|
symbol("!=="),
|
||||||
|
symbol("!=?"),
|
||||||
|
symbol("!="),
|
||||||
|
symbol("&&"),
|
||||||
|
symbol("||"),
|
||||||
|
)),
|
||||||
|
alt((
|
||||||
|
symbol("&"),
|
||||||
|
symbol("|"),
|
||||||
|
symbol("^~"),
|
||||||
|
symbol("^"),
|
||||||
|
symbol("~^"),
|
||||||
|
symbol(">>>"),
|
||||||
|
symbol(">>"),
|
||||||
|
symbol("<<<"),
|
||||||
|
symbol("<<"),
|
||||||
|
symbol("<->"),
|
||||||
|
symbol("<="),
|
||||||
|
symbol("<"),
|
||||||
|
symbol(">="),
|
||||||
|
symbol(">"),
|
||||||
|
)),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, BinaryOperator { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn inc_or_dec_operator(s: Span) -> IResult<Span, IncOrDecOperator> {
|
||||||
|
let (s, a) = alt((symbol("++"), symbol("--")))(s)?;
|
||||||
|
Ok((s, IncOrDecOperator { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn unary_module_path_operator(s: Span) -> IResult<Span, UnaryModulePathOperator> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
symbol("!"),
|
||||||
|
symbol("&"),
|
||||||
|
symbol("|"),
|
||||||
|
symbol("~&"),
|
||||||
|
symbol("~|"),
|
||||||
|
symbol("~^"),
|
||||||
|
symbol("^~"),
|
||||||
|
symbol("^"),
|
||||||
|
symbol("~"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, UnaryModulePathOperator { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn binary_module_path_operator(s: Span) -> IResult<Span, BinaryModulePathOperator> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
symbol("=="),
|
||||||
|
symbol("!="),
|
||||||
|
symbol("&&"),
|
||||||
|
symbol("||"),
|
||||||
|
symbol("&"),
|
||||||
|
symbol("|"),
|
||||||
|
symbol("^~"),
|
||||||
|
symbol("^"),
|
||||||
|
symbol("~^"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, BinaryModulePathOperator { nodes: (a,) }))
|
||||||
|
}
|
@ -1,254 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstantPrimary {
|
|
||||||
PrimaryLiteral(Box<PrimaryLiteral>),
|
|
||||||
PsParameter(Box<ConstantPrimaryPsParameter>),
|
|
||||||
Specparam(Box<ConstantPrimarySpecparam>),
|
|
||||||
GenvarIdentifier(Box<GenvarIdentifier>),
|
|
||||||
FormalPort(Box<ConstantPrimaryFormalPort>),
|
|
||||||
Enum(Box<ConstantPrimaryEnum>),
|
|
||||||
Concatenation(Box<ConstantPrimaryConcatenation>),
|
|
||||||
MultipleConcatenation(Box<ConstantPrimaryMultipleConcatenation>),
|
|
||||||
ConstantFunctionCall(Box<ConstantFunctionCall>),
|
|
||||||
ConstantLetExpression(Box<ConstantLetExpression>),
|
|
||||||
MintypmaxExpression(Box<ConstantPrimaryMintypmaxExpression>),
|
|
||||||
ConstantCast(Box<ConstantCast>),
|
|
||||||
ConstantAssignmentPatternExpression(Box<ConstantAssignmentPatternExpression>),
|
|
||||||
TypeReference(Box<TypeReference>),
|
|
||||||
Null(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryPsParameter {
|
|
||||||
pub nodes: (PsParameterIdentifier, ConstantSelect),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimarySpecparam {
|
|
||||||
pub nodes: (
|
|
||||||
SpecparamIdentifier,
|
|
||||||
Option<Bracket<ConstantRangeExpression>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryFormalPort {
|
|
||||||
pub nodes: (FormalPortIdentifier, ConstantSelect),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryEnum {
|
|
||||||
pub nodes: (PackageScopeOrClassScope, EnumIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryConcatenation {
|
|
||||||
pub nodes: (
|
|
||||||
ConstantConcatenation,
|
|
||||||
Option<Bracket<ConstantRangeExpression>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryMultipleConcatenation {
|
|
||||||
pub nodes: (
|
|
||||||
ConstantMultipleConcatenation,
|
|
||||||
Option<Bracket<ConstantRangeExpression>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantPrimaryMintypmaxExpression {
|
|
||||||
pub nodes: (Paren<ConstantMintypmaxExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModulePathPrimary {
|
|
||||||
Number(Box<Number>),
|
|
||||||
Identifier(Box<Identifier>),
|
|
||||||
ModulePathConcatenation(Box<ModulePathConcatenation>),
|
|
||||||
ModulePathMultipleConcatenation(Box<ModulePathMultipleConcatenation>),
|
|
||||||
FunctionSubroutineCall(Box<FunctionSubroutineCall>),
|
|
||||||
Mintypmax(Box<ModulePathPrimaryMintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModulePathPrimaryMintypmax {
|
|
||||||
pub nodes: (Paren<ModulePathMintypmaxExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Primary {
|
|
||||||
PrimaryLiteral(Box<PrimaryLiteral>),
|
|
||||||
Hierarchical(Box<PrimaryHierarchical>),
|
|
||||||
EmptyUnpackedArrayConcatenation(Box<EmptyUnpackedArrayConcatenation>),
|
|
||||||
Concatenation(Box<PrimaryConcatenation>),
|
|
||||||
MultipleConcatenation(Box<PrimaryMultipleConcatenation>),
|
|
||||||
FunctionSubroutineCall(Box<FunctionSubroutineCall>),
|
|
||||||
LetExpression(Box<LetExpression>),
|
|
||||||
MintypmaxExpression(Box<PrimaryMintypmaxExpression>),
|
|
||||||
Cast(Box<Cast>),
|
|
||||||
AssignmentPatternExpression(Box<AssignmentPatternExpression>),
|
|
||||||
StreamingConcatenation(Box<StreamingConcatenation>),
|
|
||||||
SequenceMethodCall(Box<SequenceMethodCall>),
|
|
||||||
This(Box<Keyword>),
|
|
||||||
Dollar(Box<Symbol>),
|
|
||||||
Null(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PrimaryHierarchical {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ClassQualifierOrPackageScope>,
|
|
||||||
HierarchicalIdentifier,
|
|
||||||
Select,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PrimaryConcatenation {
|
|
||||||
pub nodes: (Concatenation, Option<Bracket<RangeExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PrimaryMultipleConcatenation {
|
|
||||||
pub nodes: (MultipleConcatenation, Option<Bracket<RangeExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PrimaryMintypmaxExpression {
|
|
||||||
pub nodes: (Paren<MintypmaxExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassQualifierOrPackageScope {
|
|
||||||
ClassQualifier(Box<ClassQualifier>),
|
|
||||||
PackageScope(Box<PackageScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassQualifier {
|
|
||||||
pub nodes: (Option<Local>, Option<ImplicitClassHandleOrClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RangeExpression {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
PartSelectRange(Box<PartSelectRange>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PrimaryLiteral {
|
|
||||||
Number(Box<Number>),
|
|
||||||
TimeLiteral(Box<TimeLiteral>),
|
|
||||||
UnbasedUnsizedLiteral(Box<UnbasedUnsizedLiteral>),
|
|
||||||
StringLiteral(Box<StringLiteral>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TimeLiteral {
|
|
||||||
Unsigned(Box<TimeLiteralUnsigned>),
|
|
||||||
FixedPoint(Box<TimeLiteralFixedPoint>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeLiteralUnsigned {
|
|
||||||
pub nodes: (UnsignedNumber, TimeUnit),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeLiteralFixedPoint {
|
|
||||||
pub nodes: (FixedPointNumber, TimeUnit),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TimeUnit {
|
|
||||||
S(Box<Keyword>),
|
|
||||||
MS(Box<Keyword>),
|
|
||||||
US(Box<Keyword>),
|
|
||||||
NS(Box<Keyword>),
|
|
||||||
PS(Box<Keyword>),
|
|
||||||
FS(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImplicitClassHandle {
|
|
||||||
This(Box<Keyword>),
|
|
||||||
Super(Box<Keyword>),
|
|
||||||
ThisSuper(Box<(Keyword, Symbol, Keyword)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BitSelect {
|
|
||||||
nodes: (Vec<Bracket<Expression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Select {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(
|
|
||||||
Vec<(Symbol, MemberIdentifier, BitSelect)>,
|
|
||||||
Symbol,
|
|
||||||
MemberIdentifier,
|
|
||||||
)>,
|
|
||||||
BitSelect,
|
|
||||||
Option<Bracket<PartSelectRange>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonrangeSelect {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(
|
|
||||||
Vec<(Symbol, MemberIdentifier, BitSelect)>,
|
|
||||||
Symbol,
|
|
||||||
MemberIdentifier,
|
|
||||||
)>,
|
|
||||||
BitSelect,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantBitSelect {
|
|
||||||
nodes: (Vec<Bracket<ConstantExpression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantSelect {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(
|
|
||||||
Vec<(Symbol, MemberIdentifier, ConstantBitSelect)>,
|
|
||||||
Symbol,
|
|
||||||
MemberIdentifier,
|
|
||||||
)>,
|
|
||||||
ConstantBitSelect,
|
|
||||||
Option<Bracket<ConstantPartSelectRange>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantCast {
|
|
||||||
pub nodes: (CastingType, Symbol, Paren<ConstantExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantLetExpression {
|
|
||||||
pub nodes: (LetExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Cast {
|
|
||||||
pub nodes: (CastingType, Symbol, Paren<Expression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -627,31 +377,3 @@ pub(crate) fn cast(s: Span) -> IResult<Span, Cast> {
|
|||||||
let (s, c) = paren(expression)(s)?;
|
let (s, c) = paren(expression)(s)?;
|
||||||
Ok((s, Cast { nodes: (a, b, c) }))
|
Ok((s, Cast { nodes: (a, b, c) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_primary() {
|
|
||||||
parser_test!(primary, "2.1ns ", Ok((_, Primary::PrimaryLiteral(_))));
|
|
||||||
parser_test!(primary, "40 ps ", Ok((_, Primary::PrimaryLiteral(_))));
|
|
||||||
parser_test!(primary, "'0", Ok((_, Primary::PrimaryLiteral(_))));
|
|
||||||
parser_test!(primary, "10", Ok((_, Primary::PrimaryLiteral(_))));
|
|
||||||
parser_test!(primary, "\"aaa\"", Ok((_, Primary::PrimaryLiteral(_))));
|
|
||||||
parser_test!(primary, "this ", Ok((_, Primary::This(_))));
|
|
||||||
parser_test!(primary, "$", Ok((_, Primary::Dollar(_))));
|
|
||||||
parser_test!(primary, "null ", Ok((_, Primary::Null(_))));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_cast() {
|
|
||||||
parser_test!(cast, "int'(2.0 * 3.0)", Ok((_, _)));
|
|
||||||
parser_test!(cast, "shortint'({8'hFA,8'hCE}) ", Ok((_, _)));
|
|
||||||
parser_test!(cast, "signed'(x)", Ok((_, _)));
|
|
||||||
parser_test!(cast, "const'(x)", Ok((_, _)));
|
|
||||||
parser_test!(cast, "type_t'(x)", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::bytes::complete::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StringLiteral {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -54,17 +41,3 @@ pub(crate) fn string_literal_impl(s: Span) -> IResult<Span, Locate> {
|
|||||||
|
|
||||||
Ok((s, a.into()))
|
Ok((s, a.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_string_literal() {
|
|
||||||
parser_test!(string_literal, "\"aaa aaaa\"", Ok((_, _)));
|
|
||||||
parser_test!(string_literal, r#""aaa\" aaaa""#, Ok((_, _)));
|
|
||||||
parser_test!(string_literal, r#""aaa\"""#, Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstantFunctionCall {
|
|
||||||
pub nodes: (FunctionSubroutineCall,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TfCall {
|
|
||||||
pub nodes: (
|
|
||||||
PsOrHierarchicalTfIdentifier,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<Paren<ListOfArguments>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SystemTfCall {
|
|
||||||
ArgOptionl(Box<SystemTfCallArgOptional>),
|
|
||||||
ArgDataType(Box<SystemTfCallArgDataType>),
|
|
||||||
ArgExpression(Box<SystemTfCallArgExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SystemTfCallArgOptional {
|
|
||||||
pub nodes: (SystemTfIdentifier, Option<Paren<ListOfArguments>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SystemTfCallArgDataType {
|
|
||||||
pub nodes: (
|
|
||||||
SystemTfIdentifier,
|
|
||||||
Paren<(DataType, Option<(Symbol, Expression)>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SystemTfCallArgExpression {
|
|
||||||
pub nodes: (
|
|
||||||
SystemTfIdentifier,
|
|
||||||
Paren<(
|
|
||||||
List<Symbol, Option<Expression>>,
|
|
||||||
Option<(Symbol, Option<ClockingEvent>)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SubroutineCall {
|
|
||||||
TfCall(Box<TfCall>),
|
|
||||||
SystemTfCall(Box<SystemTfCall>),
|
|
||||||
MethodCall(Box<MethodCall>),
|
|
||||||
Randomize(Box<SubroutineCallRandomize>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SubroutineCallRandomize {
|
|
||||||
pub nodes: (Option<(Keyword, Symbol)>, RandomizeCall),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionSubroutineCall {
|
|
||||||
pub nodes: (SubroutineCall,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ListOfArguments {
|
|
||||||
Ordered(Box<ListOfArgumentsOrdered>),
|
|
||||||
Named(Box<ListOfArgumentsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfArgumentsOrdered {
|
|
||||||
pub nodes: (
|
|
||||||
List<Symbol, Option<Expression>>,
|
|
||||||
Vec<(Symbol, Symbol, Identifier, Paren<Option<Expression>>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfArgumentsNamed {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Identifier,
|
|
||||||
Paren<Option<Expression>>,
|
|
||||||
Vec<(Symbol, Symbol, Identifier, Paren<Option<Expression>>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MethodCall {
|
|
||||||
pub nodes: (MethodCallRoot, Symbol, MethodCallBody),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum MethodCallBody {
|
|
||||||
User(Box<MethodCallBodyUser>),
|
|
||||||
BuiltInMethodCall(Box<BuiltInMethodCall>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MethodCallBodyUser {
|
|
||||||
pub nodes: (
|
|
||||||
MethodIdentifier,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<Paren<ListOfArguments>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BuiltInMethodCall {
|
|
||||||
ArrayManipulationCall(Box<ArrayManipulationCall>),
|
|
||||||
RandomizeCall(Box<RandomizeCall>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ArrayManipulationCall {
|
|
||||||
pub nodes: (
|
|
||||||
ArrayMethodName,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<Paren<ListOfArguments>>,
|
|
||||||
Option<(Keyword, Paren<Expression>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RandomizeCall {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<Paren<Option<VariableIdentifierListOrNull>>>,
|
|
||||||
Option<(
|
|
||||||
Keyword,
|
|
||||||
Option<Paren<Option<IdentifierList>>>,
|
|
||||||
ConstraintBlock,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum VariableIdentifierListOrNull {
|
|
||||||
VariableIdentifierList(Box<VariableIdentifierList>),
|
|
||||||
Null(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum MethodCallRoot {
|
|
||||||
Primary(Box<Primary>),
|
|
||||||
ImplicitClassHandle(Box<ImplicitClassHandle>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ArrayMethodName {
|
|
||||||
MethodIdentifier(Box<MethodIdentifier>),
|
|
||||||
Unique(Box<Keyword>),
|
|
||||||
And(Box<Keyword>),
|
|
||||||
Or(Box<Keyword>),
|
|
||||||
Xor(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -367,7 +200,9 @@ pub(crate) fn randomize_call(s: Span) -> IResult<Span, RandomizeCall> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn variable_identifier_list_or_null(s: Span) -> IResult<Span, VariableIdentifierListOrNull> {
|
pub(crate) fn variable_identifier_list_or_null(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, VariableIdentifierListOrNull> {
|
||||||
alt((
|
alt((
|
||||||
map(variable_identifier_list, |x| {
|
map(variable_identifier_list, |x| {
|
||||||
VariableIdentifierListOrNull::VariableIdentifierList(Box::new(x))
|
VariableIdentifierListOrNull::VariableIdentifierList(Box::new(x))
|
||||||
@ -400,5 +235,3 @@ pub(crate) fn array_method_name(s: Span) -> IResult<Span, ArrayMethodName> {
|
|||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
18
sv-parser-parser/src/general/attributes.rs
Normal file
18
sv-parser-parser/src/general/attributes.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn attribute_instance(s: Span) -> IResult<Span, AttributeInstance> {
|
||||||
|
let (s, a) = symbol("(*")(s)?;
|
||||||
|
let (s, b) = list(symbol(","), attr_spec)(s)?;
|
||||||
|
let (s, c) = symbol("*)")(s)?;
|
||||||
|
Ok((s, AttributeInstance { nodes: (a, b, c) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn attr_spec(s: Span) -> IResult<Span, AttrSpec> {
|
||||||
|
let (s, a) = identifier(s)?;
|
||||||
|
let (s, b) = opt(pair(symbol("="), constant_expression))(s)?;
|
||||||
|
Ok((s, AttrSpec { nodes: (a, b) }))
|
||||||
|
}
|
@ -1,15 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::bytes::complete::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Comment {
|
|
||||||
nodes: (Locate,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -35,17 +24,3 @@ pub(crate) fn block_comment(s: Span) -> IResult<Span, Comment> {
|
|||||||
let a = concat(a, c).unwrap();
|
let a = concat(a, c).unwrap();
|
||||||
Ok((s, Comment { nodes: (a.into(),) }))
|
Ok((s, Comment { nodes: (a.into(),) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_comment() {
|
|
||||||
parser_test!(comment, "// comment", Ok((_, _)));
|
|
||||||
parser_test!(comment, "/* comment\n\n */", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::bytes::complete::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::error::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::{Err, IResult};
|
|
||||||
use nom_packrat::packrat_parser;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -16,531 +7,6 @@ pub(crate) const AZ09_: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV
|
|||||||
pub(crate) const AZ09_DOLLAR: &str =
|
pub(crate) const AZ09_DOLLAR: &str =
|
||||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$";
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$";
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ArrayIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BlockIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BinIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CIdentifier {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CellIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassVariableIdentifier {
|
|
||||||
pub nodes: (VariableIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClockingIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CovergroupVariableIdentifier {
|
|
||||||
pub nodes: (VariableIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CoverPointIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CrossIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DynamicArrayVariableIdentifier {
|
|
||||||
pub nodes: (VariableIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnumIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EscapedIdentifier {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FormalIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FormalPortIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FunctionIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenerateBlockIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalArrayIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalBlockIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalEventIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalIdentifier {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Root>,
|
|
||||||
Vec<(Identifier, ConstantBitSelect, Symbol)>,
|
|
||||||
Identifier,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Root {
|
|
||||||
pub nodes: (Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalNetIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalParameterIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalPropertyIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalSequenceIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalTaskIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalTfIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalVariableIdentifier {
|
|
||||||
pub nodes: (HierarchicalIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Identifier {
|
|
||||||
SimpleIdentifier(Box<SimpleIdentifier>),
|
|
||||||
EscapedIdentifier(Box<EscapedIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IndexVariableIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceInstanceIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InoutPortIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InputPortIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InstanceIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LibraryIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MemberIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MethodIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModportIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetTypeIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputPortIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PackageIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PackageScope {
|
|
||||||
Package(Box<PackageScopePackage>),
|
|
||||||
Unit(Box<Unit>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PackageScopePackage {
|
|
||||||
pub nodes: (PackageIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Unit {
|
|
||||||
pub nodes: (Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProductionIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PropertyIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsClassIdentifier {
|
|
||||||
pub nodes: (Option<PackageScope>, ClassIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsCovergroupIdentifier {
|
|
||||||
pub nodes: (Option<PackageScope>, CovergroupIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsCheckerIdentifier {
|
|
||||||
pub nodes: (Option<PackageScope>, CheckerIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsIdentifier {
|
|
||||||
pub nodes: (Option<PackageScope>, Identifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalArrayIdentifier {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ImplicitClassHandleOrClassScopeOrPackageScope>,
|
|
||||||
HierarchicalArrayIdentifier,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PsOrHierarchicalNetIdentifier {
|
|
||||||
PackageScope(Box<PsOrHierarchicalNetIdentifierPackageScope>),
|
|
||||||
HierarchicalNetIdentifier(Box<HierarchicalNetIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalNetIdentifierPackageScope {
|
|
||||||
pub nodes: (Option<PackageScope>, NetIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalNetIdentifierHierarchical {
|
|
||||||
pub nodes: (HierarchicalNetIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PsOrHierarchicalPropertyIdentifier {
|
|
||||||
PackageScope(Box<PsOrHierarchicalPropertyIdentifierPackageScope>),
|
|
||||||
HierarchicalPropertyIdentifier(Box<HierarchicalPropertyIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalPropertyIdentifierPackageScope {
|
|
||||||
pub nodes: (Option<PackageScope>, PropertyIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalPropertyIdentifierHierarchical {
|
|
||||||
pub nodes: (HierarchicalPropertyIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PsOrHierarchicalSequenceIdentifier {
|
|
||||||
PackageScope(Box<PsOrHierarchicalSequenceIdentifierPackageScope>),
|
|
||||||
HierarchicalSequenceIdentifier(Box<HierarchicalSequenceIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalSequenceIdentifierPackageScope {
|
|
||||||
pub nodes: (Option<PackageScope>, SequenceIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalSequenceIdentifierHierarchical {
|
|
||||||
pub nodes: (HierarchicalSequenceIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PsOrHierarchicalTfIdentifier {
|
|
||||||
PackageScope(Box<PsOrHierarchicalTfIdentifierPackageScope>),
|
|
||||||
HierarchicalTfIdentifier(Box<HierarchicalTfIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalTfIdentifierPackageScope {
|
|
||||||
pub nodes: (Option<PackageScope>, TfIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsOrHierarchicalTfIdentifierHierarchical {
|
|
||||||
pub nodes: (HierarchicalTfIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PsParameterIdentifier {
|
|
||||||
Scope(Box<PsParameterIdentifierScope>),
|
|
||||||
Generate(Box<PsParameterIdentifierGenerate>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsParameterIdentifierScope {
|
|
||||||
pub nodes: (Option<PackageScopeOrClassScope>, ParameterIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsParameterIdentifierGenerate {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<(
|
|
||||||
GenerateBlockIdentifier,
|
|
||||||
Option<Bracket<ConstantExpression>>,
|
|
||||||
Symbol,
|
|
||||||
)>,
|
|
||||||
ParameterIdentifier,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PsTypeIdentifier {
|
|
||||||
pub nodes: (Option<LocalOrPackageScopeOrClassScope>, TypeIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum LocalOrPackageScopeOrClassScope {
|
|
||||||
Local(Box<Local>),
|
|
||||||
PackageScope(Box<PackageScope>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Local {
|
|
||||||
pub nodes: (Keyword, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequenceIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SignalIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimpleIdentifier {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SpecparamIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SystemTfIdentifier {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TaskIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TfIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TerminalIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TopmoduleIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TypeIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariableIdentifier {
|
|
||||||
pub nodes: (Identifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImplicitClassHandleOrClassScopeOrPackageScope {
|
|
||||||
ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
PackageScope(Box<PackageScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImplicitClassHandleOrPackageScope {
|
|
||||||
ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>),
|
|
||||||
PackageScope(Box<PackageScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ImplicitClassHandleOrClassScope {
|
|
||||||
ImplicitClassHandle(Box<(ImplicitClassHandle, Symbol)>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PackageScopeOrClassScope {
|
|
||||||
PackageScope(Box<PackageScope>),
|
|
||||||
ClassScope(Box<ClassScope>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn array_identifier(s: Span) -> IResult<Span, ArrayIdentifier> {
|
pub(crate) fn array_identifier(s: Span) -> IResult<Span, ArrayIdentifier> {
|
||||||
@ -1318,44 +784,3 @@ pub(crate) fn local(s: Span) -> IResult<Span, Local> {
|
|||||||
let (s, b) = symbol("::")(s)?;
|
let (s, b) = symbol("::")(s)?;
|
||||||
Ok((s, Local { nodes: (a, b) }))
|
Ok((s, Local { nodes: (a, b) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_identifier() {
|
|
||||||
parser_test!(
|
|
||||||
identifier,
|
|
||||||
"shiftreg_a",
|
|
||||||
Ok((_, Identifier::SimpleIdentifier(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
identifier,
|
|
||||||
"_bus3",
|
|
||||||
Ok((_, Identifier::SimpleIdentifier(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
identifier,
|
|
||||||
"n$657",
|
|
||||||
Ok((_, Identifier::SimpleIdentifier(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
identifier,
|
|
||||||
"\\busa+index",
|
|
||||||
Ok((_, Identifier::EscapedIdentifier(_)))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
identifier,
|
|
||||||
"\\-clock",
|
|
||||||
Ok((_, Identifier::EscapedIdentifier(_)))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_system_tf_identifier() {
|
|
||||||
parser_test!(system_tf_identifier, "$display", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
6
sv-parser-parser/src/general/mod.rs
Normal file
6
sv-parser-parser/src/general/mod.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
pub mod attributes;
|
||||||
|
pub mod comments;
|
||||||
|
pub mod identifiers;
|
||||||
|
pub(crate) use attributes::*;
|
||||||
|
pub(crate) use comments::*;
|
||||||
|
pub(crate) use identifiers::*;
|
@ -1,63 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerInstantiation {
|
|
||||||
pub nodes: (
|
|
||||||
PsCheckerIdentifier,
|
|
||||||
NameOfInstance,
|
|
||||||
Paren<Option<ListOfCheckerPortConnections>>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ListOfCheckerPortConnections {
|
|
||||||
Ordered(Box<ListOfCheckerPortConnectionsOrdered>),
|
|
||||||
Named(Box<ListOfCheckerPortConnectionsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfCheckerPortConnectionsOrdered {
|
|
||||||
pub nodes: (List<Symbol, OrderedCheckerPortConnection>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfCheckerPortConnectionsNamed {
|
|
||||||
pub nodes: (List<Symbol, NamedCheckerPortConnection>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OrderedCheckerPortConnection {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Option<PropertyActualArg>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NamedCheckerPortConnection {
|
|
||||||
Identifier(Box<NamedCheckerPortConnectionIdentifier>),
|
|
||||||
Asterisk(Box<NamedCheckerPortConnectionAsterisk>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NamedCheckerPortConnectionIdentifier {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Symbol,
|
|
||||||
FormalPortIdentifier,
|
|
||||||
Option<Paren<Option<PropertyActualArg>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NamedCheckerPortConnectionAsterisk {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -76,7 +17,9 @@ pub(crate) fn checker_instantiation(s: Span) -> IResult<Span, CheckerInstantiati
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn list_of_checker_port_connections(s: Span) -> IResult<Span, ListOfCheckerPortConnections> {
|
pub(crate) fn list_of_checker_port_connections(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfCheckerPortConnections> {
|
||||||
alt((
|
alt((
|
||||||
list_of_checker_port_connections_ordered,
|
list_of_checker_port_connections_ordered,
|
||||||
list_of_checker_port_connections_named,
|
list_of_checker_port_connections_named,
|
||||||
@ -110,7 +53,9 @@ pub(crate) fn list_of_checker_port_connections_named(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(MaybeRecursive)]
|
#[parser(MaybeRecursive)]
|
||||||
pub(crate) fn ordered_checker_port_connection(s: Span) -> IResult<Span, OrderedCheckerPortConnection> {
|
pub(crate) fn ordered_checker_port_connection(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, OrderedCheckerPortConnection> {
|
||||||
let (s, x) = many0(attribute_instance)(s)?;
|
let (s, x) = many0(attribute_instance)(s)?;
|
||||||
let (s, y) = opt(property_actual_arg)(s)?;
|
let (s, y) = opt(property_actual_arg)(s)?;
|
||||||
Ok((s, OrderedCheckerPortConnection { nodes: (x, y) }))
|
Ok((s, OrderedCheckerPortConnection { nodes: (x, y) }))
|
||||||
@ -153,5 +98,3 @@ pub(crate) fn named_checker_port_connection_asterisk(
|
|||||||
})),
|
})),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,131 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenerateRegion {
|
|
||||||
pub nodes: (Keyword, Vec<GenerateItem>, Keyword),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LoopGenerateConstruct {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
GenvarInitialization,
|
|
||||||
Symbol,
|
|
||||||
GenvarExpression,
|
|
||||||
Symbol,
|
|
||||||
GenvarIteration,
|
|
||||||
)>,
|
|
||||||
GenerateBlock,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarInitialization {
|
|
||||||
pub nodes: (Option<Genvar>, GenvarIdentifier, Symbol, ConstantExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Genvar {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum GenvarIteration {
|
|
||||||
Assignment(Box<GenvarIterationAssignment>),
|
|
||||||
Prefix(Box<GenvarIterationPrefix>),
|
|
||||||
Suffix(Box<GenvarIterationSuffix>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarIterationAssignment {
|
|
||||||
pub nodes: (GenvarIdentifier, AssignmentOperator, GenvarExpression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarIterationPrefix {
|
|
||||||
pub nodes: (IncOrDecOperator, GenvarIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenvarIterationSuffix {
|
|
||||||
pub nodes: (GenvarIdentifier, IncOrDecOperator),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConditionalGenerateConstruct {
|
|
||||||
If(Box<IfGenerateConstruct>),
|
|
||||||
Case(Box<CaseGenerateConstruct>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IfGenerateConstruct {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<ConstantExpression>,
|
|
||||||
GenerateBlock,
|
|
||||||
Option<(Keyword, GenerateBlock)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseGenerateConstruct {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<ConstantExpression>,
|
|
||||||
Vec<CaseGenerateItem>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CaseGenerateItem {
|
|
||||||
Nondefault(Box<CaseGenerateItemNondefault>),
|
|
||||||
Default(Box<CaseGenerateItemDefault>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseGenerateItemNondefault {
|
|
||||||
pub nodes: (List<Symbol, ConstantExpression>, Symbol, GenerateBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CaseGenerateItemDefault {
|
|
||||||
pub nodes: (Keyword, Option<Symbol>, GenerateBlock),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum GenerateBlock {
|
|
||||||
GenerateItem(Box<GenerateItem>),
|
|
||||||
Multiple(Box<GenerateBlockMultiple>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GenerateBlockMultiple {
|
|
||||||
pub nodes: (
|
|
||||||
Option<(GenerateBlockIdentifier, Symbol)>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, GenerateBlockIdentifier)>,
|
|
||||||
Vec<GenerateItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, GenerateBlockIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum GenerateItem {
|
|
||||||
ModuleOrGenerateItem(Box<ModuleOrGenerateItem>),
|
|
||||||
InterfaceOrGenerateItem(Box<InterfaceOrGenerateItem>),
|
|
||||||
CheckerOrGenerateItem(Box<CheckerOrGenerateItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -206,7 +79,9 @@ pub(crate) fn genvar_iteration_suffix(s: Span) -> IResult<Span, GenvarIteration>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn conditional_generate_construct(s: Span) -> IResult<Span, ConditionalGenerateConstruct> {
|
pub(crate) fn conditional_generate_construct(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ConditionalGenerateConstruct> {
|
||||||
alt((
|
alt((
|
||||||
map(if_generate_construct, |x| {
|
map(if_generate_construct, |x| {
|
||||||
ConditionalGenerateConstruct::If(Box::new(x))
|
ConditionalGenerateConstruct::If(Box::new(x))
|
||||||
@ -310,5 +185,3 @@ pub(crate) fn generate_item(s: Span) -> IResult<Span, GenerateItem> {
|
|||||||
}),
|
}),
|
||||||
))(s)
|
))(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,19 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceInstantiation {
|
|
||||||
pub nodes: (
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Option<ParameterValueAssignment>,
|
|
||||||
List<Symbol, HierarchicalInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -30,5 +15,3 @@ pub(crate) fn interface_instantiation(s: Span) -> IResult<Span, InterfaceInstant
|
|||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
10
sv-parser-parser/src/instantiations/mod.rs
Normal file
10
sv-parser-parser/src/instantiations/mod.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pub mod checker_instantiation;
|
||||||
|
pub mod generated_instantiation;
|
||||||
|
pub mod interface_instantiation;
|
||||||
|
pub mod module_instantiation;
|
||||||
|
pub mod program_instantiation;
|
||||||
|
pub(crate) use checker_instantiation::*;
|
||||||
|
pub(crate) use generated_instantiation::*;
|
||||||
|
pub(crate) use interface_instantiation::*;
|
||||||
|
pub(crate) use module_instantiation::*;
|
||||||
|
pub(crate) use program_instantiation::*;
|
@ -1,104 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleInstantiation {
|
|
||||||
pub nodes: (
|
|
||||||
ModuleIdentifier,
|
|
||||||
Option<ParameterValueAssignment>,
|
|
||||||
List<Symbol, HierarchicalInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterValueAssignment {
|
|
||||||
pub nodes: (Symbol, Paren<Option<ListOfParameterAssignments>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ListOfParameterAssignments {
|
|
||||||
Ordered(Box<ListOfParameterAssignmentsOrdered>),
|
|
||||||
Named(Box<ListOfParameterAssignmentsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfParameterAssignmentsOrdered {
|
|
||||||
pub nodes: (List<Symbol, OrderedParameterAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfParameterAssignmentsNamed {
|
|
||||||
pub nodes: (List<Symbol, NamedParameterAssignment>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OrderedParameterAssignment {
|
|
||||||
pub nodes: (ParamExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NamedParameterAssignment {
|
|
||||||
pub nodes: (Symbol, ParameterIdentifier, Paren<Option<ParamExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HierarchicalInstance {
|
|
||||||
pub nodes: (NameOfInstance, Paren<Option<ListOfPortConnections>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NameOfInstance {
|
|
||||||
pub nodes: (InstanceIdentifier, Vec<UnpackedDimension>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ListOfPortConnections {
|
|
||||||
Ordered(Box<ListOfPortConnectionsOrdered>),
|
|
||||||
Named(Box<ListOfPortConnectionsNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPortConnectionsOrdered {
|
|
||||||
pub nodes: (List<Symbol, OrderedPortConnection>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPortConnectionsNamed {
|
|
||||||
pub nodes: (List<Symbol, NamedPortConnection>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OrderedPortConnection {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Option<Expression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NamedPortConnection {
|
|
||||||
Identifier(Box<NamedPortConnectionIdentifier>),
|
|
||||||
Asterisk(Box<NamedPortConnectionAsterisk>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NamedPortConnectionIdentifier {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Symbol,
|
|
||||||
PortIdentifier,
|
|
||||||
Option<Paren<Option<Expression>>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NamedPortConnectionAsterisk {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -132,7 +32,9 @@ pub(crate) fn list_of_parameter_assignments(s: Span) -> IResult<Span, ListOfPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser(MaybeRecursive)]
|
#[parser(MaybeRecursive)]
|
||||||
pub(crate) fn list_of_parameter_assignments_ordered(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
pub(crate) fn list_of_parameter_assignments_ordered(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfParameterAssignments> {
|
||||||
let (s, a) = list(symbol(","), ordered_parameter_assignment)(s)?;
|
let (s, a) = list(symbol(","), ordered_parameter_assignment)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
@ -143,7 +45,9 @@ pub(crate) fn list_of_parameter_assignments_ordered(s: Span) -> IResult<Span, Li
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn list_of_parameter_assignments_named(s: Span) -> IResult<Span, ListOfParameterAssignments> {
|
pub(crate) fn list_of_parameter_assignments_named(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ListOfParameterAssignments> {
|
||||||
let (s, a) = list(symbol(","), named_parameter_assignment)(s)?;
|
let (s, a) = list(symbol(","), named_parameter_assignment)(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
s,
|
s,
|
||||||
@ -245,5 +149,3 @@ pub(crate) fn named_port_connection_asterisk(s: Span) -> IResult<Span, NamedPort
|
|||||||
NamedPortConnection::Asterisk(Box::new(NamedPortConnectionAsterisk { nodes: (a, b) })),
|
NamedPortConnection::Asterisk(Box::new(NamedPortConnectionAsterisk { nodes: (a, b) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,19 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramInstantiation {
|
|
||||||
pub nodes: (
|
|
||||||
ProgramIdentifier,
|
|
||||||
Option<ParameterValueAssignment>,
|
|
||||||
List<Symbol, HierarchicalInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -30,5 +15,3 @@ pub(crate) fn program_instantiation(s: Span) -> IResult<Span, ProgramInstantiati
|
|||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,6 +1,8 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub use utils::*;
|
pub(crate) use utils::*;
|
||||||
|
|
||||||
|
mod tests;
|
||||||
|
|
||||||
pub mod behavioral_statements;
|
pub mod behavioral_statements;
|
||||||
pub mod declarations;
|
pub mod declarations;
|
||||||
@ -11,38 +13,55 @@ pub mod primitive_instances;
|
|||||||
pub mod source_text;
|
pub mod source_text;
|
||||||
pub mod specify_section;
|
pub mod specify_section;
|
||||||
pub mod udp_declaration_and_instantiation;
|
pub mod udp_declaration_and_instantiation;
|
||||||
pub use behavioral_statements::*;
|
pub(crate) use behavioral_statements::*;
|
||||||
pub use declarations::*;
|
pub(crate) use declarations::*;
|
||||||
pub use expressions::*;
|
pub(crate) use expressions::*;
|
||||||
pub use general::*;
|
pub(crate) use general::*;
|
||||||
pub use instantiations::*;
|
pub(crate) use instantiations::*;
|
||||||
pub use primitive_instances::*;
|
pub(crate) use primitive_instances::*;
|
||||||
pub use source_text::*;
|
pub(crate) use source_text::*;
|
||||||
pub use specify_section::*;
|
pub(crate) use specify_section::*;
|
||||||
pub use udp_declaration_and_instantiation::*;
|
pub(crate) use udp_declaration_and_instantiation::*;
|
||||||
|
|
||||||
|
pub(crate) use nom::branch::*;
|
||||||
|
pub(crate) use nom::bytes::complete::*;
|
||||||
|
pub(crate) use nom::character::complete::*;
|
||||||
|
pub(crate) use nom::combinator::*;
|
||||||
|
pub(crate) use nom::error::{make_error, ErrorKind};
|
||||||
|
pub(crate) use nom::multi::*;
|
||||||
|
pub(crate) use nom::sequence::*;
|
||||||
|
pub(crate) use nom::{Err, IResult};
|
||||||
|
pub(crate) use nom_packrat::{self, packrat_parser};
|
||||||
pub(crate) use sv_parser_macros::*;
|
pub(crate) use sv_parser_macros::*;
|
||||||
|
pub(crate) use sv_parser_syntaxtree::*;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub(crate) const RECURSIVE_FLAG_WORDS: usize = 1;
|
nom_packrat::storage!(AnyNode);
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, PartialEq)]
|
pub fn parse_sv(s: &str) -> Result<SourceText, ()> {
|
||||||
pub(crate) struct Extra {
|
let s = Span::new_extra(s, Extra::default());
|
||||||
#[cfg(feature = "trace")]
|
match source_text(s) {
|
||||||
pub depth: usize,
|
Ok((_, x)) => Ok(x),
|
||||||
pub recursive_flag: [u128; RECURSIVE_FLAG_WORDS],
|
Err(_) => Err(()),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type Span<'a> = nom_locate::LocatedSpanEx<&'a str, Extra>;
|
pub fn parse_lib(s: &str) -> Result<LibraryText, ()> {
|
||||||
|
let s = Span::new_extra(s, Extra::default());
|
||||||
|
match library_text(s) {
|
||||||
|
Ok((_, x)) => Ok(x),
|
||||||
|
Err(_) => Err(()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
mod thread_context {
|
mod thread_context {
|
||||||
|
|
||||||
use crate::parser::RECURSIVE_FLAG_WORDS;
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use sv_parser_syntaxtree::RECURSIVE_FLAG_WORDS;
|
||||||
|
|
||||||
pub struct ParserIndex {
|
pub struct ParserIndex {
|
||||||
index: HashMap<&'static str, usize>,
|
index: HashMap<&'static str, usize>,
|
8
sv-parser-parser/src/primitive_instances/mod.rs
Normal file
8
sv-parser-parser/src/primitive_instances/mod.rs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
pub mod primitive_gate_and_switch_types;
|
||||||
|
pub mod primitive_instantiation_and_instances;
|
||||||
|
pub mod primitive_strengths;
|
||||||
|
pub mod primitive_terminals;
|
||||||
|
pub(crate) use primitive_gate_and_switch_types::*;
|
||||||
|
pub(crate) use primitive_instantiation_and_instances::*;
|
||||||
|
pub(crate) use primitive_strengths::*;
|
||||||
|
pub(crate) use primitive_terminals::*;
|
@ -0,0 +1,67 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn cmos_switchtype(s: Span) -> IResult<Span, CmosSwitchtype> {
|
||||||
|
let (s, a) = alt((keyword("cmos"), keyword("rcmos")))(s)?;
|
||||||
|
Ok((s, CmosSwitchtype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn enable_gatetype(s: Span) -> IResult<Span, EnableGatetype> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
keyword("bufif0"),
|
||||||
|
keyword("bufif1"),
|
||||||
|
keyword("notif0"),
|
||||||
|
keyword("notif1"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, EnableGatetype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn mos_switchtype(s: Span) -> IResult<Span, MosSwitchtype> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
keyword("nmos"),
|
||||||
|
keyword("pmos"),
|
||||||
|
keyword("rnmos"),
|
||||||
|
keyword("rpmos"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, MosSwitchtype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn n_input_gatetype(s: Span) -> IResult<Span, NInputGatetype> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
keyword("and"),
|
||||||
|
keyword("nand"),
|
||||||
|
keyword("or"),
|
||||||
|
keyword("nor"),
|
||||||
|
keyword("xor"),
|
||||||
|
keyword("xnor"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, NInputGatetype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn n_output_gatetype(s: Span) -> IResult<Span, NOutputGatetype> {
|
||||||
|
let (s, a) = alt((keyword("buf"), keyword("not")))(s)?;
|
||||||
|
Ok((s, NOutputGatetype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn pass_en_switchtype(s: Span) -> IResult<Span, PassEnSwitchtype> {
|
||||||
|
let (s, a) = alt((
|
||||||
|
keyword("tranif0"),
|
||||||
|
keyword("tranif1"),
|
||||||
|
keyword("rtranif0"),
|
||||||
|
keyword("rtranif1"),
|
||||||
|
))(s)?;
|
||||||
|
Ok((s, PassEnSwitchtype { nodes: (a,) }))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[parser]
|
||||||
|
pub(crate) fn pass_switchtype(s: Span) -> IResult<Span, PassSwitchtype> {
|
||||||
|
let (s, a) = alt((keyword("tran"), keyword("rtran")))(s)?;
|
||||||
|
Ok((s, PassSwitchtype { nodes: (a,) }))
|
||||||
|
}
|
@ -1,193 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum GateInstantiation {
|
|
||||||
Cmos(Box<GateInstantiationCmos>),
|
|
||||||
Enable(Box<GateInstantiationEnable>),
|
|
||||||
Mos(Box<GateInstantiationMos>),
|
|
||||||
NInput(Box<GateInstantiationNInput>),
|
|
||||||
NOutput(Box<GateInstantiationNOutput>),
|
|
||||||
PassEn(Box<GateInstantiationPassEn>),
|
|
||||||
Pass(Box<GateInstantiationPass>),
|
|
||||||
Pulldown(Box<GateInstantiationPulldown>),
|
|
||||||
Pullup(Box<GateInstantiationPullup>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationCmos {
|
|
||||||
pub nodes: (
|
|
||||||
CmosSwitchtype,
|
|
||||||
Option<Delay3>,
|
|
||||||
List<Symbol, CmosSwitchInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationEnable {
|
|
||||||
pub nodes: (
|
|
||||||
EnableGatetype,
|
|
||||||
Option<DriveStrength>,
|
|
||||||
Option<Delay3>,
|
|
||||||
List<Symbol, EnableGateInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationMos {
|
|
||||||
pub nodes: (
|
|
||||||
MosSwitchtype,
|
|
||||||
Option<Delay3>,
|
|
||||||
List<Symbol, MosSwitchInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationNInput {
|
|
||||||
pub nodes: (
|
|
||||||
NInputGatetype,
|
|
||||||
Option<DriveStrength>,
|
|
||||||
Option<Delay2>,
|
|
||||||
List<Symbol, NInputGateInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationNOutput {
|
|
||||||
pub nodes: (
|
|
||||||
NOutputGatetype,
|
|
||||||
Option<DriveStrength>,
|
|
||||||
Option<Delay2>,
|
|
||||||
List<Symbol, NOutputGateInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationPassEn {
|
|
||||||
pub nodes: (
|
|
||||||
PassEnSwitchtype,
|
|
||||||
Option<Delay2>,
|
|
||||||
List<Symbol, PassEnableSwitchInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationPass {
|
|
||||||
pub nodes: (PassSwitchtype, List<Symbol, PassSwitchInstance>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationPulldown {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<PulldownStrength>,
|
|
||||||
List<Symbol, PullGateInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct GateInstantiationPullup {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<PullupStrength>,
|
|
||||||
List<Symbol, PullGateInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CmosSwitchInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(
|
|
||||||
OutputTerminal,
|
|
||||||
Symbol,
|
|
||||||
InputTerminal,
|
|
||||||
Symbol,
|
|
||||||
NcontrolTerminal,
|
|
||||||
Symbol,
|
|
||||||
PcontrolTerminal,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnableGateInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(
|
|
||||||
OutputTerminal,
|
|
||||||
Symbol,
|
|
||||||
InputTerminal,
|
|
||||||
Symbol,
|
|
||||||
EnableTerminal,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct MosSwitchInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(
|
|
||||||
OutputTerminal,
|
|
||||||
Symbol,
|
|
||||||
InputTerminal,
|
|
||||||
Symbol,
|
|
||||||
EnableTerminal,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NInputGateInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(OutputTerminal, Symbol, List<Symbol, InputTerminal>)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NOutputGateInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(List<Symbol, OutputTerminal>, Symbol, InputTerminal)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PassSwitchInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(InoutTerminal, Symbol, InoutTerminal)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PassEnableSwitchInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(InoutTerminal, Symbol, InoutTerminal, Symbol, EnableTerminal)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PullGateInstance {
|
|
||||||
pub nodes: (Option<NameOfInstance>, Paren<OutputTerminal>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,53 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PulldownStrength {
|
|
||||||
Strength01(Box<PulldownStrength01>),
|
|
||||||
Strength10(Box<PulldownStrength10>),
|
|
||||||
Strength0(Box<PulldownStrength0>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulldownStrength01 {
|
|
||||||
pub nodes: (Paren<(Strength0, Symbol, Strength1)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulldownStrength10 {
|
|
||||||
pub nodes: (Paren<(Strength1, Symbol, Strength0)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulldownStrength0 {
|
|
||||||
pub nodes: (Paren<Strength0>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PullupStrength {
|
|
||||||
Strength01(Box<PullupStrength01>),
|
|
||||||
Strength10(Box<PullupStrength10>),
|
|
||||||
Strength1(Box<PullupStrength1>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PullupStrength01 {
|
|
||||||
pub nodes: (Paren<(Strength0, Symbol, Strength1)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PullupStrength10 {
|
|
||||||
pub nodes: (Paren<(Strength1, Symbol, Strength0)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PullupStrength1 {
|
|
||||||
pub nodes: (Paren<Strength1>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -114,25 +65,3 @@ pub(crate) fn pullup_strength1(s: Span) -> IResult<Span, PullupStrength> {
|
|||||||
PullupStrength::Strength1(Box::new(PullupStrength1 { nodes: (a,) })),
|
PullupStrength::Strength1(Box::new(PullupStrength1 { nodes: (a,) })),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_pulldown_strength() {
|
|
||||||
parser_test!(pulldown_strength, "(supply0, strong1)", Ok((_, _)));
|
|
||||||
parser_test!(pulldown_strength, "(pull1, weak0)", Ok((_, _)));
|
|
||||||
parser_test!(pulldown_strength, "(pull0)", Ok((_, _)));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_pullup_strength() {
|
|
||||||
parser_test!(pullup_strength, "(supply0, strong1)", Ok((_, _)));
|
|
||||||
parser_test!(pullup_strength, "(pull1, weak0)", Ok((_, _)));
|
|
||||||
parser_test!(pullup_strength, "(supply1)", Ok((_, _)));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EnableTerminal {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InoutTerminal {
|
|
||||||
pub nodes: (NetLvalue,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InputTerminal {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NcontrolTerminal {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputTerminal {
|
|
||||||
pub nodes: (NetLvalue,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PcontrolTerminal {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -71,5 +37,3 @@ pub(crate) fn pcontrol_terminal(s: Span) -> IResult<Span, PcontrolTerminal> {
|
|||||||
let (s, a) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
Ok((s, PcontrolTerminal { nodes: (a,) }))
|
Ok((s, PcontrolTerminal { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
@ -1,88 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerPortList {
|
|
||||||
pub nodes: (List<Symbol, CheckerPortItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerPortItem {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Option<CheckerPortDirection>,
|
|
||||||
PropertyFormalType,
|
|
||||||
FormalPortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, PropertyActualArg)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CheckerPortDirection {
|
|
||||||
Input(Box<Keyword>),
|
|
||||||
Output(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CheckerOrGenerateItem {
|
|
||||||
CheckerOrGenerateItemDeclaration(Box<CheckerOrGenerateItemDeclaration>),
|
|
||||||
InitialConstruct(Box<InitialConstruct>),
|
|
||||||
AlwaysConstruct(Box<AlwaysConstruct>),
|
|
||||||
FinalConstruct(Box<FinalConstruct>),
|
|
||||||
AssertionItem(Box<AssertionItem>),
|
|
||||||
ContinuousAssign(Box<ContinuousAssign>),
|
|
||||||
CheckerGenerateItem(Box<CheckerGenerateItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CheckerOrGenerateItemDeclaration {
|
|
||||||
Data(Box<CheckerOrGenerateItemDeclarationData>),
|
|
||||||
FunctionDeclaration(Box<FunctionDeclaration>),
|
|
||||||
CheckerDeclaration(Box<CheckerDeclaration>),
|
|
||||||
AssertionItemDeclaration(Box<AssertionItemDeclaration>),
|
|
||||||
CovergroupDeclaration(Box<CovergroupDeclaration>),
|
|
||||||
GenvarDeclaration(Box<GenvarDeclaration>),
|
|
||||||
ClockingDeclaration(Box<ClockingDeclaration>),
|
|
||||||
Clocking(Box<CheckerOrGenerateItemDeclarationClocking>),
|
|
||||||
Disable(Box<CheckerOrGenerateItemDeclarationDisable>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerOrGenerateItemDeclarationData {
|
|
||||||
pub nodes: (Option<Rand>, DataDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Rand {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerOrGenerateItemDeclarationClocking {
|
|
||||||
pub nodes: (Keyword, Keyword, ClockingIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerOrGenerateItemDeclarationDisable {
|
|
||||||
pub nodes: (Keyword, Keyword, Keyword, ExpressionOrDist, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum CheckerGenerateItem {
|
|
||||||
LoopGenerateConstruct(Box<LoopGenerateConstruct>),
|
|
||||||
ConditionalGenerateConstruct(Box<ConditionalGenerateConstruct>),
|
|
||||||
GenerateRegion(Box<GenerateRegion>),
|
|
||||||
ElaborationSystemTask(Box<ElaborationSystemTask>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,188 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassItem {
|
|
||||||
Property(Box<ClassItemProperty>),
|
|
||||||
Method(Box<ClassItemMethod>),
|
|
||||||
Constraint(Box<ClassItemConstraint>),
|
|
||||||
Declaration(Box<ClassItemDeclaration>),
|
|
||||||
Covergroup(Box<ClassItemCovergroup>),
|
|
||||||
LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>),
|
|
||||||
ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassItemProperty {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ClassProperty),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassItemMethod {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ClassMethod),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassItemConstraint {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ClassConstraint),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassItemDeclaration {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ClassDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassItemCovergroup {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, CovergroupDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassProperty {
|
|
||||||
NonConst(Box<ClassPropertyNonConst>),
|
|
||||||
Const(Box<ClassPropertyConst>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassPropertyNonConst {
|
|
||||||
pub nodes: (Vec<PropertyQualifier>, DataDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassPropertyConst {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Vec<ClassItemQualifier>,
|
|
||||||
DataType,
|
|
||||||
ConstIdentifier,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassMethod {
|
|
||||||
Task(Box<ClassMethodTask>),
|
|
||||||
Function(Box<ClassMethodFunction>),
|
|
||||||
PureVirtual(Box<ClassMethodPureVirtual>),
|
|
||||||
ExternMethod(Box<ClassMethodExternMethod>),
|
|
||||||
Constructor(Box<ClassMethodConstructor>),
|
|
||||||
ExternConstructor(Box<ClassMethodExternConstructor>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodTask {
|
|
||||||
pub nodes: (Vec<MethodQualifier>, TaskDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodFunction {
|
|
||||||
pub nodes: (Vec<MethodQualifier>, FunctionDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodPureVirtual {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
Vec<ClassItemQualifier>,
|
|
||||||
MethodPrototype,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodExternMethod {
|
|
||||||
pub nodes: (Keyword, Vec<MethodQualifier>, MethodPrototype, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodConstructor {
|
|
||||||
pub nodes: (Vec<MethodQualifier>, ClassConstructorDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassMethodExternConstructor {
|
|
||||||
pub nodes: (Keyword, Vec<MethodQualifier>, ClassConstructorPrototype),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassConstructorPrototype {
|
|
||||||
pub nodes: (Keyword, Keyword, Option<Paren<Option<TfPortList>>>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassConstraint {
|
|
||||||
ConstraintPrototype(Box<ConstraintPrototype>),
|
|
||||||
ConstraintDeclaration(Box<ConstraintDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ClassItemQualifier {
|
|
||||||
Static(Box<Keyword>),
|
|
||||||
Protected(Box<Keyword>),
|
|
||||||
Local(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PropertyQualifier {
|
|
||||||
RandomQualifier(Box<RandomQualifier>),
|
|
||||||
ClassItemQualifier(Box<ClassItemQualifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum RandomQualifier {
|
|
||||||
Rand(Box<Keyword>),
|
|
||||||
Randc(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum MethodQualifier {
|
|
||||||
Virtual(Box<Keyword>),
|
|
||||||
PureVirtual(Box<(Keyword, Keyword)>),
|
|
||||||
ClassItemQualifier(Box<ClassItemQualifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum MethodPrototype {
|
|
||||||
TaskPrototype(Box<TaskPrototype>),
|
|
||||||
FunctionPrototype(Box<FunctionPrototype>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassConstructorDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<ClassScope>,
|
|
||||||
Keyword,
|
|
||||||
Option<Paren<Option<TfPortList>>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<BlockItemDeclaration>,
|
|
||||||
Option<(
|
|
||||||
Keyword,
|
|
||||||
Symbol,
|
|
||||||
Keyword,
|
|
||||||
Option<Paren<ListOfArguments>>,
|
|
||||||
Symbol,
|
|
||||||
)>,
|
|
||||||
Vec<FunctionStatementOrNull>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, New)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct New {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,136 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
ConfigIdentifier,
|
|
||||||
Symbol,
|
|
||||||
Vec<(LocalParameterDeclaration, Symbol)>,
|
|
||||||
DesignStatement,
|
|
||||||
Vec<ConfigRuleStatement>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ConfigIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DesignStatement {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Vec<(Option<(LibraryIdentifier, Symbol)>, CellIdentifier)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConfigRuleStatement {
|
|
||||||
Default(Box<ConfigRuleStatementDefault>),
|
|
||||||
InstLib(Box<ConfigRuleStatementInstLib>),
|
|
||||||
InstUse(Box<ConfigRuleStatementInstUse>),
|
|
||||||
CellLib(Box<ConfigRuleStatementCellLib>),
|
|
||||||
CellUse(Box<ConfigRuleStatementCellUse>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigRuleStatementDefault {
|
|
||||||
pub nodes: (DefaultClause, LiblistClause, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigRuleStatementInstLib {
|
|
||||||
pub nodes: (InstClause, LiblistClause, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigRuleStatementInstUse {
|
|
||||||
pub nodes: (InstClause, UseClause, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigRuleStatementCellLib {
|
|
||||||
pub nodes: (CellClause, LiblistClause, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConfigRuleStatementCellUse {
|
|
||||||
pub nodes: (CellClause, UseClause, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DefaultClause {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InstClause {
|
|
||||||
pub nodes: (Keyword, InstName),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InstName {
|
|
||||||
pub nodes: (TopmoduleIdentifier, Vec<(Symbol, InstanceIdentifier)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CellClause {
|
|
||||||
pub nodes: (Keyword, Option<(LibraryIdentifier, Symbol)>, CellIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LiblistClause {
|
|
||||||
pub nodes: (Keyword, Vec<LibraryIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UseClause {
|
|
||||||
Cell(Box<UseClauseCell>),
|
|
||||||
Named(Box<UseClauseNamed>),
|
|
||||||
CellNamed(Box<UseClauseCellNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UseClauseCell {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<(LibraryIdentifier, Symbol)>,
|
|
||||||
CellIdentifier,
|
|
||||||
Option<(Symbol, Config)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UseClauseNamed {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
List<Symbol, NamedParameterAssignment>,
|
|
||||||
Option<(Symbol, Config)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UseClauseCellNamed {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<(LibraryIdentifier, Symbol)>,
|
|
||||||
CellIdentifier,
|
|
||||||
List<Symbol, NamedParameterAssignment>,
|
|
||||||
Option<(Symbol, Config)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Config {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,181 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Static>,
|
|
||||||
Keyword,
|
|
||||||
ConstraintIdentifier,
|
|
||||||
ConstraintBlock,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Static {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintBlock {
|
|
||||||
pub nodes: (Brace<Vec<ConstraintBlockItem>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstraintBlockItem {
|
|
||||||
Solve(Box<ConstraintBlockItemSolve>),
|
|
||||||
ConstraintExpression(Box<ConstraintExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintBlockItemSolve {
|
|
||||||
pub nodes: (Keyword, SolveBeforeList, Keyword, SolveBeforeList, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SolveBeforeList {
|
|
||||||
pub nodes: (List<Symbol, ConstraintPrimary>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintPrimary {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ImplicitClassHandleOrClassScope>,
|
|
||||||
HierarchicalIdentifier,
|
|
||||||
Select,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstraintExpression {
|
|
||||||
Expression(Box<ConstraintExpressionExpression>),
|
|
||||||
UniquenessConstraint(Box<(UniquenessConstraint, Symbol)>),
|
|
||||||
Arrow(Box<ConstraintExpressionArrow>),
|
|
||||||
If(Box<ConstraintExpressionIf>),
|
|
||||||
Foreach(Box<ConstraintExpressionForeach>),
|
|
||||||
Disable(Box<ConstraintExpressionDisable>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintExpressionExpression {
|
|
||||||
pub nodes: (Option<Soft>, ExpressionOrDist, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Soft {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintExpressionArrow {
|
|
||||||
pub nodes: (Expression, Symbol, ConstraintSet),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintExpressionIf {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<Expression>,
|
|
||||||
ConstraintSet,
|
|
||||||
Option<(Keyword, ConstraintSet)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintExpressionForeach {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(PsOrHierarchicalArrayIdentifier, Bracket<LoopVariables>)>,
|
|
||||||
ConstraintSet,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintExpressionDisable {
|
|
||||||
pub nodes: (Keyword, Keyword, ConstraintPrimary, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UniquenessConstraint {
|
|
||||||
pub nodes: (Keyword, Brace<OpenRangeList>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstraintSet {
|
|
||||||
ConstraintExpression(Box<ConstraintExpression>),
|
|
||||||
Brace(Box<ConstraintSetBrace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintSetBrace {
|
|
||||||
pub nodes: (Brace<Vec<ConstraintExpression>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DistList {
|
|
||||||
pub nodes: (List<Symbol, DistItem>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DistItem {
|
|
||||||
pub nodes: (ValueRange, Option<DistWeight>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DistWeight {
|
|
||||||
Equal(Box<DistWeightEqual>),
|
|
||||||
Divide(Box<DistWeightDivide>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DistWeightEqual {
|
|
||||||
pub nodes: (Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DistWeightDivide {
|
|
||||||
pub nodes: (Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ConstraintPrototype {
|
|
||||||
pub nodes: (
|
|
||||||
Option<ConstraintPrototypeQualifier>,
|
|
||||||
Option<Static>,
|
|
||||||
Keyword,
|
|
||||||
ConstraintIdentifier,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ConstraintPrototypeQualifier {
|
|
||||||
Extern(Box<Keyword>),
|
|
||||||
Pure(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExternConstraintDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Static>,
|
|
||||||
Keyword,
|
|
||||||
ClassScope,
|
|
||||||
ConstraintIdentifier,
|
|
||||||
ConstraintBlock,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IdentifierList {
|
|
||||||
pub nodes: (List<Symbol, Identifier>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -410,7 +233,9 @@ pub(crate) fn constraint_prototype(s: Span) -> IResult<Span, ConstraintPrototype
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn constraint_prototype_qualifier(s: Span) -> IResult<Span, ConstraintPrototypeQualifier> {
|
pub(crate) fn constraint_prototype_qualifier(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ConstraintPrototypeQualifier> {
|
||||||
alt((
|
alt((
|
||||||
map(keyword("extern"), |x| {
|
map(keyword("extern"), |x| {
|
||||||
ConstraintPrototypeQualifier::Extern(Box::new(x))
|
ConstraintPrototypeQualifier::Extern(Box::new(x))
|
@ -1,60 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfaceOrGenerateItem {
|
|
||||||
Module(Box<InterfaceOrGenerateItemModule>),
|
|
||||||
Extern(Box<InterfaceOrGenerateItemExtern>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceOrGenerateItemModule {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModuleCommonItem),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceOrGenerateItemExtern {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ExternTfDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ExternTfDeclaration {
|
|
||||||
Method(Box<ExternTfDeclarationMethod>),
|
|
||||||
Task(Box<ExternTfDeclarationTask>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExternTfDeclarationMethod {
|
|
||||||
pub nodes: (Keyword, MethodPrototype, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ExternTfDeclarationTask {
|
|
||||||
pub nodes: (Keyword, Keyword, TaskPrototype, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfaceItem {
|
|
||||||
PortDeclaration(Box<(PortDeclaration, Symbol)>),
|
|
||||||
NonPortInterfaceItem(Box<NonPortInterfaceItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NonPortInterfaceItem {
|
|
||||||
GenerateRegion(Box<GenerateRegion>),
|
|
||||||
InterfaceOrGenerateItem(Box<InterfaceOrGenerateItem>),
|
|
||||||
ProgramDeclaration(Box<ProgramDeclaration>),
|
|
||||||
ModportDeclaration(Box<ModportDeclaration>),
|
|
||||||
InterfaceDeclaration(Box<InterfaceDeclaration>),
|
|
||||||
TimeunitsDeclaration(Box<TimeunitsDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,46 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LibraryText {
|
|
||||||
pub nodes: (Vec<LibraryDescription>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum LibraryDescription {
|
|
||||||
LibraryDeclaration(Box<LibraryDeclaration>),
|
|
||||||
IncludeStatement(Box<IncludeStatement>),
|
|
||||||
ConfigDeclaration(Box<ConfigDeclaration>),
|
|
||||||
Null(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LibraryDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
LibraryIdentifier,
|
|
||||||
List<Symbol, FilePathSpec>,
|
|
||||||
Option<(Keyword, List<Symbol, FilePathSpec>)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct IncludeStatement {
|
|
||||||
pub nodes: (Keyword, FilePathSpec, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FilePathSpec {
|
|
||||||
pub nodes: (StringLiteral,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -95,19 +53,3 @@ pub(crate) fn file_path_spec(s: Span) -> IResult<Span, FilePathSpec> {
|
|||||||
let (s, a) = string_literal(s)?;
|
let (s, a) = string_literal(s)?;
|
||||||
Ok((s, FilePathSpec { nodes: (a,) }))
|
Ok((s, FilePathSpec { nodes: (a,) }))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_library_text() {
|
|
||||||
parser_test!(
|
|
||||||
library_text,
|
|
||||||
"library rtlLib \"*.v\" -incdir \"aaa\";\ninclude \"bbb\";;",
|
|
||||||
Ok((_, _))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
22
sv-parser-parser/src/source_text/mod.rs
Normal file
22
sv-parser-parser/src/source_text/mod.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
pub mod checker_items;
|
||||||
|
pub mod class_items;
|
||||||
|
pub mod configuration_source_text;
|
||||||
|
pub mod constraints;
|
||||||
|
pub mod interface_items;
|
||||||
|
pub mod library_source_text;
|
||||||
|
pub mod module_items;
|
||||||
|
pub mod module_parameters_and_ports;
|
||||||
|
pub mod package_items;
|
||||||
|
pub mod program_items;
|
||||||
|
pub mod system_verilog_source_text;
|
||||||
|
pub(crate) use checker_items::*;
|
||||||
|
pub(crate) use class_items::*;
|
||||||
|
pub(crate) use configuration_source_text::*;
|
||||||
|
pub(crate) use constraints::*;
|
||||||
|
pub(crate) use interface_items::*;
|
||||||
|
pub(crate) use library_source_text::*;
|
||||||
|
pub(crate) use module_items::*;
|
||||||
|
pub(crate) use module_parameters_and_ports::*;
|
||||||
|
pub(crate) use package_items::*;
|
||||||
|
pub(crate) use program_items::*;
|
||||||
|
pub(crate) use system_verilog_source_text::*;
|
@ -1,195 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ElaborationSystemTask {
|
|
||||||
TaskFatal(Box<ElaborationSystemTaskFatal>),
|
|
||||||
TaskError(Box<ElaborationSystemTaskError>),
|
|
||||||
TaskWarning(Box<ElaborationSystemTaskWarning>),
|
|
||||||
TaskInfo(Box<ElaborationSystemTaskInfo>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ElaborationSystemTaskFatal {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Option<Paren<(FinishNumber, Option<(Symbol, ListOfArguments)>)>>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ElaborationSystemTaskError {
|
|
||||||
pub nodes: (Keyword, Option<Paren<Option<ListOfArguments>>>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ElaborationSystemTaskWarning {
|
|
||||||
pub nodes: (Keyword, Option<Paren<Option<ListOfArguments>>>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ElaborationSystemTaskInfo {
|
|
||||||
pub nodes: (Keyword, Option<Paren<Option<ListOfArguments>>>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum FinishNumber {
|
|
||||||
Zero(Box<Symbol>),
|
|
||||||
One(Box<Symbol>),
|
|
||||||
Two(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleCommonItem {
|
|
||||||
ModuleOrGenerateItemDeclaration(Box<ModuleOrGenerateItemDeclaration>),
|
|
||||||
InterfaceInstantiation(Box<InterfaceInstantiation>),
|
|
||||||
ProgramInstantiation(Box<ProgramInstantiation>),
|
|
||||||
AssertionItem(Box<AssertionItem>),
|
|
||||||
BindDirective(Box<BindDirective>),
|
|
||||||
ContinuousAssign(Box<ContinuousAssign>),
|
|
||||||
NetAlias(Box<NetAlias>),
|
|
||||||
InitialConstruct(Box<InitialConstruct>),
|
|
||||||
FinalConstruct(Box<FinalConstruct>),
|
|
||||||
AlwaysConstruct(Box<AlwaysConstruct>),
|
|
||||||
LoopGenerateConstruct(Box<LoopGenerateConstruct>),
|
|
||||||
ConditionalGenerateConstruct(Box<ConditionalGenerateConstruct>),
|
|
||||||
ElaborationSystemTask(Box<ElaborationSystemTask>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleItem {
|
|
||||||
PortDeclaration(Box<(PortDeclaration, Symbol)>),
|
|
||||||
NonPortModuleItem(Box<NonPortModuleItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleOrGenerateItem {
|
|
||||||
Parameter(Box<ModuleOrGenerateItemParameter>),
|
|
||||||
Gate(Box<ModuleOrGenerateItemGate>),
|
|
||||||
Udp(Box<ModuleOrGenerateItemUdp>),
|
|
||||||
Module(Box<ModuleOrGenerateItemModule>),
|
|
||||||
ModuleItem(Box<ModuleOrGenerateItemModuleItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemParameter {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ParameterOverride),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemGate {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, GateInstantiation),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemUdp {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, UdpInstantiation),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemModule {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModuleInstantiation),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemModuleItem {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModuleCommonItem),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleOrGenerateItemDeclaration {
|
|
||||||
PackageOrGenerateItemDeclaration(Box<PackageOrGenerateItemDeclaration>),
|
|
||||||
GenvarDeclaration(Box<GenvarDeclaration>),
|
|
||||||
ClockingDeclaration(Box<ClockingDeclaration>),
|
|
||||||
Clocking(Box<ModuleOrGenerateItemDeclarationClocking>),
|
|
||||||
Disable(Box<ModuleOrGenerateItemDeclarationDisable>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemDeclarationClocking {
|
|
||||||
pub nodes: (Keyword, Keyword, ClockingIdentifier, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleOrGenerateItemDeclarationDisable {
|
|
||||||
pub nodes: (Keyword, Keyword, Keyword, ExpressionOrDist, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NonPortModuleItem {
|
|
||||||
GenerateRegion(Box<GenerateRegion>),
|
|
||||||
ModuleOrGenerateItem(Box<ModuleOrGenerateItem>),
|
|
||||||
SpecifyBlock(Box<SpecifyBlock>),
|
|
||||||
Specparam(Box<NonPortModuleItemSpecparam>),
|
|
||||||
ProgramDeclaration(Box<ProgramDeclaration>),
|
|
||||||
ModuleDeclaration(Box<ModuleDeclaration>),
|
|
||||||
InterfaceDeclaration(Box<InterfaceDeclaration>),
|
|
||||||
TimeunitsDeclaration(Box<TimeunitsDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortModuleItemSpecparam {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, SpecparamDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterOverride {
|
|
||||||
pub nodes: (Keyword, ListOfDefparamAssignments, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BindDirective {
|
|
||||||
Scope(Box<BindDirectiveScope>),
|
|
||||||
Instance(Box<BindDirectiveInstance>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BindDirectiveScope {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
BindTargetScope,
|
|
||||||
Option<(Symbol, BindTargetInstanceList)>,
|
|
||||||
BindInstantiation,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BindDirectiveInstance {
|
|
||||||
pub nodes: (Keyword, BindTargetInstance, BindInstantiation, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BindTargetScope {
|
|
||||||
ModuleIdentifier(Box<ModuleIdentifier>),
|
|
||||||
InterfaceIdentifier(Box<InterfaceIdentifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BindTargetInstance {
|
|
||||||
pub nodes: (HierarchicalIdentifier, ConstantBitSelect),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct BindTargetInstanceList {
|
|
||||||
pub nodes: (List<Symbol, BindTargetInstance>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum BindInstantiation {
|
|
||||||
ProgramInstantiation(Box<ProgramInstantiation>),
|
|
||||||
ModuleInstantiation(Box<ModuleInstantiation>),
|
|
||||||
InterfaceInstantiation(Box<InterfaceInstantiation>),
|
|
||||||
CheckerInstantiation(Box<CheckerInstantiation>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,205 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ParameterPortList {
|
|
||||||
Assignment(Box<ParameterPortListAssignment>),
|
|
||||||
Declaration(Box<ParameterPortListDeclaration>),
|
|
||||||
Empty(Box<(Symbol, Symbol, Symbol)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterPortListAssignment {
|
|
||||||
pub nodes: (
|
|
||||||
Symbol,
|
|
||||||
Paren<(
|
|
||||||
ListOfParamAssignments,
|
|
||||||
Vec<(Symbol, ParameterPortDeclaration)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterPortListDeclaration {
|
|
||||||
pub nodes: (Symbol, Paren<List<Symbol, ParameterPortDeclaration>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ParameterPortDeclaration {
|
|
||||||
ParameterDeclaration(Box<ParameterDeclaration>),
|
|
||||||
LocalParameterDeclaration(Box<LocalParameterDeclaration>),
|
|
||||||
ParamList(Box<ParameterPortDeclarationParamList>),
|
|
||||||
TypeList(Box<ParameterPortDeclarationTypeList>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterPortDeclarationParamList {
|
|
||||||
pub nodes: (DataType, ListOfParamAssignments),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParameterPortDeclarationTypeList {
|
|
||||||
pub nodes: (Keyword, ListOfTypeAssignments),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPorts {
|
|
||||||
pub nodes: (Paren<List<Symbol, Port>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPortDeclarations {
|
|
||||||
pub nodes: (Paren<Option<List<Symbol, (Vec<AttributeInstance>, AnsiPortDeclaration)>>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PortDeclaration {
|
|
||||||
Inout(Box<PortDeclarationInout>),
|
|
||||||
Input(Box<PortDeclarationInput>),
|
|
||||||
Output(Box<PortDeclarationOutput>),
|
|
||||||
Ref(Box<PortDeclarationRef>),
|
|
||||||
Interface(Box<PortDeclarationInterface>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortDeclarationInout {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, InoutDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortDeclarationInput {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, InputDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortDeclarationOutput {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, OutputDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortDeclarationRef {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, RefDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortDeclarationInterface {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, InterfacePortDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Port {
|
|
||||||
NonNamed(Box<PortNonNamed>),
|
|
||||||
Named(Box<PortNamed>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortNonNamed {
|
|
||||||
pub nodes: (Option<PortExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortNamed {
|
|
||||||
pub nodes: (Symbol, PortIdentifier, Paren<Option<PortExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PortExpression {
|
|
||||||
PortReference(Box<PortReference>),
|
|
||||||
Brace(Box<PortExpressionBrace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortExpressionBrace {
|
|
||||||
pub nodes: (Brace<List<Symbol, PortReference>>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PortReference {
|
|
||||||
pub nodes: (PortIdentifier, ConstantSelect),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PortDirection {
|
|
||||||
Input(Box<Keyword>),
|
|
||||||
Output(Box<Keyword>),
|
|
||||||
Inout(Box<Keyword>),
|
|
||||||
Ref(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NetPortHeader {
|
|
||||||
pub nodes: (Option<PortDirection>, NetPortType),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct VariablePortHeader {
|
|
||||||
pub nodes: (Option<PortDirection>, VariablePortType),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfacePortHeader {
|
|
||||||
Identifier(Box<InterfacePortHeaderIdentifier>),
|
|
||||||
Interface(Box<InterfacePortHeaderInterface>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfacePortHeaderIdentifier {
|
|
||||||
pub nodes: (InterfaceIdentifier, Option<(Symbol, ModportIdentifier)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfacePortHeaderInterface {
|
|
||||||
pub nodes: (Keyword, Option<(Symbol, ModportIdentifier)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NetPortHeaderOrInterfacePortHeader {
|
|
||||||
NetPortHeader(Box<NetPortHeader>),
|
|
||||||
InterfacePortHeader(Box<InterfacePortHeader>),
|
|
||||||
}
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AnsiPortDeclaration {
|
|
||||||
Net(Box<AnsiPortDeclarationNet>),
|
|
||||||
Variable(Box<AnsiPortDeclarationVariable>),
|
|
||||||
Paren(Box<AnsiPortDeclarationParen>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AnsiPortDeclarationNet {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NetPortHeaderOrInterfacePortHeader>,
|
|
||||||
PortIdentifier,
|
|
||||||
Vec<UnpackedDimension>,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AnsiPortDeclarationVariable {
|
|
||||||
pub nodes: (
|
|
||||||
Option<VariablePortHeader>,
|
|
||||||
PortIdentifier,
|
|
||||||
Vec<VariableDimension>,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AnsiPortDeclarationParen {
|
|
||||||
pub nodes: (
|
|
||||||
Option<PortDirection>,
|
|
||||||
Symbol,
|
|
||||||
PortIdentifier,
|
|
||||||
Paren<Option<Expression>>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -258,7 +57,9 @@ pub(crate) fn parameter_port_declaration(s: Span) -> IResult<Span, ParameterPort
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn parameter_port_declaration_param_list(s: Span) -> IResult<Span, ParameterPortDeclaration> {
|
pub(crate) fn parameter_port_declaration_param_list(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ParameterPortDeclaration> {
|
||||||
let (s, a) = data_type(s)?;
|
let (s, a) = data_type(s)?;
|
||||||
let (s, b) = list_of_param_assignments(s)?;
|
let (s, b) = list_of_param_assignments(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
@ -270,7 +71,9 @@ pub(crate) fn parameter_port_declaration_param_list(s: Span) -> IResult<Span, Pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn parameter_port_declaration_type_list(s: Span) -> IResult<Span, ParameterPortDeclaration> {
|
pub(crate) fn parameter_port_declaration_type_list(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ParameterPortDeclaration> {
|
||||||
let (s, a) = keyword("type")(s)?;
|
let (s, a) = keyword("type")(s)?;
|
||||||
let (s, b) = list_of_type_assignments(s)?;
|
let (s, b) = list_of_type_assignments(s)?;
|
||||||
Ok((
|
Ok((
|
@ -1,53 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PackageItem {
|
|
||||||
PackageOrGenerateItemDeclaration(Box<PackageOrGenerateItemDeclaration>),
|
|
||||||
AnonymousProgram(Box<AnonymousProgram>),
|
|
||||||
PackageExportDeclaration(Box<PackageExportDeclaration>),
|
|
||||||
TimeunitsDeclaration(Box<TimeunitsDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PackageOrGenerateItemDeclaration {
|
|
||||||
NetDeclaration(Box<NetDeclaration>),
|
|
||||||
DataDeclaration(Box<DataDeclaration>),
|
|
||||||
TaskDeclaration(Box<TaskDeclaration>),
|
|
||||||
FunctionDeclaration(Box<FunctionDeclaration>),
|
|
||||||
CheckerDeclaration(Box<CheckerDeclaration>),
|
|
||||||
DpiImportExport(Box<DpiImportExport>),
|
|
||||||
ExternConstraintDeclaration(Box<ExternConstraintDeclaration>),
|
|
||||||
ClassDeclaration(Box<ClassDeclaration>),
|
|
||||||
ClassConstructorDeclaration(Box<ClassConstructorDeclaration>),
|
|
||||||
LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>),
|
|
||||||
ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>),
|
|
||||||
CovergroupDeclaration(Box<CovergroupDeclaration>),
|
|
||||||
AssertionItemDeclaration(Box<AssertionItemDeclaration>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct AnonymousProgram {
|
|
||||||
pub nodes: (Keyword, Symbol, Vec<AnonymousProgramItem>, Keyword),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum AnonymousProgramItem {
|
|
||||||
TaskDeclaration(Box<TaskDeclaration>),
|
|
||||||
FunctionDeclaration(Box<FunctionDeclaration>),
|
|
||||||
ClassDeclaration(Box<ClassDeclaration>),
|
|
||||||
CovergroupDeclaration(Box<CovergroupDeclaration>),
|
|
||||||
ClassConstructorDeclaration(Box<ClassConstructorDeclaration>),
|
|
||||||
Empty(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,62 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProgramItem {
|
|
||||||
PortDeclaration(Box<(PortDeclaration, Symbol)>),
|
|
||||||
NonPortProgramItem(Box<NonPortProgramItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NonPortProgramItem {
|
|
||||||
Assign(Box<NonPortProgramItemAssign>),
|
|
||||||
Module(Box<NonPortProgramItemModule>),
|
|
||||||
Initial(Box<NonPortProgramItemInitial>),
|
|
||||||
Final(Box<NonPortProgramItemFinal>),
|
|
||||||
Assertion(Box<NonPortProgramItemAssertion>),
|
|
||||||
TimeunitsDeclaration(Box<TimeunitsDeclaration>),
|
|
||||||
ProgramGenerateItem(Box<ProgramGenerateItem>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortProgramItemAssign {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ContinuousAssign),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortProgramItemModule {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ModuleOrGenerateItemDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortProgramItemInitial {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, InitialConstruct),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortProgramItemFinal {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, FinalConstruct),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NonPortProgramItemAssertion {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, ConcurrentAssertionItem),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProgramGenerateItem {
|
|
||||||
LoopGenerateConstruct(Box<LoopGenerateConstruct>),
|
|
||||||
ConditionalGenerateConstruct(Box<ConditionalGenerateConstruct>),
|
|
||||||
GenerateRegion(Box<GenerateRegion>),
|
|
||||||
ElaborationSystemTask(Box<ElaborationSystemTask>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,417 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SourceText {
|
|
||||||
pub nodes: (Option<TimeunitsDeclaration>, Vec<Description>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum Description {
|
|
||||||
ModuleDeclaration(Box<ModuleDeclaration>),
|
|
||||||
UdpDeclaration(Box<UdpDeclaration>),
|
|
||||||
InterfaceDeclaration(Box<InterfaceDeclaration>),
|
|
||||||
InterfaceClassDeclaration(Box<InterfaceClassDeclaration>),
|
|
||||||
ProgramDeclaration(Box<ProgramDeclaration>),
|
|
||||||
PackageDeclaration(Box<PackageDeclaration>),
|
|
||||||
PackageItem(Box<DescriptionPackageItem>),
|
|
||||||
BindDirective(Box<DescriptionBindDirective>),
|
|
||||||
ConfigDeclaration(Box<ConfigDeclaration>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DescriptionPackageItem {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, PackageItem),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DescriptionBindDirective {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, BindDirective),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleNonansiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModuleKeyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ModuleIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
ListOfPorts,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleAnsiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModuleKeyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ModuleIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
Option<ListOfPortDeclarations>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleDeclaration {
|
|
||||||
Nonansi(Box<ModuleDeclarationNonansi>),
|
|
||||||
Ansi(Box<ModuleDeclarationAnsi>),
|
|
||||||
Wildcard(Box<ModuleDeclarationWildcard>),
|
|
||||||
ExternNonansi(Box<ModuleDeclarationExternNonansi>),
|
|
||||||
ExternAnsi(Box<ModuleDeclarationExternAnsi>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleDeclarationNonansi {
|
|
||||||
pub nodes: (
|
|
||||||
ModuleNonansiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<ModuleItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ModuleIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleDeclarationAnsi {
|
|
||||||
pub nodes: (
|
|
||||||
ModuleAnsiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<NonPortModuleItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ModuleIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleDeclarationWildcard {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
ModuleKeyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ModuleIdentifier,
|
|
||||||
Paren<Symbol>,
|
|
||||||
Symbol,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<ModuleItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ModuleIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleDeclarationExternNonansi {
|
|
||||||
pub nodes: (Keyword, ModuleNonansiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ModuleDeclarationExternAnsi {
|
|
||||||
pub nodes: (Keyword, ModuleAnsiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ModuleKeyword {
|
|
||||||
Module(Box<Keyword>),
|
|
||||||
Macromodule(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfaceDeclaration {
|
|
||||||
Nonansi(Box<InterfaceDeclarationNonansi>),
|
|
||||||
Ansi(Box<InterfaceDeclarationAnsi>),
|
|
||||||
Wildcard(Box<InterfaceDeclarationWildcard>),
|
|
||||||
ExternNonansi(Box<InterfaceDeclarationExternNonansi>),
|
|
||||||
ExternAnsi(Box<InterfaceDeclarationExternAnsi>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceDeclarationNonansi {
|
|
||||||
pub nodes: (
|
|
||||||
InterfaceNonansiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<InterfaceItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, InterfaceIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceDeclarationAnsi {
|
|
||||||
pub nodes: (
|
|
||||||
InterfaceAnsiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<NonPortInterfaceItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, InterfaceIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceDeclarationWildcard {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Paren<Symbol>,
|
|
||||||
Symbol,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<InterfaceItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, InterfaceIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceDeclarationExternNonansi {
|
|
||||||
pub nodes: (Keyword, InterfaceNonansiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceDeclarationExternAnsi {
|
|
||||||
pub nodes: (Keyword, InterfaceAnsiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceNonansiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
ListOfPorts,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceAnsiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
InterfaceIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
Option<ListOfPortDeclarations>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ProgramDeclaration {
|
|
||||||
Nonansi(Box<ProgramDeclarationNonansi>),
|
|
||||||
Ansi(Box<ProgramDeclarationAnsi>),
|
|
||||||
Wildcard(Box<ProgramDeclarationWildcard>),
|
|
||||||
ExternNonansi(Box<ProgramDeclarationExternNonansi>),
|
|
||||||
ExternAnsi(Box<ProgramDeclarationExternAnsi>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramDeclarationNonansi {
|
|
||||||
pub nodes: (
|
|
||||||
ProgramNonansiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<ProgramItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ProgramIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramDeclarationAnsi {
|
|
||||||
pub nodes: (
|
|
||||||
ProgramAnsiHeader,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<NonPortProgramItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ProgramIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramDeclarationWildcard {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
ProgramIdentifier,
|
|
||||||
Paren<Symbol>,
|
|
||||||
Symbol,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<ProgramItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ProgramIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramDeclarationExternNonansi {
|
|
||||||
pub nodes: (Keyword, ProgramNonansiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramDeclarationExternAnsi {
|
|
||||||
pub nodes: (Keyword, ProgramAnsiHeader),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramNonansiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ProgramIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
ListOfPorts,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ProgramAnsiHeader {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ProgramIdentifier,
|
|
||||||
Vec<PackageImportDeclaration>,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
Option<ListOfPortDeclarations>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CheckerDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
CheckerIdentifier,
|
|
||||||
Option<Paren<Option<CheckerPortList>>>,
|
|
||||||
Symbol,
|
|
||||||
Vec<(Vec<AttributeInstance>, CheckerOrGenerateItem)>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, CheckerIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ClassDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Option<Virtual>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
ClassIdentifier,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
Option<(Keyword, ClassType, Option<Paren<ListOfArguments>>)>,
|
|
||||||
Option<(Keyword, List<Symbol, InterfaceClassType>)>,
|
|
||||||
Symbol,
|
|
||||||
Vec<ClassItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ClassIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Virtual {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceClassType {
|
|
||||||
pub nodes: (PsClassIdentifier, Option<ParameterValueAssignment>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceClassDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
ClassIdentifier,
|
|
||||||
Option<ParameterPortList>,
|
|
||||||
Option<(Keyword, List<Symbol, InterfaceClassType>)>,
|
|
||||||
Symbol,
|
|
||||||
Vec<InterfaceClassItem>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, ClassIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InterfaceClassItem {
|
|
||||||
TypeDeclaration(Box<TypeDeclaration>),
|
|
||||||
Method(Box<InterfaceClassItemMethod>),
|
|
||||||
LocalParameterDeclaration(Box<(LocalParameterDeclaration, Symbol)>),
|
|
||||||
ParameterDeclaration(Box<(ParameterDeclaration, Symbol)>),
|
|
||||||
Null(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceClassItemMethod {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, InterfaceClassMethod),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InterfaceClassMethod {
|
|
||||||
pub nodes: (Keyword, Keyword, MethodPrototype, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PackageDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Option<Lifetime>,
|
|
||||||
PackageIdentifier,
|
|
||||||
Symbol,
|
|
||||||
Option<TimeunitsDeclaration>,
|
|
||||||
Vec<(Vec<AttributeInstance>, PackageItem)>,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, PackageIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TimeunitsDeclaration {
|
|
||||||
Timeunit(Box<TimeunitsDeclarationTimeunit>),
|
|
||||||
Timeprecision(Box<TimeunitsDeclarationTimeprecision>),
|
|
||||||
TimeunitTimeprecision(Box<TimeunitsDeclarationTimeunitTimeprecision>),
|
|
||||||
TimeprecisionTimeunit(Box<TimeunitsDeclarationTimeprecisionTimeunit>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeunitsDeclarationTimeunit {
|
|
||||||
pub nodes: (Keyword, TimeLiteral, Option<(Symbol, TimeLiteral)>, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeunitsDeclarationTimeprecision {
|
|
||||||
pub nodes: (Keyword, TimeLiteral, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeunitsDeclarationTimeunitTimeprecision {
|
|
||||||
pub nodes: (Keyword, TimeLiteral, Symbol, Keyword, TimeLiteral, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeunitsDeclarationTimeprecisionTimeunit {
|
|
||||||
pub nodes: (Keyword, TimeLiteral, Symbol, Keyword, TimeLiteral, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -1049,27 +636,3 @@ pub(crate) fn timeunits_declaration_timeprecision_timeunit(
|
|||||||
)),
|
)),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_timeunits_declaration() {
|
|
||||||
parser_test!(timeunits_declaration, "timeunit 1.0ps;", Ok((_, _)));
|
|
||||||
parser_test!(timeunits_declaration, "timeunit 1.0ps / 20ms;", Ok((_, _)));
|
|
||||||
parser_test!(timeunits_declaration, "timeprecision 10.0fs;", Ok((_, _)));
|
|
||||||
parser_test!(
|
|
||||||
timeunits_declaration,
|
|
||||||
"timeunit 10.0fs; timeprecision 20s;",
|
|
||||||
Ok((_, _))
|
|
||||||
);
|
|
||||||
parser_test!(
|
|
||||||
timeunits_declaration,
|
|
||||||
"timeprecision 10.0fs; timeunit 20s \n;",
|
|
||||||
Ok((_, _))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
14
sv-parser-parser/src/specify_section/mod.rs
Normal file
14
sv-parser-parser/src/specify_section/mod.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
pub mod specify_block_declaration;
|
||||||
|
pub mod specify_block_terminals;
|
||||||
|
pub mod specify_path_declarations;
|
||||||
|
pub mod specify_path_delays;
|
||||||
|
pub mod system_timing_check_command_arguments;
|
||||||
|
pub mod system_timing_check_commands;
|
||||||
|
pub mod system_timing_check_event_definitions;
|
||||||
|
pub(crate) use specify_block_declaration::*;
|
||||||
|
pub(crate) use specify_block_terminals::*;
|
||||||
|
pub(crate) use specify_path_declarations::*;
|
||||||
|
pub(crate) use specify_path_delays::*;
|
||||||
|
pub(crate) use system_timing_check_command_arguments::*;
|
||||||
|
pub(crate) use system_timing_check_commands::*;
|
||||||
|
pub(crate) use system_timing_check_event_definitions::*;
|
@ -1,35 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SpecifyBlock {
|
|
||||||
pub nodes: (Keyword, Vec<SpecifyItem>, Keyword),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SpecifyItem {
|
|
||||||
SpecparamDeclaration(Box<SpecparamDeclaration>),
|
|
||||||
PulsestyleDeclaration(Box<PulsestyleDeclaration>),
|
|
||||||
ShowcancelledDeclaration(Box<ShowcancelledDeclaration>),
|
|
||||||
PathDeclaration(Box<PathDeclaration>),
|
|
||||||
SystemTimingCheck(Box<SystemTimingCheck>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PulsestyleDeclaration {
|
|
||||||
pub nodes: (Keyword, ListOfPathOutputs, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ShowcancelledDeclaration {
|
|
||||||
pub nodes: (Keyword, ListOfPathOutputs, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,49 +1,11 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SpecifyInputTerminalDescriptor {
|
|
||||||
pub nodes: (InputIdentifier, Option<Bracket<ConstantRangeExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SpecifyOutputTerminalDescriptor {
|
|
||||||
pub nodes: (OutputIdentifier, Option<Bracket<ConstantRangeExpression>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum InputIdentifier {
|
|
||||||
InputPortIdentifier(Box<InputPortIdentifier>),
|
|
||||||
InoutPortIdentifier(Box<InoutPortIdentifier>),
|
|
||||||
Interface(Box<InputIdentifierInterface>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InputIdentifierInterface {
|
|
||||||
pub nodes: (InterfaceIdentifier, Symbol, PortIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum OutputIdentifier {
|
|
||||||
OutputPortIdentifier(Box<OutputPortIdentifier>),
|
|
||||||
InoutPortIdentifier(Box<InoutPortIdentifier>),
|
|
||||||
Interface(Box<OutputIdentifierInterface>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputIdentifierInterface {
|
|
||||||
pub nodes: (InterfaceIdentifier, Symbol, PortIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn specify_input_terminal_descriptor(s: Span) -> IResult<Span, SpecifyInputTerminalDescriptor> {
|
pub(crate) fn specify_input_terminal_descriptor(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, SpecifyInputTerminalDescriptor> {
|
||||||
let (s, a) = input_identifier(s)?;
|
let (s, a) = input_identifier(s)?;
|
||||||
let (s, b) = opt(bracket(constant_range_expression))(s)?;
|
let (s, b) = opt(bracket(constant_range_expression))(s)?;
|
||||||
Ok((s, SpecifyInputTerminalDescriptor { nodes: (a, b) }))
|
Ok((s, SpecifyInputTerminalDescriptor { nodes: (a, b) }))
|
@ -1,68 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PathDeclaration {
|
|
||||||
SimplePathDeclaration(Box<(SimplePathDeclaration, Symbol)>),
|
|
||||||
EdgeSensitivePathDeclaration(Box<(EdgeSensitivePathDeclaration, Symbol)>),
|
|
||||||
StateDependentPathDeclaration(Box<(StateDependentPathDeclaration, Symbol)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SimplePathDeclaration {
|
|
||||||
Parallel(Box<SimplePathDeclarationParallel>),
|
|
||||||
Full(Box<SimplePathDeclarationFull>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimplePathDeclarationParallel {
|
|
||||||
pub nodes: (ParallelPathDescription, Symbol, PathDelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SimplePathDeclarationFull {
|
|
||||||
pub nodes: (FullPathDescription, Symbol, PathDelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParallelPathDescription {
|
|
||||||
pub nodes: (
|
|
||||||
Paren<(
|
|
||||||
SpecifyInputTerminalDescriptor,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
SpecifyOutputTerminalDescriptor,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FullPathDescription {
|
|
||||||
pub nodes: (
|
|
||||||
Paren<(
|
|
||||||
ListOfPathInputs,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
ListOfPathOutputs,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPathInputs {
|
|
||||||
pub nodes: (List<Symbol, SpecifyInputTerminalDescriptor>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPathOutputs {
|
|
||||||
pub nodes: (List<Symbol, SpecifyOutputTerminalDescriptor>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,131 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum PathDelayValue {
|
|
||||||
ListOfPathDelayExpressions(Box<ListOfPathDelayExpressions>),
|
|
||||||
Paren(Box<PathDelayValueParen>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PathDelayValueParen {
|
|
||||||
pub nodes: (Paren<ListOfPathDelayExpressions>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ListOfPathDelayExpressions {
|
|
||||||
pub nodes: (List<Symbol, TPathDelayExpression>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TPathDelayExpression {
|
|
||||||
pub nodes: (PathDelayExpression,),
|
|
||||||
}
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PathDelayExpression {
|
|
||||||
pub nodes: (ConstantMintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EdgeSensitivePathDeclaration {
|
|
||||||
Parallel(Box<EdgeSensitivePathDeclarationParallel>),
|
|
||||||
Full(Box<EdgeSensitivePathDeclarationFull>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeSensitivePathDeclarationParallel {
|
|
||||||
pub nodes: (ParallelEdgeSensitivePathDescription, Symbol, PathDelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeSensitivePathDeclarationFull {
|
|
||||||
pub nodes: (FullEdgeSensitivePathDescription, Symbol, PathDelayValue),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ParallelEdgeSensitivePathDescription {
|
|
||||||
pub nodes: (
|
|
||||||
Paren<(
|
|
||||||
Option<EdgeIdentifier>,
|
|
||||||
SpecifyInputTerminalDescriptor,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
Paren<(
|
|
||||||
SpecifyOutputTerminalDescriptor,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
DataSourceExpression,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FullEdgeSensitivePathDescription {
|
|
||||||
pub nodes: (
|
|
||||||
Paren<(
|
|
||||||
Option<EdgeIdentifier>,
|
|
||||||
ListOfPathInputs,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
Paren<(
|
|
||||||
ListOfPathOutputs,
|
|
||||||
Option<PolarityOperator>,
|
|
||||||
Symbol,
|
|
||||||
DataSourceExpression,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataSourceExpression {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EdgeIdentifier {
|
|
||||||
Posedge(Box<Keyword>),
|
|
||||||
Negedge(Box<Keyword>),
|
|
||||||
Edge(Box<Keyword>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum StateDependentPathDeclaration {
|
|
||||||
IfSimple(Box<StateDependentPathDeclarationIfSimple>),
|
|
||||||
IfEdgeSensitive(Box<StateDependentPathDeclarationIfEdgeSensitive>),
|
|
||||||
IfNone(Box<StateDependentPathDeclarationIfNone>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StateDependentPathDeclarationIfSimple {
|
|
||||||
pub nodes: (Keyword, Paren<ModulePathExpression>, SimplePathDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StateDependentPathDeclarationIfEdgeSensitive {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<ModulePathExpression>,
|
|
||||||
EdgeSensitivePathDeclaration,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StateDependentPathDeclarationIfNone {
|
|
||||||
pub nodes: (Keyword, SimplePathDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PolarityOperator {
|
|
||||||
pub nodes: (Symbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -167,7 +40,9 @@ pub(crate) fn path_delay_expression(s: Span) -> IResult<Span, PathDelayExpressio
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn edge_sensitive_path_declaration(s: Span) -> IResult<Span, EdgeSensitivePathDeclaration> {
|
pub(crate) fn edge_sensitive_path_declaration(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, EdgeSensitivePathDeclaration> {
|
||||||
alt((
|
alt((
|
||||||
edge_sensitive_path_declaration_parallel,
|
edge_sensitive_path_declaration_parallel,
|
||||||
edge_sensitive_path_declaration_full,
|
edge_sensitive_path_declaration_full,
|
||||||
@ -258,7 +133,9 @@ pub(crate) fn edge_identifier(s: Span) -> IResult<Span, EdgeIdentifier> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn state_dependent_path_declaration(s: Span) -> IResult<Span, StateDependentPathDeclaration> {
|
pub(crate) fn state_dependent_path_declaration(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, StateDependentPathDeclaration> {
|
||||||
alt((
|
alt((
|
||||||
state_dependent_path_declaration_if_simple,
|
state_dependent_path_declaration_if_simple,
|
||||||
state_dependent_path_declaration_if_edge_sensitive,
|
state_dependent_path_declaration_if_edge_sensitive,
|
@ -1,92 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimecheckCondition {
|
|
||||||
pub nodes: (MintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ControlledReferenceEvent {
|
|
||||||
pub nodes: (ControlledTimingCheckEvent,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DataEvent {
|
|
||||||
pub nodes: (TimingCheckEvent,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DelayedData {
|
|
||||||
TerminalIdentifier(Box<TerminalIdentifier>),
|
|
||||||
WithMintypmax(Box<DelayedDataWithMintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DelayedDataWithMintypmax {
|
|
||||||
pub nodes: (TerminalIdentifier, Bracket<ConstantMintypmaxExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum DelayedReference {
|
|
||||||
TerminalIdentifier(Box<TerminalIdentifier>),
|
|
||||||
WithMintypmax(Box<DelayedReferenceWithMintypmax>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct DelayedReferenceWithMintypmax {
|
|
||||||
pub nodes: (TerminalIdentifier, Bracket<ConstantMintypmaxExpression>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EndEdgeOffset {
|
|
||||||
pub nodes: (MintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EventBasedFlag {
|
|
||||||
pub nodes: (ConstantExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Notifier {
|
|
||||||
pub nodes: (VariableIdentifier,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ReferenceEvent {
|
|
||||||
pub nodes: (TimingCheckEvent,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RemainActiveFlag {
|
|
||||||
pub nodes: (ConstantMintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimestampCondition {
|
|
||||||
pub nodes: (MintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct StartEdgeOffset {
|
|
||||||
pub nodes: (MintypmaxExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Threshold {
|
|
||||||
pub nodes: (ConstantExpression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimingCheckLimit {
|
|
||||||
pub nodes: (Expression,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,273 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SystemTimingCheck {
|
|
||||||
SetupTimingCheck(Box<SetupTimingCheck>),
|
|
||||||
HoldTimingCheck(Box<HoldTimingCheck>),
|
|
||||||
SetupholdTimingCheck(Box<SetupholdTimingCheck>),
|
|
||||||
RecoveryTimingCheck(Box<RecoveryTimingCheck>),
|
|
||||||
RemovalTimingCheck(Box<RemovalTimingCheck>),
|
|
||||||
RecremTimingCheck(Box<RecremTimingCheck>),
|
|
||||||
SkewTimingCheck(Box<SkewTimingCheck>),
|
|
||||||
TimeskewTimingCheck(Box<TimeskewTimingCheck>),
|
|
||||||
FullskewTimingCheck(Box<FullskewTimingCheck>),
|
|
||||||
PeriodTimingCheck(Box<PeriodTimingCheck>),
|
|
||||||
WidthTimingCheck(Box<WidthTimingCheck>),
|
|
||||||
NochargeTimingCheck(Box<NochargeTimingCheck>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SetupTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct HoldTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SetupholdTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<Notifier>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<TimestampCondition>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<TimecheckCondition>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<DelayedReference>,
|
|
||||||
Option<(Symbol, Option<DelayedData>)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RecoveryTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RemovalTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct RecremTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<Notifier>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<TimestampCondition>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<TimecheckCondition>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<DelayedReference>,
|
|
||||||
Option<(Symbol, Option<DelayedData>)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SkewTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimeskewTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<Notifier>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<EventBasedFlag>,
|
|
||||||
Option<(Symbol, Option<RemainActiveFlag>)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct FullskewTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<Notifier>,
|
|
||||||
Option<(
|
|
||||||
Symbol,
|
|
||||||
Option<EventBasedFlag>,
|
|
||||||
Option<(Symbol, Option<RemainActiveFlag>)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct PeriodTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ControlledReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct WidthTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ControlledReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
TimingCheckLimit,
|
|
||||||
Symbol,
|
|
||||||
Threshold,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct NochargeTimingCheck {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
Paren<(
|
|
||||||
ReferenceEvent,
|
|
||||||
Symbol,
|
|
||||||
DataEvent,
|
|
||||||
Symbol,
|
|
||||||
StartEdgeOffset,
|
|
||||||
Symbol,
|
|
||||||
EndEdgeOffset,
|
|
||||||
Option<(Symbol, Option<Notifier>)>,
|
|
||||||
)>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,86 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimingCheckEvent {
|
|
||||||
pub nodes: (
|
|
||||||
Option<TimingCheckEventControl>,
|
|
||||||
SpecifyTerminalDescriptor,
|
|
||||||
Option<(Symbol, TimingCheckCondition)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ControlledTimingCheckEvent {
|
|
||||||
pub nodes: (
|
|
||||||
TimingCheckEventControl,
|
|
||||||
SpecifyTerminalDescriptor,
|
|
||||||
Option<(Symbol, TimingCheckCondition)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TimingCheckEventControl {
|
|
||||||
Posedge(Box<Keyword>),
|
|
||||||
Negedge(Box<Keyword>),
|
|
||||||
Edge(Box<Keyword>),
|
|
||||||
EdgeControlSpecifier(Box<EdgeControlSpecifier>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SpecifyTerminalDescriptor {
|
|
||||||
SpecifyInputTerminalDescriptor(Box<SpecifyInputTerminalDescriptor>),
|
|
||||||
SpecifyOutputTerminalDescriptor(Box<SpecifyOutputTerminalDescriptor>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeControlSpecifier {
|
|
||||||
pub nodes: (Keyword, Bracket<List<Symbol, EdgeDescriptor>>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeDescriptor {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum TimingCheckCondition {
|
|
||||||
ScalarTimingCheckCondition(Box<ScalarTimingCheckCondition>),
|
|
||||||
Paren(Box<TimingCheckConditionParen>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct TimingCheckConditionParen {
|
|
||||||
pub nodes: (Paren<ScalarTimingCheckCondition>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum ScalarTimingCheckCondition {
|
|
||||||
Expression(Box<Expression>),
|
|
||||||
Unary(Box<ScalarTimingCheckConditionUnary>),
|
|
||||||
Binary(Box<ScalarTimingCheckConditionBinary>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ScalarTimingCheckConditionUnary {
|
|
||||||
pub nodes: (Symbol, Expression),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ScalarTimingCheckConditionBinary {
|
|
||||||
pub nodes: (Expression, Symbol, ScalarConstant),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct ScalarConstant {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -192,7 +110,9 @@ pub(crate) fn scalar_timing_check_condition(s: Span) -> IResult<Span, ScalarTimi
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn scalar_timing_check_condition_unary(s: Span) -> IResult<Span, ScalarTimingCheckCondition> {
|
pub(crate) fn scalar_timing_check_condition_unary(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ScalarTimingCheckCondition> {
|
||||||
let (s, a) = symbol("~")(s)?;
|
let (s, a) = symbol("~")(s)?;
|
||||||
let (s, b) = expression(s)?;
|
let (s, b) = expression(s)?;
|
||||||
Ok((
|
Ok((
|
||||||
@ -204,7 +124,9 @@ pub(crate) fn scalar_timing_check_condition_unary(s: Span) -> IResult<Span, Scal
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
pub(crate) fn scalar_timing_check_condition_binary(s: Span) -> IResult<Span, ScalarTimingCheckCondition> {
|
pub(crate) fn scalar_timing_check_condition_binary(
|
||||||
|
s: Span,
|
||||||
|
) -> IResult<Span, ScalarTimingCheckCondition> {
|
||||||
let (s, a) = expression(s)?;
|
let (s, a) = expression(s)?;
|
||||||
let (s, b) = alt((symbol("==="), symbol("=="), symbol("!=="), symbol("!=")))(s)?;
|
let (s, b) = alt((symbol("==="), symbol("=="), symbol("!=="), symbol("!=")))(s)?;
|
||||||
let (s, c) = scalar_constant(s)?;
|
let (s, c) = scalar_constant(s)?;
|
791
sv-parser-parser/src/tests.rs
Normal file
791
sv-parser-parser/src/tests.rs
Normal file
@ -0,0 +1,791 @@
|
|||||||
|
#![cfg(test)]
|
||||||
|
|
||||||
|
use crate::*;
|
||||||
|
|
||||||
|
macro_rules! test {
|
||||||
|
( $x:expr, $y:expr, $z:pat ) => {
|
||||||
|
let ret = all_consuming($x)(Span::new_extra($y, Extra::default()));
|
||||||
|
if let $z = ret {
|
||||||
|
} else {
|
||||||
|
assert!(false, "{:?}", ret)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pulldown_strength() {
|
||||||
|
test!(pulldown_strength, "(supply0, strong1)", Ok((_, _)));
|
||||||
|
test!(pulldown_strength, "(pull1, weak0)", Ok((_, _)));
|
||||||
|
test!(pulldown_strength, "(pull0)", Ok((_, _)));
|
||||||
|
test!(pulldown_strength, "(pull0)", Ok((_, _)));
|
||||||
|
test!(pulldown_strength, "(pull0)", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pullup_strength() {
|
||||||
|
test!(pullup_strength, "(supply0, strong1)", Ok((_, _)));
|
||||||
|
test!(pullup_strength, "(pull1, weak0)", Ok((_, _)));
|
||||||
|
test!(pullup_strength, "(supply1)", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cmos_switchtype() {
|
||||||
|
test!(cmos_switchtype, "cmos ", Ok((_, _)));
|
||||||
|
test!(cmos_switchtype, "rcmos ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_enable_gatetype() {
|
||||||
|
test!(enable_gatetype, "bufif0 ", Ok((_, _)));
|
||||||
|
test!(enable_gatetype, "bufif1 ", Ok((_, _)));
|
||||||
|
test!(enable_gatetype, "notif0 ", Ok((_, _)));
|
||||||
|
test!(enable_gatetype, "notif1 ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_mos_switchtype() {
|
||||||
|
test!(mos_switchtype, "nmos ", Ok((_, _)));
|
||||||
|
test!(mos_switchtype, "pmos ", Ok((_, _)));
|
||||||
|
test!(mos_switchtype, "rnmos ", Ok((_, _)));
|
||||||
|
test!(mos_switchtype, "rpmos ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_n_input_gatetype() {
|
||||||
|
test!(n_input_gatetype, "and ", Ok((_, _)));
|
||||||
|
test!(n_input_gatetype, "nand ", Ok((_, _)));
|
||||||
|
test!(n_input_gatetype, "or ", Ok((_, _)));
|
||||||
|
test!(n_input_gatetype, "nor ", Ok((_, _)));
|
||||||
|
test!(n_input_gatetype, "xor ", Ok((_, _)));
|
||||||
|
test!(n_input_gatetype, "xnor ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_n_output_gatetype() {
|
||||||
|
test!(n_output_gatetype, "buf ", Ok((_, _)));
|
||||||
|
test!(n_output_gatetype, "not ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pass_en_switchtype() {
|
||||||
|
test!(pass_en_switchtype, "tranif0 ", Ok((_, _)));
|
||||||
|
test!(pass_en_switchtype, "tranif1 ", Ok((_, _)));
|
||||||
|
test!(pass_en_switchtype, "rtranif0 ", Ok((_, _)));
|
||||||
|
test!(pass_en_switchtype, "rtranif1 ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_pass_switchtype() {
|
||||||
|
test!(pass_switchtype, "tran ", Ok((_, _)));
|
||||||
|
test!(pass_switchtype, "rtran ", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_library_text() {
|
||||||
|
test!(
|
||||||
|
library_text,
|
||||||
|
"library rtlLib \"*.v\" -incdir \"aaa\";\ninclude \"bbb\";;",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_timeunits_declaration() {
|
||||||
|
test!(timeunits_declaration, "timeunit 1.0ps;", Ok((_, _)));
|
||||||
|
test!(timeunits_declaration, "timeunit 1.0ps / 20ms;", Ok((_, _)));
|
||||||
|
test!(timeunits_declaration, "timeprecision 10.0fs;", Ok((_, _)));
|
||||||
|
test!(
|
||||||
|
timeunits_declaration,
|
||||||
|
"timeunit 10.0fs; timeprecision 20s;",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
timeunits_declaration,
|
||||||
|
"timeprecision 10.0fs; timeunit 20s \n;",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_data_type() {
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"struct { bit [7:0] opcode; bit [23:0] addr; }",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"struct packed signed { int a; shortint b; byte c; bit [7:0] d; }",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"union { int i; shortreal f; } ",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"struct { bit isfloat; union { int i; shortreal f; } n; }",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"union packed { s_atmcell acell; bit [423:0] bit_slice; bit [52:0][7:0] byte_slice; }",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_type,
|
||||||
|
"union tagged { void Invalid; int Valid; }",
|
||||||
|
Ok((_, DataType::StructUnion(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_local_parameter_declaration() {
|
||||||
|
test!(
|
||||||
|
local_parameter_declaration,
|
||||||
|
"localparam byte colon1 = \":\" ",
|
||||||
|
Ok((_, LocalParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parameter_declaration() {
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter logic flag = 1 ",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter e = 25, f = 9 ",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter byte_size = 8, byte_mask = byte_size - 1",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter signed [3:0] mux_selector = 0",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter real r1 = 3.5e17",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter logic [31:0] P1 [3:0] = '{ 1, 2, 3, 4 } ",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter r2 = $ ",
|
||||||
|
Ok((_, ParameterDeclaration::Param(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
parameter_declaration,
|
||||||
|
"parameter type p2 = shortint ",
|
||||||
|
Ok((_, ParameterDeclaration::Type(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_specparam_declaration() {
|
||||||
|
test!(specparam_declaration, "specparam delay = 10 ; ", Ok((_, _)));
|
||||||
|
test!(
|
||||||
|
specparam_declaration,
|
||||||
|
"specparam tRise_clk_q = 150, tFall_clk_q = 200;",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_inout_declaration() {
|
||||||
|
test!(inout_declaration, "inout a", Ok((_, _)));
|
||||||
|
test!(inout_declaration, "inout [7:0] a", Ok((_, _)));
|
||||||
|
test!(inout_declaration, "inout signed [7:0] a", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_net_type_declaration() {
|
||||||
|
test!(
|
||||||
|
net_type_declaration,
|
||||||
|
"nettype T wT;",
|
||||||
|
Ok((_, NetTypeDeclaration::DataType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_type_declaration,
|
||||||
|
"nettype T wTsum with Tsum;",
|
||||||
|
Ok((_, NetTypeDeclaration::DataType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_type_declaration,
|
||||||
|
"nettype MyBaseT::T narrowTsum with MyBaseT::Tsum;",
|
||||||
|
Ok((_, NetTypeDeclaration::DataType(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_net_declaration() {
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"trireg (large) logic #(0,0,0) cap1;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wire addressT w1;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wire struct packed { logic ecc; logic [7:0] data; } memsig;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wire w;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wire [15:0] w;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"interconnect w1;",
|
||||||
|
Ok((_, NetDeclaration::Interconnect(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"interconnect [3:0] w2;",
|
||||||
|
Ok((_, NetDeclaration::Interconnect(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"interconnect [3:0] w3 [1:0];",
|
||||||
|
Ok((_, NetDeclaration::Interconnect(_)))
|
||||||
|
);
|
||||||
|
test!(net_declaration, "interconnect logic [3:0] w4;", Err(_));
|
||||||
|
test!(net_declaration, "interconnect #(1,2,3) w5;", Err(_));
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wand w;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"tri [15:0] busa;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"trireg (small) storeit;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"wire w1, w2;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"tri1 scalared [63:0] bus64;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
net_declaration,
|
||||||
|
"tri vectored [31:0] data;",
|
||||||
|
Ok((_, NetDeclaration::NetType(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_data_declaration() {
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"shortint s1, s2[0:9];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"var byte my_byte;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"var v;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"var [15:0] vw;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"var enum bit { clear, error } status;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"var reg r;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int i = 0;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"logic a;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"logic[3:0] v;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"logic signed [3:0] signed_reg;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"logic [-1:4] b;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"logic [4:0] x, y, z;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int unsigned ui;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int signed si;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"string myName = default_name;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"byte c = \"A\";",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"bit [10:0] b = \"x41\";",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"bit [1:4][7:0] h = \"hello\" ;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"event done;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"event done_too = done;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"event empty = null;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef int intP;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"intP a, b;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef enum type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef struct type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef union type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef class type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef interface class type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef type_identifier;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"typedef C::T c_t;",
|
||||||
|
Ok((_, DataDeclaration::TypeDeclaration(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum {red, yellow, green} light1, light2;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum bit [1:0] {IDLE, XX='x, S1=2'b01, S2=2'b10} state, next;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum integer {IDLE, XX='x, S1='b01, S2='b10} state, next;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum integer {IDLE, XX='x, S1='b01, S2='b10} state, next;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum {bronze=3, silver, gold} medal;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum {a=3, b=7, c} alphabet;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"enum bit [3:0] {bronze='h3, silver, gold='h5} medal2;",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"integer i_array[*];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"bit [20:0] array_b[string];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"event ev_array[myClass];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int array_name [*];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int array_name1 [ integer ];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"int a[int] = '{default:1};",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
data_declaration,
|
||||||
|
"byte q1[$];",
|
||||||
|
Ok((_, DataDeclaration::Variable(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_drive_strength() {
|
||||||
|
test!(drive_strength, "(supply0, strong1)", Ok((_, _)));
|
||||||
|
test!(drive_strength, "(pull1, weak0)", Ok((_, _)));
|
||||||
|
test!(drive_strength, "(pull0, highz1)", Ok((_, _)));
|
||||||
|
test!(drive_strength, "(weak1, highz0)", Ok((_, _)));
|
||||||
|
test!(drive_strength, "(highz0, supply1)", Ok((_, _)));
|
||||||
|
test!(drive_strength, "(highz1, strong0)", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_charge_strength() {
|
||||||
|
test!(charge_strength, "( small)", Ok((_, _)));
|
||||||
|
test!(charge_strength, "( medium )", Ok((_, _)));
|
||||||
|
test!(charge_strength, "(large)", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_blocking_assignment() {
|
||||||
|
test!(
|
||||||
|
blocking_assignment,
|
||||||
|
"idest = new [3] (isrc)",
|
||||||
|
Ok((_, BlockingAssignment::NonrangeVariable(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_primary() {
|
||||||
|
test!(primary, "2.1ns ", Ok((_, Primary::PrimaryLiteral(_))));
|
||||||
|
test!(primary, "40 ps ", Ok((_, Primary::PrimaryLiteral(_))));
|
||||||
|
test!(primary, "'0", Ok((_, Primary::PrimaryLiteral(_))));
|
||||||
|
test!(primary, "10", Ok((_, Primary::PrimaryLiteral(_))));
|
||||||
|
test!(primary, "\"aaa\"", Ok((_, Primary::PrimaryLiteral(_))));
|
||||||
|
test!(primary, "this ", Ok((_, Primary::This(_))));
|
||||||
|
test!(primary, "$", Ok((_, Primary::Dollar(_))));
|
||||||
|
test!(primary, "null ", Ok((_, Primary::Null(_))));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cast() {
|
||||||
|
test!(cast, "int'(2.0 * 3.0)", Ok((_, _)));
|
||||||
|
test!(cast, "shortint'({8'hFA,8'hCE}) ", Ok((_, _)));
|
||||||
|
test!(cast, "signed'(x)", Ok((_, _)));
|
||||||
|
test!(cast, "const'(x)", Ok((_, _)));
|
||||||
|
test!(cast, "type_t'(x)", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_number() {
|
||||||
|
test!(number, "659", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "'h 837FF", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "'o7460", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "'4af", Err(_));
|
||||||
|
test!(number, "4'b1001", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "5 'D 3", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "3'b01x", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "12'hx", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "16'hz", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "8 'd -6", Err(_));
|
||||||
|
test!(number, "4 'shf", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "16'sd?", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(number, "27_195_000", Ok((_, Number::IntegralNumber(_))));
|
||||||
|
test!(
|
||||||
|
number,
|
||||||
|
"16'b0011_0101_0001_1111",
|
||||||
|
Ok((_, Number::IntegralNumber(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
number,
|
||||||
|
"32 'h 12ab_f001",
|
||||||
|
Ok((_, Number::IntegralNumber(_)))
|
||||||
|
);
|
||||||
|
test!(number, "1.2", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "0.1", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "2394.26331", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "1.2E12", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "1.30e-2", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "0.1e-0", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "23E10", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "29E-2", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, "236.123_763_e-12", Ok((_, Number::RealNumber(_))));
|
||||||
|
test!(number, ".12", Err(_));
|
||||||
|
test!(number, "9.", Err(_));
|
||||||
|
test!(number, "4.E3", Err(_));
|
||||||
|
test!(number, ".2e-7", Err(_));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unbased_unsized_literal() {
|
||||||
|
test!(unbased_unsized_literal, "'0", Ok((_, _)));
|
||||||
|
test!(unbased_unsized_literal, "'1", Ok((_, _)));
|
||||||
|
test!(unbased_unsized_literal, "'x", Ok((_, _)));
|
||||||
|
test!(unbased_unsized_literal, "'z", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_net_lvalue() {
|
||||||
|
test!(net_lvalue, "A", Ok((_, _)));
|
||||||
|
test!(net_lvalue, "{A[7:0],A[15:8],A[23:16]}", Ok((_, _)));
|
||||||
|
test!(net_lvalue, "'{A[7:0],A[15:8]}", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_variable_lvalue() {
|
||||||
|
test!(variable_lvalue, "A", Ok((_, _)));
|
||||||
|
test!(variable_lvalue, "{A[7:0],A[15:8],A[23:16]}", Ok((_, _)));
|
||||||
|
test!(variable_lvalue, "'{A[7:0],A[15:8]}", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_nonrange_variable_lvalue() {
|
||||||
|
test!(nonrange_variable_lvalue, "A", Ok((_, _)));
|
||||||
|
test!(nonrange_variable_lvalue, "A[1][2][3]", Ok((_, _)));
|
||||||
|
//TODO
|
||||||
|
//test!(nonrange_variable_lvalue, "A[][2][3]", Ok((_, _)));
|
||||||
|
//test!(nonrange_variable_lvalue, "A[][]", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unary_operator() {
|
||||||
|
test!(unary_operator, "+", Ok((_, _)));
|
||||||
|
test!(unary_operator, "-", Ok((_, _)));
|
||||||
|
test!(unary_operator, "!", Ok((_, _)));
|
||||||
|
test!(unary_operator, "&", Ok((_, _)));
|
||||||
|
test!(unary_operator, "|", Ok((_, _)));
|
||||||
|
test!(unary_operator, "~&", Ok((_, _)));
|
||||||
|
test!(unary_operator, "~|", Ok((_, _)));
|
||||||
|
test!(unary_operator, "~^", Ok((_, _)));
|
||||||
|
test!(unary_operator, "^~", Ok((_, _)));
|
||||||
|
test!(unary_operator, "^", Ok((_, _)));
|
||||||
|
test!(unary_operator, "~", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_binary_operator() {
|
||||||
|
test!(binary_operator, "+", Ok((_, _)));
|
||||||
|
test!(binary_operator, "-", Ok((_, _)));
|
||||||
|
test!(binary_operator, "**", Ok((_, _)));
|
||||||
|
test!(binary_operator, "*", Ok((_, _)));
|
||||||
|
test!(binary_operator, "/", Ok((_, _)));
|
||||||
|
test!(binary_operator, "%", Ok((_, _)));
|
||||||
|
test!(binary_operator, "===", Ok((_, _)));
|
||||||
|
test!(binary_operator, "==?", Ok((_, _)));
|
||||||
|
test!(binary_operator, "==", Ok((_, _)));
|
||||||
|
test!(binary_operator, "!==", Ok((_, _)));
|
||||||
|
test!(binary_operator, "!=?", Ok((_, _)));
|
||||||
|
test!(binary_operator, "!=", Ok((_, _)));
|
||||||
|
test!(binary_operator, "&&", Ok((_, _)));
|
||||||
|
test!(binary_operator, "||", Ok((_, _)));
|
||||||
|
test!(binary_operator, "&", Ok((_, _)));
|
||||||
|
test!(binary_operator, "|", Ok((_, _)));
|
||||||
|
test!(binary_operator, "^~", Ok((_, _)));
|
||||||
|
test!(binary_operator, "^", Ok((_, _)));
|
||||||
|
test!(binary_operator, "~^", Ok((_, _)));
|
||||||
|
test!(binary_operator, ">>>", Ok((_, _)));
|
||||||
|
test!(binary_operator, ">>", Ok((_, _)));
|
||||||
|
test!(binary_operator, "<<<", Ok((_, _)));
|
||||||
|
test!(binary_operator, "<<", Ok((_, _)));
|
||||||
|
test!(binary_operator, "->", Ok((_, _)));
|
||||||
|
test!(binary_operator, "<->", Ok((_, _)));
|
||||||
|
test!(binary_operator, "<=", Ok((_, _)));
|
||||||
|
test!(binary_operator, "<", Ok((_, _)));
|
||||||
|
test!(binary_operator, ">=", Ok((_, _)));
|
||||||
|
test!(binary_operator, ">", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_inc_or_dec_operator() {
|
||||||
|
test!(inc_or_dec_operator, "++", Ok((_, _)));
|
||||||
|
test!(inc_or_dec_operator, "--", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_unary_module_path_operator() {
|
||||||
|
test!(unary_module_path_operator, "!", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "&", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "|", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "~&", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "~|", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "~^", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "^~", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "^", Ok((_, _)));
|
||||||
|
test!(unary_module_path_operator, "~", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_binary_module_path_operator() {
|
||||||
|
test!(binary_module_path_operator, "==", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "!=", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "&&", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "||", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "&", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "|", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "^~", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "^", Ok((_, _)));
|
||||||
|
test!(binary_module_path_operator, "~^", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_string_literal() {
|
||||||
|
test!(string_literal, "\"aaa aaaa\"", Ok((_, _)));
|
||||||
|
test!(string_literal, r#""aaa\" aaaa""#, Ok((_, _)));
|
||||||
|
test!(string_literal, r#""aaa\"""#, Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_identifier() {
|
||||||
|
test!(
|
||||||
|
identifier,
|
||||||
|
"shiftreg_a",
|
||||||
|
Ok((_, Identifier::SimpleIdentifier(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
identifier,
|
||||||
|
"_bus3",
|
||||||
|
Ok((_, Identifier::SimpleIdentifier(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
identifier,
|
||||||
|
"n$657",
|
||||||
|
Ok((_, Identifier::SimpleIdentifier(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
identifier,
|
||||||
|
"\\busa+index",
|
||||||
|
Ok((_, Identifier::EscapedIdentifier(_)))
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
identifier,
|
||||||
|
"\\-clock",
|
||||||
|
Ok((_, Identifier::EscapedIdentifier(_)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_system_tf_identifier() {
|
||||||
|
test!(system_tf_identifier, "$display", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_comment() {
|
||||||
|
test!(comment, "// comment", Ok((_, _)));
|
||||||
|
test!(comment, "/* comment\n\n */", Ok((_, _)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_attribute_instance() {
|
||||||
|
test!(
|
||||||
|
attribute_instance,
|
||||||
|
"(* full_case, parallel_case *)",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
test!(attribute_instance, "(* full_case=1 *)", Ok((_, _)));
|
||||||
|
test!(
|
||||||
|
attribute_instance,
|
||||||
|
"(* full_case=1, parallel_case = 0 *)",
|
||||||
|
Ok((_, _))
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
pub mod udp_body;
|
||||||
|
pub mod udp_declaration;
|
||||||
|
pub mod udp_instantiation;
|
||||||
|
pub mod udp_ports;
|
||||||
|
pub(crate) use udp_body::*;
|
||||||
|
pub(crate) use udp_declaration::*;
|
||||||
|
pub(crate) use udp_instantiation::*;
|
||||||
|
pub(crate) use udp_ports::*;
|
@ -1,119 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UdpBody {
|
|
||||||
CombinationalBody(Box<CombinationalBody>),
|
|
||||||
SequentialBody(Box<SequentialBody>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CombinationalBody {
|
|
||||||
pub nodes: (
|
|
||||||
Keyword,
|
|
||||||
CombinationalEntry,
|
|
||||||
Vec<CombinationalEntry>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CombinationalEntry {
|
|
||||||
pub nodes: (LevelInputList, Symbol, OutputSymbol, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequentialBody {
|
|
||||||
pub nodes: (
|
|
||||||
Option<UdpInitialStatement>,
|
|
||||||
Keyword,
|
|
||||||
SequentialEntry,
|
|
||||||
Vec<SequentialEntry>,
|
|
||||||
Keyword,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpInitialStatement {
|
|
||||||
pub nodes: (Keyword, OutputPortIdentifier, Symbol, InitVal, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct InitVal {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct SequentialEntry {
|
|
||||||
pub nodes: (
|
|
||||||
SeqInputList,
|
|
||||||
Symbol,
|
|
||||||
CurrentState,
|
|
||||||
Symbol,
|
|
||||||
NextState,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum SeqInputList {
|
|
||||||
LevelInputList(Box<LevelInputList>),
|
|
||||||
EdgeInputList(Box<EdgeInputList>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LevelInputList {
|
|
||||||
pub nodes: (LevelSymbol, Vec<LevelSymbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeInputList {
|
|
||||||
pub nodes: (Vec<LevelSymbol>, EdgeIndicator, Vec<LevelSymbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum EdgeIndicator {
|
|
||||||
Paren(Box<EdgeIndicatorParen>),
|
|
||||||
EdgeSymbol(Box<EdgeSymbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeIndicatorParen {
|
|
||||||
pub nodes: (Paren<(LevelSymbol, LevelSymbol)>,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct CurrentState {
|
|
||||||
pub nodes: (LevelSymbol,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum NextState {
|
|
||||||
OutputSymbol(Box<OutputSymbol>),
|
|
||||||
Minus(Box<Symbol>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct OutputSymbol {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct LevelSymbol {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct EdgeSymbol {
|
|
||||||
pub nodes: (Keyword,),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,90 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpNonansiDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
UdpIdentifier,
|
|
||||||
Paren<UdpPortList>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpAnsiDeclaration {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
UdpIdentifier,
|
|
||||||
Paren<UdpDeclarationPortList>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UdpDeclaration {
|
|
||||||
Nonansi(Box<UdpDeclarationNonansi>),
|
|
||||||
Ansi(Box<UdpDeclarationAnsi>),
|
|
||||||
ExternNonansi(Box<UdpDeclarationExternNonansi>),
|
|
||||||
ExternAnsi(Box<UdpDeclarationExternAnsi>),
|
|
||||||
Wildcard(Box<UdpDeclarationWildcard>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationNonansi {
|
|
||||||
pub nodes: (
|
|
||||||
UdpNonansiDeclaration,
|
|
||||||
UdpPortDeclaration,
|
|
||||||
Vec<UdpPortDeclaration>,
|
|
||||||
UdpBody,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, UdpIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationAnsi {
|
|
||||||
pub nodes: (
|
|
||||||
UdpAnsiDeclaration,
|
|
||||||
UdpBody,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, UdpIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationExternNonansi {
|
|
||||||
pub nodes: (Keyword, UdpNonansiDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationExternAnsi {
|
|
||||||
pub nodes: (Keyword, UdpAnsiDeclaration),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationWildcard {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
UdpIdentifier,
|
|
||||||
Paren<Symbol>,
|
|
||||||
Symbol,
|
|
||||||
Vec<UdpPortDeclaration>,
|
|
||||||
UdpBody,
|
|
||||||
Keyword,
|
|
||||||
Option<(Symbol, UdpIdentifier)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,35 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpInstantiation {
|
|
||||||
pub nodes: (
|
|
||||||
UdpIdentifier,
|
|
||||||
Option<DriveStrength>,
|
|
||||||
Option<Delay2>,
|
|
||||||
List<Symbol, UdpInstance>,
|
|
||||||
Symbol,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpInstance {
|
|
||||||
pub nodes: (
|
|
||||||
Option<NameOfInstance>,
|
|
||||||
Paren<(
|
|
||||||
OutputTerminal,
|
|
||||||
Symbol,
|
|
||||||
InputTerminal,
|
|
||||||
Vec<(Symbol, InputTerminal)>,
|
|
||||||
)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,69 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpPortList {
|
|
||||||
pub nodes: (
|
|
||||||
OutputPortIdentifier,
|
|
||||||
Symbol,
|
|
||||||
List<Symbol, InputPortIdentifier>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpDeclarationPortList {
|
|
||||||
pub nodes: (
|
|
||||||
UdpOutputDeclaration,
|
|
||||||
Symbol,
|
|
||||||
List<Symbol, UdpInputDeclaration>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UdpPortDeclaration {
|
|
||||||
UdpOutputDeclaration(Box<(UdpOutputDeclaration, Symbol)>),
|
|
||||||
UdpInputDeclaration(Box<(UdpInputDeclaration, Symbol)>),
|
|
||||||
UdpRegDeclaration(Box<(UdpRegDeclaration, Symbol)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum UdpOutputDeclaration {
|
|
||||||
Nonreg(Box<UdpOutputDeclarationNonreg>),
|
|
||||||
Reg(Box<UdpOutputDeclarationReg>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpOutputDeclarationNonreg {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Keyword, PortIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpOutputDeclarationReg {
|
|
||||||
pub nodes: (
|
|
||||||
Vec<AttributeInstance>,
|
|
||||||
Keyword,
|
|
||||||
Keyword,
|
|
||||||
PortIdentifier,
|
|
||||||
Option<(Symbol, ConstantExpression)>,
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpInputDeclaration {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Keyword, ListOfUdpPortIdentifiers),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct UdpRegDeclaration {
|
|
||||||
pub nodes: (Vec<AttributeInstance>, Keyword, VariableIdentifier),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -1,12 +1,4 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use nom::branch::*;
|
|
||||||
use nom::bytes::complete::*;
|
|
||||||
use nom::character::complete::*;
|
|
||||||
use nom::combinator::*;
|
|
||||||
use nom::multi::*;
|
|
||||||
use nom::sequence::*;
|
|
||||||
use nom::IResult;
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -261,47 +253,6 @@ const KEYWORDS: &[&str] = &[
|
|||||||
"xor",
|
"xor",
|
||||||
];
|
];
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Symbol {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub struct Keyword {
|
|
||||||
pub nodes: (Locate, Vec<WhiteSpace>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Node)]
|
|
||||||
pub enum WhiteSpace {
|
|
||||||
Space(Box<Locate>),
|
|
||||||
Comment(Box<Comment>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Paren<T> {
|
|
||||||
pub nodes: (Symbol, T, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Brace<T> {
|
|
||||||
pub nodes: (Symbol, T, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Bracket<T> {
|
|
||||||
pub nodes: (Symbol, T, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct ApostropheBrace<T> {
|
|
||||||
pub nodes: (Symbol, T, Symbol),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct List<T, U> {
|
|
||||||
pub nodes: (U, Vec<(T, U)>),
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
pub(crate) fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O, Vec<WhiteSpace>)>
|
pub(crate) fn ws<'a, O, F>(f: F) -> impl Fn(Span<'a>) -> IResult<Span<'a>, (O, Vec<WhiteSpace>)>
|
||||||
@ -543,16 +494,3 @@ pub(crate) fn trace<'a>(mut s: Span<'a>, name: &str) -> Span<'a> {
|
|||||||
s.extra.depth += 1;
|
s.extra.depth += 1;
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
macro_rules! parser_test {
|
|
||||||
( $x:expr, $y:expr, $z:pat ) => {
|
|
||||||
let ret = all_consuming($x)(Span::new_extra($y, Extra::default()));
|
|
||||||
if let $z = ret {
|
|
||||||
} else {
|
|
||||||
assert!(false, "{:?}", ret)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
14
sv-parser-syntaxtree/Cargo.toml
Normal file
14
sv-parser-syntaxtree/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "sv-parser-syntaxtree"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["dalance <dalance@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
build = "build.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
sv-parser-macros = { path = "../sv-parser-macros" }
|
||||||
|
nom_locate = { path = "../../nom_locate" }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
walkdir = "2"
|
||||||
|
regex = "1"
|
@ -22,7 +22,7 @@ fn main() {
|
|||||||
|
|
||||||
let re_node = Regex::new(r"#\[derive.*Node.*\]").unwrap();
|
let re_node = Regex::new(r"#\[derive.*Node.*\]").unwrap();
|
||||||
|
|
||||||
for entry in WalkDir::new("src/parser") {
|
for entry in WalkDir::new("src") {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
if entry.file_type().is_file() {
|
if entry.file_type().is_file() {
|
||||||
let f = File::open(entry.path()).unwrap();
|
let f = File::open(entry.path()).unwrap();
|
@ -1,12 +1,11 @@
|
|||||||
use crate::ast::*;
|
use crate::*;
|
||||||
use crate::parser::*;
|
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/any_node.rs"));
|
include!(concat!(env!("OUT_DIR"), "/any_node.rs"));
|
||||||
|
|
||||||
pub(crate) struct RefNodes<'a>(pub Vec<RefNode<'a>>);
|
pub struct RefNodes<'a>(pub Vec<RefNode<'a>>);
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
@ -0,0 +1,80 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AssertionItem {
|
||||||
|
Concurrent(Box<ConcurrentAssertionItem>),
|
||||||
|
Immediate(Box<DeferredImmediateAssetionItem>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DeferredImmediateAssetionItem {
|
||||||
|
pub nodes: (
|
||||||
|
Option<(BlockIdentifier, Symbol)>,
|
||||||
|
DeferredImmediateAssertionStatement,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ProceduralAssertionStatement {
|
||||||
|
Concurrent(Box<ConcurrentAssertionStatement>),
|
||||||
|
Immediate(Box<ImmediateAssetionStatement>),
|
||||||
|
Checker(Box<CheckerInstantiation>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ImmediateAssetionStatement {
|
||||||
|
Simple(Box<SimpleImmediateAssertionStatement>),
|
||||||
|
Deferred(Box<DeferredImmediateAssertionStatement>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum SimpleImmediateAssertionStatement {
|
||||||
|
Assert(Box<SimpleImmediateAssertStatement>),
|
||||||
|
Assume(Box<SimpleImmediateAssumeStatement>),
|
||||||
|
Cover(Box<SimpleImmediateCoverStatement>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct SimpleImmediateAssertStatement {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, ActionBlock),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct SimpleImmediateAssumeStatement {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, ActionBlock),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct SimpleImmediateCoverStatement {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum DeferredImmediateAssertionStatement {
|
||||||
|
Assert(Box<DeferredImmediateAssertStatement>),
|
||||||
|
Assume(Box<DeferredImmediateAssumeStatement>),
|
||||||
|
Cover(Box<DeferredImmediateCoverStatement>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DeferredImmediateAssertStatement {
|
||||||
|
pub nodes: (Keyword, AssertTiming, Paren<Expression>, ActionBlock),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DeferredImmediateAssumeStatement {
|
||||||
|
pub nodes: (Keyword, AssertTiming, Paren<Expression>, ActionBlock),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DeferredImmediateCoverStatement {
|
||||||
|
pub nodes: (Keyword, AssertTiming, Paren<Expression>, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AssertTiming {
|
||||||
|
Zero(Box<Symbol>),
|
||||||
|
Final(Box<Keyword>),
|
||||||
|
}
|
@ -0,0 +1,128 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CaseStatement {
|
||||||
|
Normal(Box<CaseStatementNormal>),
|
||||||
|
Matches(Box<CaseStatementMatches>),
|
||||||
|
Inside(Box<CaseStatementInside>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseStatementNormal {
|
||||||
|
pub nodes: (
|
||||||
|
Option<UniquePriority>,
|
||||||
|
CaseKeyword,
|
||||||
|
Paren<CaseExpression>,
|
||||||
|
CaseItem,
|
||||||
|
Vec<CaseItem>,
|
||||||
|
Keyword,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseStatementMatches {
|
||||||
|
pub nodes: (
|
||||||
|
Option<UniquePriority>,
|
||||||
|
CaseKeyword,
|
||||||
|
Paren<CaseExpression>,
|
||||||
|
Keyword,
|
||||||
|
CasePatternItem,
|
||||||
|
Vec<CasePatternItem>,
|
||||||
|
Keyword,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseStatementInside {
|
||||||
|
pub nodes: (
|
||||||
|
Option<UniquePriority>,
|
||||||
|
Keyword,
|
||||||
|
Paren<CaseExpression>,
|
||||||
|
Keyword,
|
||||||
|
CaseInsideItem,
|
||||||
|
Vec<CaseInsideItem>,
|
||||||
|
Keyword,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CaseKeyword {
|
||||||
|
Case(Box<Keyword>),
|
||||||
|
Casez(Box<Keyword>),
|
||||||
|
Casex(Box<Keyword>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseExpression {
|
||||||
|
pub nodes: (Expression,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CaseItem {
|
||||||
|
NonDefault(Box<CaseItemNondefault>),
|
||||||
|
Default(Box<CaseItemDefault>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseItemNondefault {
|
||||||
|
pub nodes: (List<Symbol, CaseItemExpression>, Symbol, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseItemDefault {
|
||||||
|
pub nodes: (Keyword, Option<Symbol>, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CasePatternItem {
|
||||||
|
NonDefault(Box<CasePatternItemNondefault>),
|
||||||
|
Default(Box<CaseItemDefault>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CasePatternItemNondefault {
|
||||||
|
pub nodes: (
|
||||||
|
Pattern,
|
||||||
|
Option<(Symbol, Expression)>,
|
||||||
|
Symbol,
|
||||||
|
StatementOrNull,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CaseInsideItem {
|
||||||
|
NonDefault(Box<CaseInsideItemNondefault>),
|
||||||
|
Default(Box<CaseItemDefault>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseInsideItemNondefault {
|
||||||
|
pub nodes: (OpenRangeList, Symbol, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CaseItemExpression {
|
||||||
|
pub nodes: (Expression,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RandcaseStatement {
|
||||||
|
pub nodes: (Keyword, RandcaseItem, Vec<RandcaseItem>, Keyword),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RandcaseItem {
|
||||||
|
pub nodes: (Expression, Symbol, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct OpenRangeList {
|
||||||
|
pub nodes: (List<Symbol, OpenValueRange>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct OpenValueRange {
|
||||||
|
pub nodes: (ValueRange,),
|
||||||
|
}
|
182
sv-parser-syntaxtree/src/behavioral_statements/clocking_block.rs
Normal file
182
sv-parser-syntaxtree/src/behavioral_statements/clocking_block.rs
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ClockingDeclaration {
|
||||||
|
Local(Box<ClockingDeclarationLocal>),
|
||||||
|
Global(Box<ClockingDeclarationGlobal>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDeclarationLocal {
|
||||||
|
pub nodes: (
|
||||||
|
Option<Default>,
|
||||||
|
Keyword,
|
||||||
|
Option<ClockingIdentifier>,
|
||||||
|
ClockingEvent,
|
||||||
|
Symbol,
|
||||||
|
Vec<ClockingItem>,
|
||||||
|
Keyword,
|
||||||
|
Option<(Symbol, ClockingIdentifier)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct Default {
|
||||||
|
pub nodes: (Keyword,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDeclarationGlobal {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Keyword,
|
||||||
|
Option<ClockingIdentifier>,
|
||||||
|
ClockingEvent,
|
||||||
|
Symbol,
|
||||||
|
Keyword,
|
||||||
|
Option<(Symbol, ClockingIdentifier)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ClockingEvent {
|
||||||
|
Identifier(Box<ClockingEventIdentifier>),
|
||||||
|
Expression(Box<ClockingEventExpression>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingEventIdentifier {
|
||||||
|
pub nodes: (Symbol, Identifier),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingEventExpression {
|
||||||
|
pub nodes: (Symbol, Paren<EventExpression>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ClockingItem {
|
||||||
|
Default(Box<ClockingItemDefault>),
|
||||||
|
Direction(Box<ClockingItemDirection>),
|
||||||
|
Assertion(Box<ClockingItemAssertion>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingItemDefault {
|
||||||
|
pub nodes: (Keyword, DefaultSkew, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingItemDirection {
|
||||||
|
pub nodes: (ClockingDirection, ListOfClockingDeclAssign, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingItemAssertion {
|
||||||
|
pub nodes: (Vec<AttributeInstance>, AssertionItemDeclaration),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum DefaultSkew {
|
||||||
|
Input(Box<DefaultSkewInput>),
|
||||||
|
Output(Box<DefaultSkewOutput>),
|
||||||
|
InputOutput(Box<DefaultSkewInputOutput>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DefaultSkewInput {
|
||||||
|
pub nodes: (Keyword, ClockingSkew),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DefaultSkewOutput {
|
||||||
|
pub nodes: (Keyword, ClockingSkew),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct DefaultSkewInputOutput {
|
||||||
|
pub nodes: (Keyword, ClockingSkew, Keyword, ClockingSkew),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ClockingDirection {
|
||||||
|
Input(Box<ClockingDirectionInput>),
|
||||||
|
Output(Box<ClockingDirectionOutput>),
|
||||||
|
InputOutput(Box<ClockingDirectionInputOutput>),
|
||||||
|
Inout(Box<Keyword>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDirectionInput {
|
||||||
|
pub nodes: (Keyword, Option<ClockingSkew>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDirectionOutput {
|
||||||
|
pub nodes: (Keyword, Option<ClockingSkew>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDirectionInputOutput {
|
||||||
|
pub nodes: (Keyword, Option<ClockingSkew>, Keyword, Option<ClockingSkew>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ListOfClockingDeclAssign {
|
||||||
|
pub nodes: (List<Symbol, ClockingDeclAssign>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDeclAssign {
|
||||||
|
pub nodes: (SignalIdentifier, Option<(Symbol, Expression)>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ClockingSkew {
|
||||||
|
Edge(Box<ClockingSkewEdge>),
|
||||||
|
DelayControl(Box<DelayControl>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingSkewEdge {
|
||||||
|
pub nodes: (EdgeIdentifier, Option<DelayControl>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockingDrive {
|
||||||
|
pub nodes: (ClockvarExpression, Symbol, Option<CycleDelay>, Expression),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum CycleDelay {
|
||||||
|
Integral(Box<CycleDelayIntegral>),
|
||||||
|
Identifier(Box<CycleDelayIdentifier>),
|
||||||
|
Expression(Box<CycleDelayExpression>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CycleDelayIntegral {
|
||||||
|
pub nodes: (Symbol, IntegralNumber),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CycleDelayIdentifier {
|
||||||
|
pub nodes: (Symbol, Identifier),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CycleDelayExpression {
|
||||||
|
pub nodes: (Symbol, Paren<Expression>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct Clockvar {
|
||||||
|
pub nodes: (HierarchicalIdentifier,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ClockvarExpression {
|
||||||
|
pub nodes: (Clockvar, Select),
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ConditionalStatement {
|
||||||
|
pub nodes: (
|
||||||
|
Option<UniquePriority>,
|
||||||
|
Keyword,
|
||||||
|
Paren<CondPredicate>,
|
||||||
|
StatementOrNull,
|
||||||
|
Vec<(Keyword, Keyword, Paren<CondPredicate>, StatementOrNull)>,
|
||||||
|
Option<(Keyword, StatementOrNull)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum UniquePriority {
|
||||||
|
Unique(Box<Keyword>),
|
||||||
|
Unique0(Box<Keyword>),
|
||||||
|
Priority(Box<Keyword>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CondPredicate {
|
||||||
|
pub nodes: (List<Symbol, ExpressionOrCondPattern>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ExpressionOrCondPattern {
|
||||||
|
Expression(Box<Expression>),
|
||||||
|
CondPattern(Box<CondPattern>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct CondPattern {
|
||||||
|
pub nodes: (Expression, Keyword, Pattern),
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ContinuousAssign {
|
||||||
|
Net(Box<ContinuousAssignNet>),
|
||||||
|
Variable(Box<ContinuousAssignVariable>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ContinuousAssignNet {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Option<DriveStrength>,
|
||||||
|
Option<Delay3>,
|
||||||
|
ListOfNetAssignments,
|
||||||
|
Symbol,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ContinuousAssignVariable {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Option<DelayControl>,
|
||||||
|
ListOfVariableAssignments,
|
||||||
|
Symbol,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ListOfNetAssignments {
|
||||||
|
pub nodes: (List<Symbol, NetAssignment>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ListOfVariableAssignments {
|
||||||
|
pub nodes: (List<Symbol, VariableAssignment>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct NetAlias {
|
||||||
|
pub nodes: (Keyword, NetLvalue, Symbol, List<Symbol, NetLvalue>, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct NetAssignment {
|
||||||
|
pub nodes: (NetLvalue, Symbol, Expression),
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum LoopStatement {
|
||||||
|
Forever(Box<LoopStatementForever>),
|
||||||
|
Repeat(Box<LoopStatementRepeat>),
|
||||||
|
While(Box<LoopStatementWhile>),
|
||||||
|
For(Box<LoopStatementFor>),
|
||||||
|
DoWhile(Box<LoopStatementDoWhile>),
|
||||||
|
Foreach(Box<LoopStatementForeach>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementForever {
|
||||||
|
pub nodes: (Keyword, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementRepeat {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementWhile {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementFor {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Paren<(
|
||||||
|
Option<ForInitialization>,
|
||||||
|
Symbol,
|
||||||
|
Option<Expression>,
|
||||||
|
Symbol,
|
||||||
|
Option<ForStep>,
|
||||||
|
)>,
|
||||||
|
StatementOrNull,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementDoWhile {
|
||||||
|
pub nodes: (Keyword, StatementOrNull, Keyword, Paren<Expression>, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopStatementForeach {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Paren<(PsOrHierarchicalArrayIdentifier, Bracket<LoopVariables>)>,
|
||||||
|
Statement,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ForInitialization {
|
||||||
|
ListOfVariableAssignments(Box<ListOfVariableAssignments>),
|
||||||
|
Declaration(Box<ForInitializationDeclaration>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ForInitializationDeclaration {
|
||||||
|
pub nodes: (List<Symbol, ForVariableDeclaration>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ForVariableDeclaration {
|
||||||
|
pub nodes: (
|
||||||
|
Option<Var>,
|
||||||
|
DataType,
|
||||||
|
List<Symbol, (VariableIdentifier, Symbol, Expression)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct Var {
|
||||||
|
pub nodes: (Keyword,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ForStep {
|
||||||
|
pub nodes: (List<Symbol, ForStepAssignment>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ForStepAssignment {
|
||||||
|
OperatorAssignment(Box<OperatorAssignment>),
|
||||||
|
IncOrDecExpression(Box<IncOrDecExpression>),
|
||||||
|
FunctionSubroutineCall(Box<FunctionSubroutineCall>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct LoopVariables {
|
||||||
|
pub nodes: (List<Symbol, Option<IndexVariableIdentifier>>,),
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ActionBlock {
|
||||||
|
StatementOrNull(Box<StatementOrNull>),
|
||||||
|
Else(Box<ActionBlockElse>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ActionBlockElse {
|
||||||
|
pub nodes: (Option<Statement>, Keyword, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct SeqBlock {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Option<(Symbol, BlockIdentifier)>,
|
||||||
|
Vec<BlockItemDeclaration>,
|
||||||
|
Vec<StatementOrNull>,
|
||||||
|
Keyword,
|
||||||
|
Option<(Symbol, BlockIdentifier)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ParBlock {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Option<(Symbol, BlockIdentifier)>,
|
||||||
|
Vec<BlockItemDeclaration>,
|
||||||
|
Vec<StatementOrNull>,
|
||||||
|
JoinKeyword,
|
||||||
|
Option<(Symbol, BlockIdentifier)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum JoinKeyword {
|
||||||
|
Join(Box<Keyword>),
|
||||||
|
JoinAny(Box<Keyword>),
|
||||||
|
JoinNone(Box<Keyword>),
|
||||||
|
}
|
107
sv-parser-syntaxtree/src/behavioral_statements/patterns.rs
Normal file
107
sv-parser-syntaxtree/src/behavioral_statements/patterns.rs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum Pattern {
|
||||||
|
Variable(Box<PatternVariable>),
|
||||||
|
Asterisk(Box<Symbol>),
|
||||||
|
ConstantExpression(Box<ConstantExpression>),
|
||||||
|
Tagged(Box<PatternTagged>),
|
||||||
|
List(Box<PatternList>),
|
||||||
|
IdentifierList(Box<PatternIdentifierList>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct PatternVariable {
|
||||||
|
pub nodes: (Symbol, VariableIdentifier),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct PatternTagged {
|
||||||
|
pub nodes: (Keyword, MemberIdentifier, Option<Pattern>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct PatternList {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, Pattern>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct PatternIdentifierList {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, (MemberIdentifier, Symbol, Pattern)>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AssignmentPattern {
|
||||||
|
List(Box<AssignmentPatternList>),
|
||||||
|
Structure(Box<AssignmentPatternStructure>),
|
||||||
|
Array(Box<AssignmentPatternArray>),
|
||||||
|
Repeat(Box<AssignmentPatternRepeat>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternList {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, Expression>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternStructure {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, (StructurePatternKey, Symbol, Expression)>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternArray {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, (ArrayPatternKey, Symbol, Expression)>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternRepeat {
|
||||||
|
pub nodes: (ApostropheBrace<(ConstantExpression, Brace<List<Symbol, Expression>>)>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum StructurePatternKey {
|
||||||
|
MemberIdentifier(Box<MemberIdentifier>),
|
||||||
|
AssignmentPatternKey(Box<AssignmentPatternKey>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ArrayPatternKey {
|
||||||
|
ConstantExpression(Box<ConstantExpression>),
|
||||||
|
AssignmentPatternKey(Box<AssignmentPatternKey>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AssignmentPatternKey {
|
||||||
|
SimpleType(Box<SimpleType>),
|
||||||
|
Default(Box<Keyword>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternExpression {
|
||||||
|
pub nodes: (Option<AssignmentPatternExpressionType>, AssignmentPattern),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AssignmentPatternExpressionType {
|
||||||
|
PsTypeIdentifier(Box<PsTypeIdentifier>),
|
||||||
|
PsParameterIdentifier(Box<PsParameterIdentifier>),
|
||||||
|
IntegerAtomType(Box<IntegerAtomType>),
|
||||||
|
TypeReference(Box<TypeReference>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ConstantAssignmentPatternExpression {
|
||||||
|
pub nodes: (AssignmentPatternExpression,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternNetLvalue {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, NetLvalue>>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentPatternVariableLvalue {
|
||||||
|
pub nodes: (ApostropheBrace<List<Symbol, VariableLvalue>>,),
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct InitialConstruct {
|
||||||
|
pub nodes: (Keyword, StatementOrNull),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AlwaysConstruct {
|
||||||
|
pub nodes: (AlwaysKeyword, Statement),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum AlwaysKeyword {
|
||||||
|
Always(Box<Keyword>),
|
||||||
|
AlwaysComb(Box<Keyword>),
|
||||||
|
AlwaysLatch(Box<Keyword>),
|
||||||
|
AlwaysFf(Box<Keyword>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct FinalConstruct {
|
||||||
|
pub nodes: (Keyword, FunctionStatement),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum BlockingAssignment {
|
||||||
|
Variable(Box<BlockingAssignmentVariable>),
|
||||||
|
NonrangeVariable(Box<BlockingAssignmentNonrangeVariable>),
|
||||||
|
HierarchicalVariable(Box<BlockingAssignmentHierarchicalVariable>),
|
||||||
|
OperatorAssignment(Box<OperatorAssignment>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct BlockingAssignmentVariable {
|
||||||
|
pub nodes: (VariableLvalue, Symbol, DelayOrEventControl, Expression),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct BlockingAssignmentNonrangeVariable {
|
||||||
|
pub nodes: (NonrangeVariableLvalue, Symbol, DynamicArrayNew),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct BlockingAssignmentHierarchicalVariable {
|
||||||
|
pub nodes: (
|
||||||
|
Option<ImplicitClassHandleOrClassScopeOrPackageScope>,
|
||||||
|
HierarchicalVariableIdentifier,
|
||||||
|
Select,
|
||||||
|
Symbol,
|
||||||
|
ClassNew,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct OperatorAssignment {
|
||||||
|
pub nodes: (VariableLvalue, AssignmentOperator, Expression),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct AssignmentOperator {
|
||||||
|
pub nodes: (Symbol,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct NonblockingAssignment {
|
||||||
|
pub nodes: (
|
||||||
|
VariableLvalue,
|
||||||
|
Symbol,
|
||||||
|
Option<DelayOrEventControl>,
|
||||||
|
Expression,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum ProceduralContinuousAssignment {
|
||||||
|
Assign(Box<ProceduralContinuousAssignmentAssign>),
|
||||||
|
Deassign(Box<ProceduralContinuousAssignmentDeassign>),
|
||||||
|
ForceVariable(Box<ProceduralContinuousAssignmentForceVariable>),
|
||||||
|
ForceNet(Box<ProceduralContinuousAssignmentForceNet>),
|
||||||
|
ReleaseVariable(Box<ProceduralContinuousAssignmentReleaseVariable>),
|
||||||
|
ReleaseNet(Box<ProceduralContinuousAssignmentReleaseNet>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentAssign {
|
||||||
|
pub nodes: (Keyword, VariableAssignment),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentDeassign {
|
||||||
|
pub nodes: (Keyword, VariableLvalue),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentForceVariable {
|
||||||
|
pub nodes: (Keyword, VariableAssignment),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentForceNet {
|
||||||
|
pub nodes: (Keyword, NetAssignment),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentReleaseVariable {
|
||||||
|
pub nodes: (Keyword, VariableLvalue),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProceduralContinuousAssignmentReleaseNet {
|
||||||
|
pub nodes: (Keyword, NetLvalue),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct VariableAssignment {
|
||||||
|
pub nodes: (VariableLvalue, Symbol, Expression),
|
||||||
|
}
|
135
sv-parser-syntaxtree/src/behavioral_statements/randsequence.rs
Normal file
135
sv-parser-syntaxtree/src/behavioral_statements/randsequence.rs
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RandsequenceStatement {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Paren<Option<ProductionIdentifier>>,
|
||||||
|
Production,
|
||||||
|
Vec<Production>,
|
||||||
|
Keyword,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct Production {
|
||||||
|
pub nodes: (
|
||||||
|
Option<DataTypeOrVoid>,
|
||||||
|
ProductionIdentifier,
|
||||||
|
Option<Paren<TfPortList>>,
|
||||||
|
Symbol,
|
||||||
|
List<Symbol, RsRule>,
|
||||||
|
Symbol,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsRule {
|
||||||
|
pub nodes: (
|
||||||
|
RsProductionList,
|
||||||
|
Option<(Symbol, WeightSpecification, Option<RsCodeBlock>)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum RsProductionList {
|
||||||
|
Prod(Box<RsProductionListProd>),
|
||||||
|
Join(Box<RsProductionListJoin>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsProductionListProd {
|
||||||
|
pub nodes: (RsProd, Vec<RsProd>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsProductionListJoin {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Keyword,
|
||||||
|
Option<Paren<Expression>>,
|
||||||
|
ProductionItem,
|
||||||
|
ProductionItem,
|
||||||
|
Vec<ProductionItem>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum WeightSpecification {
|
||||||
|
IntegralNumber(Box<IntegralNumber>),
|
||||||
|
PsIdentifier(Box<PsIdentifier>),
|
||||||
|
Expression(Box<WeightSpecificationExpression>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct WeightSpecificationExpression {
|
||||||
|
pub nodes: (Paren<Expression>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsCodeBlock {
|
||||||
|
pub nodes: (Brace<(Vec<DataDeclaration>, Vec<StatementOrNull>)>,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum RsProd {
|
||||||
|
ProductionItem(Box<ProductionItem>),
|
||||||
|
RsCodeBlock(Box<RsCodeBlock>),
|
||||||
|
RsIfElse(Box<RsIfElse>),
|
||||||
|
RsRepeat(Box<RsRepeat>),
|
||||||
|
RsCase(Box<RsCase>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct ProductionItem {
|
||||||
|
pub nodes: (ProductionIdentifier, Option<Paren<ListOfArguments>>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsIfElse {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Paren<Expression>,
|
||||||
|
ProductionItem,
|
||||||
|
Option<(Keyword, ProductionItem)>,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsRepeat {
|
||||||
|
pub nodes: (Keyword, Paren<Expression>, ProductionItem),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsCase {
|
||||||
|
pub nodes: (
|
||||||
|
Keyword,
|
||||||
|
Paren<CaseExpression>,
|
||||||
|
RsCaseItem,
|
||||||
|
Vec<RsCaseItem>,
|
||||||
|
Keyword,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum RsCaseItem {
|
||||||
|
NonDefault(Box<RsCaseItemNondefault>),
|
||||||
|
Default(Box<RsCaseItemDefault>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsCaseItemNondefault {
|
||||||
|
pub nodes: (
|
||||||
|
List<Symbol, CaseItemExpression>,
|
||||||
|
Symbol,
|
||||||
|
ProductionItem,
|
||||||
|
Symbol,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct RsCaseItemDefault {
|
||||||
|
pub nodes: (Keyword, Option<Symbol>, ProductionItem, Symbol),
|
||||||
|
}
|
68
sv-parser-syntaxtree/src/behavioral_statements/statements.rs
Normal file
68
sv-parser-syntaxtree/src/behavioral_statements/statements.rs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
use crate::*;
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum StatementOrNull {
|
||||||
|
Statement(Box<Statement>),
|
||||||
|
Attribute(Box<StatementOrNullAttribute>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct StatementOrNullAttribute {
|
||||||
|
pub nodes: (Vec<AttributeInstance>, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct Statement {
|
||||||
|
pub nodes: (
|
||||||
|
Option<(BlockIdentifier, Symbol)>,
|
||||||
|
Vec<AttributeInstance>,
|
||||||
|
StatementItem,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum StatementItem {
|
||||||
|
BlockingAssignment(Box<(BlockingAssignment, Symbol)>),
|
||||||
|
NonblockingAssignment(Box<(NonblockingAssignment, Symbol)>),
|
||||||
|
ProceduralContinuousAssignment(Box<(ProceduralContinuousAssignment, Symbol)>),
|
||||||
|
CaseStatement(Box<CaseStatement>),
|
||||||
|
ConditionalStatement(Box<ConditionalStatement>),
|
||||||
|
IncOrDecExpression(Box<(IncOrDecExpression, Symbol)>),
|
||||||
|
SubroutineCallStatement(Box<SubroutineCallStatement>),
|
||||||
|
DisableStatement(Box<DisableStatement>),
|
||||||
|
EventTrigger(Box<EventTrigger>),
|
||||||
|
LoopStatement(Box<LoopStatement>),
|
||||||
|
JumpStatement(Box<JumpStatement>),
|
||||||
|
ParBlock(Box<ParBlock>),
|
||||||
|
ProceduralTimingControlStatement(Box<ProceduralTimingControlStatement>),
|
||||||
|
SeqBlock(Box<SeqBlock>),
|
||||||
|
WaitStatement(Box<WaitStatement>),
|
||||||
|
ProceduralAssertionStatement(Box<ProceduralAssertionStatement>),
|
||||||
|
ClockingDrive(Box<(ClockingDrive, Symbol)>),
|
||||||
|
RandsequenceStatement(Box<RandsequenceStatement>),
|
||||||
|
RandcaseStatement(Box<RandcaseStatement>),
|
||||||
|
ExpectPropertyStatement(Box<ExpectPropertyStatement>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct FunctionStatement {
|
||||||
|
pub nodes: (Statement,),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub enum FunctionStatementOrNull {
|
||||||
|
Statement(Box<FunctionStatement>),
|
||||||
|
Attribute(Box<FunctionStatementOrNullAttribute>),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct FunctionStatementOrNullAttribute {
|
||||||
|
pub nodes: (Vec<AttributeInstance>, Symbol),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Node)]
|
||||||
|
pub struct VariableIdentifierList {
|
||||||
|
pub nodes: (List<Symbol, VariableIdentifier>,),
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user