From 0aef3ba3f67df91cc7d494440ea28afc964c9869 Mon Sep 17 00:00:00 2001 From: Stephen McGinty Date: Tue, 25 Jun 2024 16:24:52 +0800 Subject: [PATCH 1/2] Allow the final waveform def not to have a semicolon terminator --- rust/origen_metal/src/stil/parser.rs | 2 +- rust/origen_metal/src/stil/stil.pest | 3 ++- test_apps/python_app/vendor/stil/example2.stil | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rust/origen_metal/src/stil/parser.rs b/rust/origen_metal/src/stil/parser.rs index 4a31c7fd..f12dad71 100644 --- a/rust/origen_metal/src/stil/parser.rs +++ b/rust/origen_metal/src/stil/parser.rs @@ -664,7 +664,7 @@ pub fn to_ast(mut pair: Pair, source_file: Option<&str>) -> Result { + Rule::event | Rule::event_with_no_semicolon => { ids.push(ast.push_and_open(node!(STIL::Event))); pairs.push(pair.into_inner()); } diff --git a/rust/origen_metal/src/stil/stil.pest b/rust/origen_metal/src/stil/stil.pest index 6d2d8dee..ddaabbc9 100644 --- a/rust/origen_metal/src/stil/stil.pest +++ b/rust/origen_metal/src/stil/stil.pest @@ -221,12 +221,13 @@ waveforms = { "Waveforms" ~ "{" ~ waveform* ~ "}" } waveform = { sigref_expr ~ "{" ~ inherit_waveform* ~ (tagged_wfc_definition | wfc_definition)* ~ "}" } inherit_waveform = { "InheritWaveform" ~ name ~ EOS } wfc_definition = { wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ "}" } -tagged_wfc_definition = { tag ~ wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ "}" } +tagged_wfc_definition = { tag ~ wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ event_with_no_semicolon? ~ "}" } wfc_list = @{ wfc_char+ } wfc_char = { ASCII_ALPHANUMERIC } inherit_waveform_wfc = { "InheritWaveform" ~ name_wfc ~ EOS } name_wfc = { ((name_segment ~ ".")+ ~ wfc_list) | wfc_list } event = { label? ~ time_expr? ~ event_list? ~ EOS } +event_with_no_semicolon = { label? ~ time_expr? ~ event_list? } event_list = { event_char ~ ("/" ~ event_char)* } event_char = { "D" | "U" | "Z" | "P" | "L" | "H" | "X" | "x" | "T" | "V" | "l" | "h" | "t" | "v" | "R" | "G" | diff --git a/test_apps/python_app/vendor/stil/example2.stil b/test_apps/python_app/vendor/stil/example2.stil index f7efd786..6a658bae 100644 --- a/test_apps/python_app/vendor/stil/example2.stil +++ b/test_apps/python_app/vendor/stil/example2.stil @@ -36,7 +36,7 @@ SignalGroups quality { Timing { WaveformTable defaults { Waveforms { - allpins { xX { TMARK: 't_anchor' Z; } } + allpins { xX { TMARK: 't_anchor' Z } } } } WaveformTable wft1 { From 3fc15704d78a5f5566aa044efc6aeddade93d610 Mon Sep 17 00:00:00 2001 From: Stephen McGinty Date: Wed, 26 Jun 2024 10:00:10 +0800 Subject: [PATCH 2/2] Add coverage for tagged waveform parsing --- rust/origen_metal/src/stil/stil.pest | 4 +++- test_apps/python_app/vendor/stil/example2.stil | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rust/origen_metal/src/stil/stil.pest b/rust/origen_metal/src/stil/stil.pest index ddaabbc9..c8a8aff2 100644 --- a/rust/origen_metal/src/stil/stil.pest +++ b/rust/origen_metal/src/stil/stil.pest @@ -220,7 +220,9 @@ sub_waveform = { label? ~ "Duration" ~ time_expr ~ "{" ~ event* ~ "}" } waveforms = { "Waveforms" ~ "{" ~ waveform* ~ "}" } waveform = { sigref_expr ~ "{" ~ inherit_waveform* ~ (tagged_wfc_definition | wfc_definition)* ~ "}" } inherit_waveform = { "InheritWaveform" ~ name ~ EOS } -wfc_definition = { wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ "}" } +// Allow the final event to optionally have no semicolon at the end, for compatibility with historical AMD +// waveform defs which don't have a semicolon for waveforms that only contain a single event +wfc_definition = { wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ event_with_no_semicolon? ~ "}" } tagged_wfc_definition = { tag ~ wfc_list ~ "{" ~ inherit_waveform_wfc* ~ event* ~ event_with_no_semicolon? ~ "}" } wfc_list = @{ wfc_char+ } wfc_char = { ASCII_ALPHANUMERIC } diff --git a/test_apps/python_app/vendor/stil/example2.stil b/test_apps/python_app/vendor/stil/example2.stil index 6a658bae..0c363272 100644 --- a/test_apps/python_app/vendor/stil/example2.stil +++ b/test_apps/python_app/vendor/stil/example2.stil @@ -36,7 +36,17 @@ SignalGroups quality { Timing { WaveformTable defaults { Waveforms { - allpins { xX { TMARK: 't_anchor' Z } } + allpins { + xX { TMARK: 't_anchor' Z } + 0 {'0ns' D; } + 1 {'0ns' U } + L {'0ns' L; } + H {'0ns' H } + p {'0ns' U; '5ns' D; } + P {'0ns' D; '5ns' U } + t {'0ns' U; '5ns' D; } + T {'0ns' D; '5ns' U } + } } } WaveformTable wft1 {