From b61b3814ec0bf3e6efe2c9c96d81935820fcf767 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sun, 11 Dec 2022 19:41:36 -0800 Subject: [PATCH] Add br_gh800 test This is a test for github issue#800. This should work on all platforms, but Windows seems weird. The issue seems to be with Windows comparing gold files with CR-LF weirdly, so make all the tests internal. --- ivtest/ivltests/br_gh800.v | 52 ++++++++++++++++++++++++++++++++++++++ ivtest/regress-sv.list | 1 + 2 files changed, 53 insertions(+) create mode 100644 ivtest/ivltests/br_gh800.v diff --git a/ivtest/ivltests/br_gh800.v b/ivtest/ivltests/br_gh800.v new file mode 100644 index 000000000..685608be3 --- /dev/null +++ b/ivtest/ivltests/br_gh800.v @@ -0,0 +1,52 @@ + +// br_gh800 (github Issue #800) +module AssignLiterals; + initial begin + string s; + + // Note that the \0 in this string literal assigned to the string + // must disappear, leaving "AB" what is actually assigned to the + // string. See IEEE Std 1800-2017: 6.16 String data type. + s = "A\0B"; + $display("1. '%s' len=%1d hex=%02h%02h%02h",s,s.len(), s[0], s[1], s[2]); + if (s.len() != 2 || s != "AB" || s[0] !== 'h41 || s[1] !== 'h42) begin + $display("FAILED"); + $finish; + end + + s = "A\015\12B"; + $display("2. len=%1d hex=%02h%02h%02h%02h",s.len(), s[0], s[1], s[2], s[3]); + if (s.len() != 4 || s[0] !== 'h41 || s[1] !== 'h0d + || s[2] !== 'h0a || s[3] !== 'h42) begin + $display("FAILED"); + $finish; + end + + s = {"A","\015","\012","B"}; + $display("3. len=%1d hex=%02h%02h%02h%02h",s.len(), s[0], s[1], s[2], s[3]); + if (s.len() != 4 || s[0] !== 'h41 || s[1] !== 'h0d + || s[2] !== 'h0a || s[3] !== 'h42) begin + $display("FAILED"); + $finish; + end + + s = "A\170\171B"; + $display("4. '%s' len=%1d hex=%02h%02h%02h%02h",s,s.len(), + s[0], s[1], s[2], s[3]); + if (s.len() != 4 || s[0] !== 'h41 || s[1] !== 'h78 || s[2] !== 'h79 + || s[3] !== 'h42) begin + $display("FAILED"); + $finish; + end + + s = {"A",8'o15,8'o12,"\012","B"}; + $display("5. len=%1d hex=%02h%02h%02h%02h%02h",s.len(), s[0], s[1], s[2], s[3], s[4]); + if (s.len() != 5 || s[0] !== 'h41 || s[1] !== 'h0d + || s[2] !== 'h0a || s[3] !== 'h0a || s[4] !== 'h42) begin + $display("FAILED"); + $finish; + end + + $display("PASSED"); + end +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index a78c4db97..c59386de7 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -228,6 +228,7 @@ br_gh699 CE,-g2009 ivltests br_gh756 normal,-g2009 ivltests br_gh782a normal,-g2009 ivltests gold=br_gh782a.gold br_gh782b normal,-g2009 ivltests gold=br_gh782b.gold +br_gh800 normal,-g2009 ivltests br_gh801 normal,-g2009 ivltests br_gh801b normal,-g2009 ivltests br_ml20171017 normal,-g2009 ivltests