opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[dvsim] Questa uart_smoke failing at tl_agent_pkg load

Open AWHoppe opened this issue 2 years ago • 13 comments

Description

Hi,

While trying to setup launch dvsim with questa for uart_smoke test I get the following in the run log:

** Fatal: (vsim-3373) Range of part-select [-1:2] into 'bus_req.a_addr' [31:0] is reversed. Time: 0 ps Iteration: 0 Region: /tl_agent_pkg::tl_reg_adapter #(tl_agent_pkg::tl_seq_item) File: /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/wanklerh/se-metis/scratch/metis/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_tl_agent_0/tl_reg_adapter.sv Line: 45

The same setup is working with Xcelium as target tool. The build log does not seem to point to anything helpful. The problem seems to be that the tl_reg_adapter class included in tl_agent_pkg does not recognize the parameters defined in the package, e.g. AddrWidth, thus it throws this error.

I am on a local fork of tag Earlgrey-M2.5.2-ROM_RC1. I checked issue #9514 and it seems unrelated but maybe someone can clarify.

Any ideas?

AWHoppe avatar Feb 15 '24 16:02 AWHoppe

Hi there,

I've not got access to a Questa licence so I can't run this locally. But the line this points to is:

            a_addr[AddrWidth-1:2] == rw.addr[AddrWidth-1:2];

I think the message is talking about the left hand side of the comparison, but I doubt it matters. Anyway, if AddrWidth is zero (maybe the default if unset?), this will indeed be [-1:2] which is causing the fatal error.

The AddrWidth value is supposed to come from tl_agent_pkg.sv. It might be worth forcing that to 32 as a local hack to see whether that fixes things. If so, the problem is with bus_params_pkg. If not, you'll have to investigate why the tl_agent_pkg::AddrWidth value isn't visible in tl_reg_adapter.sv.

rswarbrick avatar Feb 16 '24 15:02 rswarbrick

bus_params_pkg is being compiled and presents no errors. The setup works with Xcelium.

The error is in the line you mentioned, however if I, for example, change AddrWidth-1 to 31 it instead complains about the reversed assignment on the RHS of the comparison.

The same happens for the other uses of tl_agent_pkg.sv defined parameters. It's as if the class cannot access the scope of the package it has been included into.

AWHoppe avatar Feb 16 '24 16:02 AWHoppe

Is the bug just that tl_reg_adapter.sv should have a line with import tl_agent_pkg::*; ?

It's possible that I'm just missing something, but I don't think I can see why we expect the contents of tl_agent_pkg to be in scope when evaluating the body of tl_reg_adapter. I'm rather confused, though! Either our code is silly and Xcelium and VCS are being very lax, or I haven't quite understood...

rswarbrick avatar Feb 16 '24 17:02 rswarbrick

If I try importing the package import tl_agent_pkg::*; or using the package scope tl_agent_pkg::AddrWidth to access the parameter, I get an error saying this is not allowed because the package has not been elaborated (understandable).

We are trying to reach Siemens to figure out the issue.

AWHoppe avatar Feb 19 '24 09:02 AWHoppe

As an update, there seemed to be a problem with Questa itself in finding the package parameters in the class. After some help, using local:: scope solved our problem. This forced the tool to search locally.

AWHoppe avatar Feb 28 '24 08:02 AWHoppe

Hello Rupert

As mentioned by my colleague AWHoppe that adding local:: like this a_addr[local::AddrWidth-1:2] == rw.addr[local::AddrWidth-1:2]; did removed the earlier error ** Fatal: (vsim-3373) Range of part-select [-1:2] into 'bus_req.a_addr' [31:0] is reversed.

But several more UVM related errors are generated.

