From 918976651af663cc48796e7cf8a42dc373363906 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 6 Jan 2026 23:00:55 -0800 Subject: [PATCH] Fixes for vlog95 generation and gold file updates --- ivtest/gold/br_gh710a-vlog95-vvp-stdout.gold | 1 + ivtest/gold/br_gh710b-vlog95-vvp-stdout.gold | 1 + ivtest/gold/br_gh710c-vlog95-vvp-stdout.gold | 1 + ivtest/gold/sdf_header-vlog95-vvp-stdout.gold | 12 ++++++++++++ ivtest/regress-vlog95.list | 5 +++++ ivtest/regress-vvp.list | 4 ++-- ivtest/run_ivl.py | 11 ++++++----- ivtest/vvp_tests/br_gh1074a.json | 6 +++++- ivtest/vvp_tests/br_gh1074b.json | 6 +++++- ivtest/vvp_tests/br_gh710a.json | 6 +++++- ivtest/vvp_tests/br_gh710b.json | 6 +++++- ivtest/vvp_tests/br_gh710c.json | 6 +++++- ivtest/vvp_tests/localparam_type-vlog95.json | 8 -------- ivtest/vvp_tests/localparam_type.json | 3 +++ ivtest/vvp_tests/parameter_type-vlog95.json | 8 -------- ivtest/vvp_tests/parameter_type.json | 3 +++ ivtest/vvp_tests/sdf_header.json | 5 ++++- ivtest/vvp_tests/sv_2state_array_init_prop.json | 6 +++++- tgt-vlog95/numbers.c | 15 +++++++++++++-- 19 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 ivtest/gold/br_gh710a-vlog95-vvp-stdout.gold create mode 100644 ivtest/gold/br_gh710b-vlog95-vvp-stdout.gold create mode 100644 ivtest/gold/br_gh710c-vlog95-vvp-stdout.gold create mode 100644 ivtest/gold/sdf_header-vlog95-vvp-stdout.gold delete mode 100644 ivtest/vvp_tests/localparam_type-vlog95.json delete mode 100644 ivtest/vvp_tests/parameter_type-vlog95.json diff --git a/ivtest/gold/br_gh710a-vlog95-vvp-stdout.gold b/ivtest/gold/br_gh710a-vlog95-vvp-stdout.gold new file mode 100644 index 000000000..3627cd939 --- /dev/null +++ b/ivtest/gold/br_gh710a-vlog95-vvp-stdout.gold @@ -0,0 +1 @@ +VCD info: dumpfile dump.vcd opened for output. diff --git a/ivtest/gold/br_gh710b-vlog95-vvp-stdout.gold b/ivtest/gold/br_gh710b-vlog95-vvp-stdout.gold new file mode 100644 index 000000000..c7c63b826 --- /dev/null +++ b/ivtest/gold/br_gh710b-vlog95-vvp-stdout.gold @@ -0,0 +1 @@ +LXT info: dumpfile dump.lxt opened for output. diff --git a/ivtest/gold/br_gh710c-vlog95-vvp-stdout.gold b/ivtest/gold/br_gh710c-vlog95-vvp-stdout.gold new file mode 100644 index 000000000..28c086d9c --- /dev/null +++ b/ivtest/gold/br_gh710c-vlog95-vvp-stdout.gold @@ -0,0 +1 @@ +LXT2 info: dumpfile dump.lx2 opened for output. diff --git a/ivtest/gold/sdf_header-vlog95-vvp-stdout.gold b/ivtest/gold/sdf_header-vlog95-vvp-stdout.gold new file mode 100644 index 000000000..12f3f8333 --- /dev/null +++ b/ivtest/gold/sdf_header-vlog95-vvp-stdout.gold @@ -0,0 +1,12 @@ +SDF INFO: Loading ivltests/sdf_header.sdf from work/vlog95.v:11 +SDF INFO: ivltests/sdf_header.sdf:2: Version: 3.0 +SDF INFO: ivltests/sdf_header.sdf:3: Design: test +SDF INFO: ivltests/sdf_header.sdf:4: Date: Wed Mar 8 12:34:56 2023 +SDF INFO: ivltests/sdf_header.sdf:5: Vendor: No Vendor +SDF INFO: ivltests/sdf_header.sdf:6: Program: Human +SDF INFO: ivltests/sdf_header.sdf:7: Program Version: 1.0.0 +SDF INFO: ivltests/sdf_header.sdf:8: Divider: "/" +SDF INFO: ivltests/sdf_header.sdf:9: Voltage: 5.000000 +SDF INFO: ivltests/sdf_header.sdf:10: Process: best=0.65:nom=1.0:worst=1.8 +SDF INFO: ivltests/sdf_header.sdf:11: Temperature: 25.000000 +SDF INFO: ivltests/sdf_header.sdf:12: Timescale: 1ps diff --git a/ivtest/regress-vlog95.list b/ivtest/regress-vlog95.list index ff21499c6..3f82374c8 100644 --- a/ivtest/regress-vlog95.list +++ b/ivtest/regress-vlog95.list @@ -1110,3 +1110,8 @@ case_unique normal,-g2009 ivltests gold=case_unique-vlog95.gold # An error is reported for both compiler passes br_gh377 normal,-Ptest.name= ivltests gold=br_gh377-vlog95.gold + +# When the work was done to support timing checks this caused multiple +# names for a single nexus so this test now fails. This needs to be fixed +# or the code needs to be reworked. +pr1520314 NI diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index aef0a53f0..1151f4658 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -35,8 +35,8 @@ br_gh939 vvp_tests/br_gh939.json br_gh1001 vvp_tests/br_gh1001.json br_gh1018 vvp_tests/br_gh1018.json br_gh1029 vvp_tests/br_gh1029.json -br_gh1075a vvp_tests/br_gh1074a.json -br_gh1075b vvp_tests/br_gh1074b.json +br_gh1074a vvp_tests/br_gh1074a.json +br_gh1074b vvp_tests/br_gh1074b.json br_gh1087a1 vvp_tests/br_gh1087a1.json br_gh1087a2 vvp_tests/br_gh1087a2.json br_gh1087a3 vvp_tests/br_gh1087a3.json diff --git a/ivtest/run_ivl.py b/ivtest/run_ivl.py index 57e4419df..a8a3ab605 100644 --- a/ivtest/run_ivl.py +++ b/ivtest/run_ivl.py @@ -116,8 +116,8 @@ def compare_files(log_path, gold_path): if a != b: # pylint: disable-next=consider-using-f-string - print("{log} and {gold} differ:".format(log=log_path, gold=gold_path)) - sys.stdout.writelines(difflib.unified_diff(a, b, log_path, gold_path)) + print("{gold} and {log} differ:".format(gold=gold_path,log=log_path)) + sys.stdout.writelines(difflib.unified_diff(b, a, gold_path, log_path)) return False return True @@ -243,9 +243,7 @@ def do_run_normal(options: dict, cfg: dict, expected_fail: bool, # Run the vlog95 translation if needed. if cfg['vlog95']: - options['iverilog_args'].append("-tvlog95") - options['iverilog_args'].append("-pfileline=1") - options['iverilog_args'].append("-pspacing=4") + options['iverilog_args'].extend(["-tvlog95", "-pfileline=1", "-pspacing=4"]) ivl_tcmd = assemble_iverilog_cmd(options, cfg, 'vlog95.v') ivl_tres = run_cmd(ivl_tcmd) @@ -253,10 +251,13 @@ def do_run_normal(options: dict, cfg: dict, expected_fail: bool, if ivl_tres.returncode != 0: return [1, "Failed - vlog95 translation failed."] + enable_specify = "-gspecify" in options['iverilog_args'] if "-pallowsigned=1" in options['iverilog_args']: options['iverilog_args'] = [ "-g2001-noconfig" ] else: options['iverilog_args'] = [ "-g1995" ] + if enable_specify: + options['iverilog_args'].append("-gspecify") options['source'] = os.path.join("work", "vlog95.v") # Run the iverilog command diff --git a/ivtest/vvp_tests/br_gh1074a.json b/ivtest/vvp_tests/br_gh1074a.json index 667d5cc28..87e7ee1f0 100644 --- a/ivtest/vvp_tests/br_gh1074a.json +++ b/ivtest/vvp_tests/br_gh1074a.json @@ -1,5 +1,9 @@ { "type" : "normal", "source" : "br_gh1074a.v", - "iverilog-args" : [ "-g2009" ] + "iverilog-args" : [ "-g2009" ], + "vlog95" : { + "__comment" : "two-state variables are not supported", + "type" : "EF" + } } diff --git a/ivtest/vvp_tests/br_gh1074b.json b/ivtest/vvp_tests/br_gh1074b.json index c2c9ab4c8..7f36f5515 100644 --- a/ivtest/vvp_tests/br_gh1074b.json +++ b/ivtest/vvp_tests/br_gh1074b.json @@ -1,5 +1,9 @@ { "type" : "normal", "source" : "br_gh1074b.v", - "iverilog-args" : [ "-g2009" ] + "iverilog-args" : [ "-g2009" ], + "vlog95" : { + "__comment" : "two-state variables are not supported", + "type" : "EF" + } } diff --git a/ivtest/vvp_tests/br_gh710a.json b/ivtest/vvp_tests/br_gh710a.json index b22dc50fb..2dd77515e 100644 --- a/ivtest/vvp_tests/br_gh710a.json +++ b/ivtest/vvp_tests/br_gh710a.json @@ -3,5 +3,9 @@ "source" : "br_gh710.v", "gold" : "br_gh710a", "iverilog-args" : [ "-g2009" ], - "vvp-args-extended" : [ "-vcd" ] + "vvp-args-extended" : [ "-vcd" ], + "vlog95" : { + "__comment" : "packages are translated to modules that can be dumped", + "gold" : "br_gh710a-vlog95" + } } diff --git a/ivtest/vvp_tests/br_gh710b.json b/ivtest/vvp_tests/br_gh710b.json index 2d77b17bb..1b875560f 100644 --- a/ivtest/vvp_tests/br_gh710b.json +++ b/ivtest/vvp_tests/br_gh710b.json @@ -3,5 +3,9 @@ "source" : "br_gh710.v", "gold" : "br_gh710b", "iverilog-args" : [ "-g2009" ], - "vvp-args-extended" : [ "-lxt" ] + "vvp-args-extended" : [ "-lxt" ], + "vlog95" : { + "__comment" : "packages are translated to modules that can be dumped", + "gold" : "br_gh710b-vlog95" + } } diff --git a/ivtest/vvp_tests/br_gh710c.json b/ivtest/vvp_tests/br_gh710c.json index d8798e72f..1ca468d1e 100644 --- a/ivtest/vvp_tests/br_gh710c.json +++ b/ivtest/vvp_tests/br_gh710c.json @@ -3,5 +3,9 @@ "source" : "br_gh710.v", "gold" : "br_gh710c", "iverilog-args" : [ "-g2009" ], - "vvp-args-extended" : [ "-lxt2" ] + "vvp-args-extended" : [ "-lxt2" ], + "vlog95" : { + "__comment" : "packages are translated to modules that can be dumped", + "gold" : "br_gh710c-vlog95" + } } diff --git a/ivtest/vvp_tests/localparam_type-vlog95.json b/ivtest/vvp_tests/localparam_type-vlog95.json deleted file mode 100644 index b66958b3f..000000000 --- a/ivtest/vvp_tests/localparam_type-vlog95.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type" : "normal-vlog95", - "source" : "localparam_type.v", - "gold" : "parameter_type-vlog95", - "strict" : { - "gold" : "parameter_type-vlog95_std" - } -} diff --git a/ivtest/vvp_tests/localparam_type.json b/ivtest/vvp_tests/localparam_type.json index 4b777ff98..5e596aaf6 100644 --- a/ivtest/vvp_tests/localparam_type.json +++ b/ivtest/vvp_tests/localparam_type.json @@ -4,5 +4,8 @@ "gold" : "parameter_type", "strict" : { "gold" : "parameter_type_std" + }, + "vlog95" : { + "iverilog-args" : [ "-pallowsigned=1" ] } } diff --git a/ivtest/vvp_tests/parameter_type-vlog95.json b/ivtest/vvp_tests/parameter_type-vlog95.json deleted file mode 100644 index cc465e59a..000000000 --- a/ivtest/vvp_tests/parameter_type-vlog95.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "type" : "normal-vlog95", - "source" : "parameter_type.v", - "gold" : "parameter_type-vlog95", - "strict" : { - "gold" : "parameter_type-vlog95_std" - } -} diff --git a/ivtest/vvp_tests/parameter_type.json b/ivtest/vvp_tests/parameter_type.json index fe0793c19..0859d8abd 100644 --- a/ivtest/vvp_tests/parameter_type.json +++ b/ivtest/vvp_tests/parameter_type.json @@ -4,5 +4,8 @@ "gold" : "parameter_type", "strict" : { "gold" : "parameter_type_std" + }, + "vlog95" : { + "iverilog-args" : [ "-pallowsigned=1" ] } } diff --git a/ivtest/vvp_tests/sdf_header.json b/ivtest/vvp_tests/sdf_header.json index 0a0698951..57d78cf3b 100644 --- a/ivtest/vvp_tests/sdf_header.json +++ b/ivtest/vvp_tests/sdf_header.json @@ -3,5 +3,8 @@ "source" : "sdf_header.v", "gold" : "sdf_header", "iverilog-args" : [ "-gspecify" ], - "vvp-args-extended" : [ "-sdf-verbose" ] + "vvp-args-extended" : [ "-sdf-verbose" ], + "vlog95" : { + "gold" : "sdf_header-vlog95" + } } diff --git a/ivtest/vvp_tests/sv_2state_array_init_prop.json b/ivtest/vvp_tests/sv_2state_array_init_prop.json index b7dc4c08b..1b5df07be 100644 --- a/ivtest/vvp_tests/sv_2state_array_init_prop.json +++ b/ivtest/vvp_tests/sv_2state_array_init_prop.json @@ -1,5 +1,9 @@ { "type" : "normal", "source" : "sv_2state_array_init_prop.v", - "iverilog-args" : [ "-g2005-sv" ] + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "two-state variables are not supported", + "type" : "EF" + } } diff --git a/tgt-vlog95/numbers.c b/tgt-vlog95/numbers.c index 5dee05a00..776424b54 100644 --- a/tgt-vlog95/numbers.c +++ b/tgt-vlog95/numbers.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2021 Cary R. (cygcary@yahoo.com) + * Copyright (C) 2011-2026 Cary R. (cygcary@yahoo.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -68,6 +68,7 @@ static int32_t get_int32_from_bits(const char *bits, unsigned nbits, value |= ~(((uint32_t)1 << trim_wid) - (uint32_t)1); } *result_type = 0; + if ((msb == 'x') || (msb == 'z')) *result_type = -1; return value; } @@ -136,7 +137,17 @@ void emit_number(const char *bits, unsigned nbits, unsigned is_signed, int rtype; int32_t value = get_int32_from_bits(bits, nbits, 1, &rtype); if (rtype != 0) emit_bits(bits, nbits, is_signed); - else fprintf(vlog_out, "%"PRId32, value); + else { + /* Limit the size of the decimal value if needed. */ + if (nbits < 32U) { + if (value < 0) { + value *= -1; + fprintf(vlog_out, "-"); + } + fprintf(vlog_out, "%u'sd", nbits); + } + fprintf(vlog_out, "%"PRId32, value); + } /* Otherwise a signed value can only be 32 bits long since it can * only be represented as an integer. We can trim any matching MSB * bits to make it fit. We cannot support individual undefined