From d2ac403415cdfb5de8fba805893cbc2b2a3dc96a Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 5 Mar 2022 17:37:01 -0800 Subject: [PATCH] Add sv_string7 and sv_stting7b tests. These test string assignments of various escaped special characters. --- ivtest/ivltests/sv_string7.v | 45 ++++++++++++++++++++++++++++++++++ ivtest/ivltests/sv_string7b.v | 46 +++++++++++++++++++++++++++++++++++ ivtest/regress-sv.list | 2 ++ 3 files changed, 93 insertions(+) create mode 100644 ivtest/ivltests/sv_string7.v create mode 100644 ivtest/ivltests/sv_string7b.v diff --git a/ivtest/ivltests/sv_string7.v b/ivtest/ivltests/sv_string7.v new file mode 100644 index 000000000..eec33c63c --- /dev/null +++ b/ivtest/ivltests/sv_string7.v @@ -0,0 +1,45 @@ + +module main; + + string foo; + int error_count; + + task check_char(input int idx, input [7:0] val); + if (foo[idx] !== val) begin + $display("FAILED: foo[%0d]==%02h, expecting %02h", + idx, foo[idx], val); + error_count = error_count+1; + end + endtask // check_char + + initial begin + // These are the special charasters in strings as defined by + // IEEE Std 1800-2017: 5.9.1 Special characters in strings. + // The string assignment is governed by: + // IEEE Std 1800-2017: 6.16 String data type + foo = "abc\n\t\\\"\v\f\a\001\002\x03\x04"; + error_count = 0; + + check_char(0, 8'h61); // 'a' + check_char(1, 8'h62); // 'b' + check_char(2, 8'h63); // 'c' + check_char(3, 8'h0a); // '\n' + check_char(4, 8'h09); // '\t' + check_char(5, 8'h5c); // '\\' + check_char(6, 8'h22); // '\"' + check_char(7, 8'h0b); // '\v' + check_char(8, 8'h0c); // '\f' + check_char(9, 8'h07); // '\a' + check_char(10, 8'h01); // '\001' + check_char(11, 8'h02); // '\002' + check_char(12, 8'h03); // '\x03' + check_char(13, 8'h04); // '\x04' + + if (foo.len() !== 14) begin + $display("FAILED: foo.len() == %0d, should be 14", foo.len()); + error_count = error_count+1; + end + + if (error_count == 0) $display("PASSED"); + end +endmodule // main diff --git a/ivtest/ivltests/sv_string7b.v b/ivtest/ivltests/sv_string7b.v new file mode 100644 index 000000000..abb95128e --- /dev/null +++ b/ivtest/ivltests/sv_string7b.v @@ -0,0 +1,46 @@ + +module main; + + string foo; + int error_count; + + task check_char(input int idx, input [7:0] val); + if (foo[idx] !== val) begin + $display("FAILED: foo[%0d]==%02h, expecting %02h", + idx, foo[idx], val); + error_count = error_count+1; + end + endtask // check_char + + initial begin + // These are the special charasters in strings as defined by + // IEEE Std 1800-2017: 5.9.1 Special characters in strings. + // The string assignment is governed by: + // IEEE Std 1800-2017: 6.16 String data type + foo = "abc"; + foo = {foo, "\n\t\\\"\v\f\a\001\002\x03\x04"}; + error_count = 0; + + check_char(0, 8'h61); // 'a' + check_char(1, 8'h62); // 'b' + check_char(2, 8'h63); // 'c' + check_char(3, 8'h0a); // '\n' + check_char(4, 8'h09); // '\t' + check_char(5, 8'h5c); // '\\' + check_char(6, 8'h22); // '\"' + check_char(7, 8'h0b); // '\v' + check_char(8, 8'h0c); // '\f' + check_char(9, 8'h07); // '\a' + check_char(10, 8'h01); // '\001' + check_char(11, 8'h02); // '\002' + check_char(12, 8'h03); // '\x03' + check_char(13, 8'h04); // '\x04' + + if (foo.len() !== 14) begin + $display("FAILED: foo.len() == %0d, should be 14", foo.len()); + error_count = error_count+1; + end + + if (error_count == 0) $display("PASSED"); + end +endmodule // main diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index d6f190e08..601647f8c 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -530,6 +530,8 @@ sv_string3 normal,-g2009 ivltests sv_string4 normal,-g2009 ivltests sv_string5 normal,-g2009 ivltests sv_string6 normal,-g2009 ivltests +sv_string7 normal,-g2009 ivltests +sv_string7b normal,-g2009 ivltests sv_timeunit_prec1 normal,-g2005-sv ivltests sv_timeunit_prec2 normal,-g2009 ivltests sv_timeunit_prec3a normal,-g2005-sv ivltests gold=sv_timeunit_prec3a.gold