diff --git a/CHANGELOG.md b/CHANGELOG.md index 5704b164..b8adf1ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ * Fixed unneeded scoping of constant function calls used in type lookups * `/*/` is no longer interpreted as a self-closing block comment, e.g., `$display("a"/*/,"b"/* */);` previously printed "ab", but now prints "a" - +* Fixed keywords included in the "1364-2001" and "1364-2001-noconfig" + `begin_keywords` version specifiers ### New Features diff --git a/src/Language/SystemVerilog/Parser/Keywords.hs b/src/Language/SystemVerilog/Parser/Keywords.hs index 727ace2f..414507e7 100644 --- a/src/Language/SystemVerilog/Parser/Keywords.hs +++ b/src/Language/SystemVerilog/Parser/Keywords.hs @@ -33,13 +33,13 @@ newKeywords = [ KW_trireg, KW_vectored, KW_wait, KW_wand, KW_weak0, KW_weak1, KW_while, KW_wire, KW_wor, KW_xnor, KW_xor]), - ("1364-2001-noconfig", [KW_cell, KW_config, KW_design, KW_endconfig, - KW_incdir, KW_include, KW_instance, KW_liblist, KW_library, KW_use]), - - ("1364-2001", [KW_automatic, KW_endgenerate, KW_generate, KW_genvar, - KW_localparam, KW_noshowcancelled, KW_pulsestyle_ondetect, + ("1364-2001-noconfig", [KW_automatic, KW_endgenerate, KW_generate, + KW_genvar, KW_localparam, KW_noshowcancelled, KW_pulsestyle_ondetect, KW_pulsestyle_onevent, KW_showcancelled, KW_signed, KW_unsigned]), + ("1364-2001", [KW_cell, KW_config, KW_design, KW_endconfig, KW_incdir, + KW_include, KW_instance, KW_liblist, KW_library, KW_use]), + ("1364-2005", [KW_uwire]), ("1800-2005", [KW_alias, KW_always_comb, KW_always_ff, KW_always_latch, diff --git a/test/keyword/1364-1995.txt b/test/keyword/1364-1995.txt new file mode 100644 index 00000000..052cf5b4 --- /dev/null +++ b/test/keyword/1364-1995.txt @@ -0,0 +1,102 @@ +always +and +assign +begin +buf +bufif0 +bufif1 +case +casex +casez +cmos +deassign +default +defparam +disable +edge +else +end +endcase +endfunction +endmodule +endprimitive +endspecify +endtable +endtask +event +for +force +forever +fork +function +highz0 +highz1 +if +ifnone +initial +inout +input +integer +join +large +macromodule +medium +module +nand +negedge +nmos +nor +not +notif0 +notif1 +or +output +parameter +pmos +posedge +primitive +pull0 +pull1 +pulldown +pullup +rcmos +real +realtime +reg +release +repeat +rnmos +rpmos +rtran +rtranif0 +rtranif1 +scalared +small +specify +specparam +strong0 +strong1 +supply0 +supply1 +table +task +time +tran +tranif0 +tranif1 +tri +tri0 +tri1 +triand +trior +trireg +vectored +wait +wand +weak0 +weak1 +while +wire +wor +xnor +xor diff --git a/test/keyword/1364-2001-noconfig.txt b/test/keyword/1364-2001-noconfig.txt new file mode 100644 index 00000000..c1b81ef4 --- /dev/null +++ b/test/keyword/1364-2001-noconfig.txt @@ -0,0 +1,11 @@ +automatic +endgenerate +generate +genvar +localparam +noshowcancelled +pulsestyle_ondetect +pulsestyle_onevent +showcancelled +signed +unsigned diff --git a/test/keyword/1364-2001.txt b/test/keyword/1364-2001.txt new file mode 100644 index 00000000..7211c8d4 --- /dev/null +++ b/test/keyword/1364-2001.txt @@ -0,0 +1,10 @@ +cell +config +design +endconfig +incdir +include +instance +liblist +library +use diff --git a/test/keyword/1364-2005.txt b/test/keyword/1364-2005.txt new file mode 100644 index 00000000..0e1336c3 --- /dev/null +++ b/test/keyword/1364-2005.txt @@ -0,0 +1 @@ +uwire diff --git a/test/keyword/1800-2005.txt b/test/keyword/1800-2005.txt new file mode 100644 index 00000000..aa92ea3c --- /dev/null +++ b/test/keyword/1800-2005.txt @@ -0,0 +1,97 @@ +alias +always_comb +always_ff +always_latch +assert +assume +before +bind +bins +binsof +bit +break +byte +chandle +class +clocking +const +constraint +context +continue +cover +covergroup +coverpoint +cross +dist +do +endclass +endclocking +endgroup +endinterface +endpackage +endprogram +endproperty +endsequence +enum +expect +export +extends +extern +final +first_match +foreach +forkjoin +iff +ignore_bins +illegal_bins +import +inside +int +interface +intersect +join_any +join_none +local +logic +longint +matches +modport +new +null +package +packed +priority +program +property +protected +pure +rand +randc +randcase +randsequence +ref +return +sequence +shortint +shortreal +solve +static +string +struct +super +tagged +this +throughout +timeprecision +timeunit +type +typedef +union +unique +var +virtual +void +wait_order +wildcard +with +within diff --git a/test/keyword/1800-2009.txt b/test/keyword/1800-2009.txt new file mode 100644 index 00000000..3271b031 --- /dev/null +++ b/test/keyword/1800-2009.txt @@ -0,0 +1,23 @@ +accept_on +checker +endchecker +eventually +global +implies +let +nexttime +reject_on +restrict +s_always +s_eventually +s_nexttime +s_until +s_until_with +strong +sync_accept_on +sync_reject_on +unique0 +until +until_with +untyped +weak diff --git a/test/keyword/1800-2012.txt b/test/keyword/1800-2012.txt new file mode 100644 index 00000000..21dab21a --- /dev/null +++ b/test/keyword/1800-2012.txt @@ -0,0 +1,4 @@ +implements +interconnect +nettype +soft diff --git a/test/keyword/run.sh b/test/keyword/run.sh new file mode 100755 index 00000000..2e2cd358 --- /dev/null +++ b/test/keyword/run.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +VERSIONS=( + 1364-1995 + 1364-2001-noconfig + 1364-2001 + 1364-2005 + 1800-2005 + 1800-2009 + 1800-2012 +) + +testKeyword() { + sv2v_exit_code=$1 + ivl_exit_code=$(($1*2)) + version=$2 + keyword=$3 + + source="\`begin_keywords \"$version\"\nmodule $keyword;endmodule\n\`end_keywords" + + $SV2V <(echo -e "$source") >/dev/null 2>/dev/null + assertTrue "unexpected sv2v exit code $?" "[ $sv2v_exit_code -eq $? ]" + + iverilog -g2012 -o/dev/null <(echo -e "$source") >/dev/null 2>/dev/null + assertTrue "unexpected ivl exit code $?" "[ $ivl_exit_code -eq $? ]" +} + +addTest() { + test="$1_$2_$3" + eval "$test() { testKeyword $1 $2 $3; }" + suite_addTest $test +} + +addTests() { + prev= + for curr in "${VERSIONS[@]}"; do + # This isn't a keyword in prior version. + [ -n "$prev" -a $curr = $version ] && \ + addTest 0 $prev $keyword && \ + break + prev=$curr + done + # This is a keyword in the specified version. + addTest 1 $version $keyword +} + +suite() { + for version in "${VERSIONS[@]}"; do + while read keyword; do + addTests + done < $version.txt + done +} + +source ../lib/functions.sh + +. shunit2 diff --git a/test/lex/begin_keywords.sv b/test/lex/begin_keywords.sv index fded8dc0..678c45fa 100644 --- a/test/lex/begin_keywords.sv +++ b/test/lex/begin_keywords.sv @@ -1,4 +1,4 @@ -`begin_keywords "1364-2001-noconfig" +`begin_keywords "1364-1995" task foo; integer automatic = 2; $display(automatic * automatic); @@ -10,7 +10,14 @@ task automatic bar; endtask `end_keywords `end_keywords +`begin_keywords "1364-2001-noconfig" +task baz; + integer cell = 3; + $display(cell ** cell); +endtask +`end_keywords module top; initial foo; initial bar; + initial baz; endmodule diff --git a/test/lex/begin_keywords.v b/test/lex/begin_keywords.v index 8a301fef..6b270d86 100644 --- a/test/lex/begin_keywords.v +++ b/test/lex/begin_keywords.v @@ -13,6 +13,14 @@ module top; $display(y * y); end endtask + task baz; + integer w; + begin + w = 3; + $display(w ** w); + end + endtask initial foo; initial bar; + initial baz; endmodule