From 1a073fbf5ea543cef40dacacd24936b29d8d1abd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 2 Jan 2021 22:00:13 -0500 Subject: [PATCH] Fix vpiLeftRange on little-endian memories (#2696). --- Changes | 2 ++ src/V3EmitCSyms.cpp | 4 ++-- test_regress/t/t_vpi_var.cpp | 19 +++++++++++++++++++ test_regress/t/t_vpi_var.v | 4 +++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 28fc047ca..3011c1d70 100644 --- a/Changes +++ b/Changes @@ -27,6 +27,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix genblk naming to match IEEE (#2686). [tinshark] +**** Fix vpiLeftRange on little-endian memories (#2696). [Marlon James] + **** Fix vpi_release_handle to be called implicitly per IEEE (#2706). **** Fix tracing empty sc module (#2729). diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 65fc9970a..d6392ef64 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -773,9 +773,9 @@ void EmitCSyms::emitSymImp() { = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node if (const AstNodeArrayDType* adtypep = VN_CAST(dtypep, NodeArrayDType)) { bounds += " ,"; - bounds += cvtToStr(adtypep->hi()); + bounds += cvtToStr(adtypep->left()); bounds += ","; - bounds += cvtToStr(adtypep->lo()); + bounds += cvtToStr(adtypep->right()); if (VN_IS(dtypep, PackArrayDType)) { pdim++; } else { diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index cf948643b..b8af76d23 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -327,6 +327,25 @@ int _mon_check_var() { CHECK_RESULT_CSTR(p, "vpiConstant"); } + TestVpiHandle vh5 = VPI_HANDLE("quads"); + CHECK_RESULT_NZ(vh5); + { + TestVpiHandle vh10 = vpi_handle(vpiLeftRange, vh5); + CHECK_RESULT_NZ(vh10); + vpi_get_value(vh10, &tmpValue); + CHECK_RESULT(tmpValue.value.integer, 2); + p = vpi_get_str(vpiType, vh10); + CHECK_RESULT_CSTR(p, "vpiConstant"); + } + { + TestVpiHandle vh10 = vpi_handle(vpiRightRange, vh5); + CHECK_RESULT_NZ(vh10); + vpi_get_value(vh10, &tmpValue); + CHECK_RESULT(tmpValue.value.integer, 3); + p = vpi_get_str(vpiType, vh10); + CHECK_RESULT_CSTR(p, "vpiConstant"); + } + return 0; } diff --git a/test_regress/t/t_vpi_var.v b/test_regress/t/t_vpi_var.v index 34b94b34e..89160dc60 100644 --- a/test_regress/t/t_vpi_var.v +++ b/test_regress/t/t_vpi_var.v @@ -29,7 +29,9 @@ extern "C" int mon_check(); reg [2:1] twoone /*verilator public_flat_rw @(posedge clk) */; reg [2:1] fourthreetwoone[4:3] /*verilator public_flat_rw @(posedge clk) */; - reg [61:0] quads[3:2] /*verilator public_flat_rw @(posedge clk) */; + // verilator lint_off LITENDIAN + reg [0:61] quads[2:3] /*verilator public_flat_rw @(posedge clk) */; + // verilator lint_on LITENDIAN reg [31:0] count /*verilator public_flat_rd */; reg [31:0] half_count /*verilator public_flat_rd */;