# ** Warning: (vsim-8637) A modport ('mon_tx_mp') should not be used in a hierarchical path.
#    Time: 0 ps  Iteration: 0  Region: /uart_agent_pkg::uart_monitor File: /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/scratch/48-dv-questa-questa-dvsim-run-breaking-at/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_uart_agent_0.1/uart_monitor.sv Line: 49
# ** Warning: (vsim-8637) A modport ('mon_rx_mp') should not be used in a hierarchical path.
#    Time: 0 ps  Iteration: 0  Region: /uart_agent_pkg::uart_monitor File: /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/scratch/48-dv-questa-questa-dvsim-run-breaking-at/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_uart_agent_0.1/uart_monitor.sv Line: 97
# ** Warning: (vsim-8637) A modport ('drv_rx_mp') should not be used in a hierarchical path.
#    Time: 0 ps  Iteration: 0  Region: /uart_agent_pkg::uart_driver File: /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/scratch/48-dv-questa-questa-dvsim-run-breaking-at/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_uart_agent_0.1/uart_driver.sv Line: 73
# Compiling /tmp/farid@dsc007_dpi_3508636/linux_x86_64_gcc-7.4.0/exportwrapper.c
# Loading /tmp/farid@dsc007_dpi_3508636/linux_x86_64_gcc-7.4.0/vsim_auto_compile.so
# do /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/hw/dv/tools/questa/sim.tcl
# 0
# 0
UVM_INFO @ 0 ps: reporter [RNTST] Running test uart_base_test...
** Warning: (vsim-3829) Non-existent associative array entry. Returning default value.
   Time: 0 ps  Iteration: 54  Process: /cip_base_pkg::cip_base_scoreboard #(uart_ral_pkg::uart_reg_block, uart_env_pkg::uart_env_cfg, uart_env_pkg::uart_env_cov)::check_alerts/#FORK#258_7feff077553 File: /home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/scratch/48-dv-questa-questa-dvsim-run-breaking-at/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_cip_lib_0/cip_base_scoreboard.sv Line: 259
** Warning: (vsim-3829) Non-existent associative array entry. Returning default value.
   Time: 16757 ps  Iteration: 2  Process: /cip_base_pkg::cip_base_scoreboard #(uart_ral_pkg::uart_reg_block, uart_env_pkg::uart_env_cfg, uart_env_pkg::uart_env_cov)::check_alerts/#FORK#258_7feff077553 File: 

/home/idsproj01/trusted/projects/TrEB/Design/TReB_ASIC_01/_cad/Digital/user/farid/se-metis/scratch/48-dv-questa-questa-dvsim-run-breaking-at/uart-sim-questa/default/sim-vcs/../src/lowrisc_dv_cip_lib_0/cip_base_scoreboard.sv Line: 259
UVM_ERROR @   2299038 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2332371 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2365704 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2399037 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2432370 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2465703 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2499036 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2532369 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2565702 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2599035 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_ERROR @   2632368 ps: (tlul_assert.sv:314) [ASSERT FAILED] dReadyKnown_A
UVM_INFO @ 223230162 ps: (uart_tx_rx_vseq.sv:114) uvm_test_top.env.virtual_sequencer [uvm_test_top.env.virtual_sequencer.uart_smoke_vseq] finished run 1/2
UVM_INFO @ 5957972814 ps: (uart_tx_rx_vseq.sv:114) uvm_test_top.env.virtual_sequencer [uvm_test_top.env.virtual_sequencer.uart_smoke_vseq] finished run 2/2
UVM_INFO @ 5981372630 ps: (uvm_report_catcher.svh:705) [UVM/REPORT/CATCHER] 

Do you know any potential reason why adding "local::" infront of parameter AddrWidth is necessary while executing with Questa whereas its not an issue with Xcelium?

Do you think Opentitan could be incompatible with Questa?

MuzamilFarid avatar Feb 29 '24 13:02 MuzamilFarid

I think I might understand a bit more about what's going on. The code in question is essentially:

        `DV_CHECK_RANDOMIZE_WITH_FATAL(bus_req,
            a_opcode              == tlul_pkg::Get;
            a_addr[AddrWidth-1:2] == rw.addr[AddrWidth-1:2];
            $countones(a_mask)  dist {MaskWidth       :/ 1,
                                      [0:MaskWidth-1] :/ 1};)

Clearly, we thought that AddrWidth would be in scope in the place it's being evaluated. The logic is that this is really being evaluated deep inside tl_agent_pkg (because tl_reg_adapter.sv gets included there) and so the parameters in the package should be in scope.

Looking at IEEE 1800, section 18.7.1, which explains what the local:: prefix is supposed to do, I don't think I understand why this makes any difference. I think it tells the EDA tool to skip over the "randomize() with class" (which is tl_seq_item here) and to use the current scope instead. The problem is that both of these places should have AddrWidth in scope, pointing at tl_agent_pkg::AddrWidth in both cases.

I'm very happy to tweak the code to work with Questa as well, but this sounds like a tool bug that we're having to work around. Have I misunderstood something?

rswarbrick avatar Feb 29 '24 15:02 rswarbrick

Hi

Thanks for the quick feedback.

I dont know weather its a bug in the tool or the OpenTitan potential incompatibility with Questa.

As a developer of OT, What is your gut feeling about a potential lack of compatibility with vendors other than Xcelium or Vcs?

In your experience is this possible that Questa is building/executing a code differently than Xcelium?

As we are not dealing with a rather simpler design, There is a complex mixture of classes, verification & usage of advance Sv constructs, I dont know if tools action differ when we get to that level of complexity.....

MuzamilFarid avatar Feb 29 '24 21:02 MuzamilFarid

Hi there. I'm afraid I'm not sure. I don't believe that anyone is currently using OpenTitan with Questa (which is why it's broken).

The problem might be that we've messed stuff up, or it might be a bug in Questa. But it doesn't really matter which one: we need to fix/work around things either way. Could you open a PR with a change that fixes things? Ideally, this should have a comment (// This is needed for Questa because... ) to give hints to future readers.

rswarbrick avatar Mar 01 '24 10:03 rswarbrick

Hi Rupert

I will further investigate the issue, it appears you are right either a tool has a bug or OT somehow reflects incompatibility with Questa, Either way a work around is needed.

I will keep you posted.

MuzamilFarid avatar Mar 01 '24 20:03 MuzamilFarid

Hi Rupert I was able to fix the failing UART smoke test, The issue was discussed earlier https://github.com/lowRISC/opentitan/issues/9514 The clocking had to be added t d_ready signal in tl_host_driver.sv after the invalidate_a_channel() is called. All UART tests are passing except uart_stress_all_with_rand_reset test which fails and generates following UVM errors.

            UVM_ERROR @  61831776 ps: (cip_base_scoreboard.sv:222) [uvm_test_top.env.scoreboard] Check failed expected_alert[alert_name].expected == 1 (0 [0x0] vs 1 [0x1]) alert fatal_fault triggered unexpectedly
            UVM_ERROR @  62031774 ps: (cip_base_scoreboard.sv:207) uvm_test_top.env.scoreboard [uvm_test_top.env.scoreboard] alert fatal_fault has unexpected signal int error
            UVM_ERROR @  62065107 ps: (cip_base_scoreboard.sv:207) uvm_test_top.env.scoreboard [uvm_test_top.env.scoreboard] alert fatal_fault has unexpected signal int error
            UVM_ERROR @  62098440 ps: (cip_base_scoreboard.sv:207) uvm_test_top.env.scoreboard [uvm_test_top.env.scoreboard] alert fatal_fault has unexpected signal int error
            UVM_ERROR @  62131773 ps: (cip_base_scoreboard.sv:207) uvm_test_top.env.scoreboard [uvm_test_top.env.scoreboard] alert fatal_fault has unexpected signal int error

Do you have any potential leads how can this be solved?

MuzamilFarid avatar Mar 21 '24 11:03 MuzamilFarid

I think this might not be a Questa problem! Looking at https://reports.opentitan.org/hw/ip/uart/dv/latest/report.html, I think we're not seeing a 100% pass rate for this test in the nightly regression run either.

There's actually an engineer at lowRISC who's looking at this particular test at the moment. (It turns out to be hard!)

rswarbrick avatar Mar 21 '24 12:03 rswarbrick

I believe that the remaining issue was to do with uart_stress_all_with_rand_reset. I think this is probably now fixed, at least for VCS (which we use for nightly regressions). On the last run, 100/100 runs passed: image (Run from 21/4/24)

I'm going to close this issue accordingly because I think all the things it discussed are fixed. Please feel free to re-open if I've missed something, or open a new issue if there's something new.

rswarbrick avatar Apr 23 '24 13:04 rswarbrick