8000 Support Questa qrun/QIS flow by imphil · Pull Request #3306 · cocotb/cocotb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support Questa qrun/QIS flow #3306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

imphil
Copy link
Member
@imphil imphil commented May 14, 2023

Support the qrun/QIS flow in Questa in the Makefile flow

Closes #4364.

v2 from #3274:

  • Default to the new flow from Questa 2023.1 on (the first version which includes Visualizer and hence is guaranteed to work with the flow)
  • Give users the option to choose the old or the new flow by using SIM=questa-qrun or SIM=questa-compat.
  • More documentation updates.
  • Implement the Questa version detection in Python to avoid adding a dependency to awk and sed.

@AbdouTharwat I kept the original commit attributed to you, since you did the majority of the work. Thank you for it! Can you please have a look and give it a try?

Patches:

  • Support the Questa qrun flow
  • Questa: Remove unnecessary FLI library check
  • Add minimal documentation for the custom qrun flow

TODOs:

  • Implement qisqrun logic in runner.
  • Fix VHDL+FLI failures (or disable the tests)

@imphil imphil requested a review from a team May 14, 2023 14:54
@imphil
Copy link
Member Author
imphil commented May 14, 2023

If we're OK with the flow in general I'll add the same commands to the runner as well (probably in a separate PR).

@AbdouTharwat
Copy link

@imphil Yeah sure, thanks for you efforts. I am looking into this and testing it now, I will update you once I am done

@ktbarrett
Copy link
Member

Needs a newsfragment.

@AbdouTharwat
Copy link

Thanks for your efforts @imphil, It is working well, the info messages also are great and keep the user aware of the changes done. also variables names looks better now. We are OK with this, you can go head. Thanks

Copy link
Member
@ktbarrett ktbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. After the newsfragment of course.

@AbdouTharwat
Copy link
AbdouTharwat commented May 18, 2023

Sorry, can we add the python architecture check again to Makefile.questa-qrun, I assumed user will point to only one binary and forgot the case when user has both 32 and 64 binaries in same path, this should not impact anything else.
it will only be adding these 3 lines just before the line 121 starting with: $(COCOTB_RESULTS_FILE):
ifeq ($(PYTHON_ARCH),64bit)
QRUN_CMD += -64
endif

Thanks,

@imphil imphil force-pushed the questa-qrun-imphil branch from b3b508c to 01fb79f Compare May 19, 2023 21:12
@imphil
Copy link
Member Author
imphil commented May 19, 2023

Updated to include the 64b switch as proposed as well as a newsfragment. I'll wait with merging until we have Questa 2023 in CI (currently blocked for unrelated test failures).

@imphil imphil force-pushed the questa-qrun-imphil branch from 01fb79f to e0e12dc Compare May 22, 2023 14:54
@imphil
Copy link
Member Author
imphil commented May 22, 2023

OK, we now got Questa 2023.2 in CI, together with Questa 2022.4. All tests pass with 2022.4 using the +acc old flow. Unfortunately, a number of tests fail with the new QIS/Qrun flow:

Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_read_write' with parameters 'all'
Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_discover_all' with parameters 'all'
Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_direct_constant_indexing' with parameters 'all'
Failure in testsuite: 'all' classname: 'test_iteration' testcase: 'recursive_discovery' with parameters 'all'

The failures look on first sight like differences in signal visibility due to the QIS flow.

@AbdouTharwat Can you reproduce these test failures with this PR? You should get the same failures if you run the tests against Questa 2023.2, as described at https://github.com/cocotb/cocotb/blob/master/CONTRIBUTING.md#running-tests-locally.

I can try to piece together steps to reproduce these failures and file an issue with Siemens, but you're probably in a much better position to do so. Let me know if you need further input from my side.

@imphil imphil added the status:blocked further progress is blocked by a dependency, e.g. other code which must be commited first. label May 22, 2023
@AbdouTharwat
Copy link

Thanks @imphil, I have reproduced these 4 test failures and filed an issue. We are now looking into this

@ktbarrett
Copy link
Member

So what can we do for now to get this in for 1.8? Do we add conditionals for both version and whether the qrun mode is used? We can only really detect if we are using qrun if use the environment variable, but perhaps that's fine here since this is a part of the regression where we are only using makefiles (for now).

@ktbarrett ktbarrett added this to the 1.8.0 milestone May 31, 2023
@imphil
Copy link
Member Author
imphil commented May 31, 2023

I'd just leave this out of 1.8, we're not ready yet to move users over to the new flow without regressions. Users can still use the older flow until we understand the regressions better.

@ktbarrett ktbarrett removed this from the 1.8.0 milestone May 31, 2023
@AbdouTharwat
Copy link
AbdouTharwat commented Jun 22, 2023

Hello @imphil, after having a look on the failures you mentioned I have some observations:

in test_iteration_verilog --> testcase: recursive_discovery

  • test_iteration_es.py line 40: states that vpiAlways does not show, and thus removed from pass_total to be 259 instead of 265
  • acc flow: Found a total of 259
  • QIS flow: Found a total of 265
  • Which means QIS flow now has correct result, do you agree?

in test_iteration_mixedlang --> testcase: recursive_discovery

  • test_iteration.py line 75: states that vpiAlways does not show, and thus removed from pass_total to be 991 instead of 1024
  • acc flow: Found a total of 991
  • QIS flow: Found a total of 1024
  • Which means QIS flow now has correct result, do you agree?

in test_iteration_vhdl (FLI) --> testcase: recursive_discovery

  • test_iteration_es.py line 44: states that FLI starting 2023.1 does not discover certain objects, thus removed from pass_total to be 34553 instead of 34569
  • acc flow: Found a total of 34553
  • QIS flow: Found a total of 34569
  • Which means QIS flow now has correct result, do you agree?

in test_array --> testcase: recursive_discovery

  • QIS flow found 17 more objects due to vpiAlways is now shown, is this expected?

We are investigating other issues of:

  • FLI with test_array --> testcase test_read_write and test_discover_all
  • VHPI with test_iteration_vhdl (VHPI) --> testcase: recursive_discovery

@ktbarrett
Copy link
Member

Why are we even trying to discover always, initial, and function blocks?

@imphil imphil force-pushed the questa-qrun-imphil branch from e0e12dc to c9d729c Compare June 28, 2023 20:45
@imphil imphil requested a review from ktbarrett June 28, 2023 20:45
@imphil
Copy link
Member Author
imphil commented Jun 28, 2023

@AbdouTharwat Thanks for looking into the fails, much appreciated!

I pushed a number of commits to address some of the issues that you found plus a couple more, most notably:

  • Wrong handling of include multiple Verilog include directories. That's fixed.
  • Multi-library VHDL tests were disabled due to the renaming of the SIM variable. Re-enable them.
  • I updated the test expectations to address the newly visible vpiAlways blocks that you pointed out, plus some more.

TODOs:

  • Re-enabling the VHDL library tests uncovere missing functionality in the QIS/Qrun makefile: the make_lib part in the questa-compat makefile. This makes tests/test_cases/test_vhdl_libraries_multiple fail.
  • As you noted, there are some tests still not matching the expectations. Let me know if you have updates on those and I'll try to incorporate them.

@imphil
Copy link
Member Author
imphil commented Jun 28, 2023

Why are we even trying to discover always, initial, and function blocks?

History, I guess :-) I don't think we have much use for these blocks ultimately.

@imphil imphil force-pushed the questa-qrun-imphil branch 2 times, most recently from 44809a3 to 9f06918 Compare June 28, 2023 21:33
@imphil
Copy link
Member Author
imphil commented Jun 29, 2023

I looked at the runs and that's what I'm getting with the QIS/Qrun flow with Questa 2023.2:

VHDL-VHPI

  • Failure in testsuite: 'all' classname: 'test_iteration' testcase: 'recursive_discovery' with parameters 'all':
    AssertionError: assert 66960 == 66959

VHDL-FLI

  • Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_read_write' with parameters 'all'
    AttributeError: param_rec contains no object named a
  • Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_discover_all' with parameters 'all'
    AssertionError: assert 822 == 856
  • Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_direct_constant_indexing' with parameters 'all'
    AttributeError: param_rec contains no object named a

Verilog-VPI

  • Failure in testsuite: 'all' classname: 'test_array' testcase: 'test_discover_all' with parameters 'all'
    AssertionError: assert 1095 == 1078
  • Failure in testsuite: 'all' classname: 'test_cocotb_array' testcase: 'test_in_vect_packed_packed_unpacked' with parameters 'all'
    test_in_vect_packed_packed_unpacked failed: passed but we expected an error
  • Failure in testsuite: 'all' classname: 'test_cocotb_array' testcase: 'test_in_arr_packed_unpacked' with parameters 'all'
    test_in_arr_packed_unpacked failed: passed but we expected an error
  • Failure in testsuite: 'all' classname: 'test_cocotb_array' testcase: 'test_in_2d_arr_unpacked' with parameters 'all'
    test_in_2d_arr_unpacked failed: passed but we expected an error

@AbdouTharwat
Copy link

Hi @imphil,

Regarding the VPI tests, there are some observations:

test_array

  • QIS flow found 1095 instead of 1078 objects, comparing both transcripts the extra 17 objects found by QIS are due to vpiAlways here is the output of those extra objects:

50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[20].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[16].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[17].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[18].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[19].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[21].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[22].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.asc_gen[23].#ALWAYS#182) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[0].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[1].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[2].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[3].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[4].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[5].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[6].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.desc_gen[7].#ALWAYS#195) (GPI_MODULE)
50.00ns INFO cocotb.test ------Found HierarchyObject(array_module.#ALWAYS#111) (GPI_MODULE)

Reviewing analog_module.sv we find:

  1. line 182 has generate block with always statement indexing from 16 to 23
  2. line 195 has generate block with always statement indexing from 7 to 0
  3. line 111 has always statement

In conclusion it appears that QIS shows objects that were not shown by old flow but are correct as shown above

test_cocotb_array

the test was run with LOG_LEVEL DEBUG and for the 3 mentioned tests test_in_vect_packed_packed_unpacked, test_in_arr_packed_unpacked, and test_in_2d_arr_unpacked it appears that old flow failed to find handle for those while new QIS flow succeeded. I am attaching the debug log for the 3 tests both in QIS flow and +acc flow so you can have a look
vpi QIS.txt
vpi +acc.txt

Reviewing the test_cocotb_array.py file we find 3 comments at lines 85, 125, 154 stating that Questa is unable to access elements of a logic array if the last dimension is unpacked (gh-2605) which means it is an open issue and it appears to be solved with new QIS flow

In conclusion it appears that these tests were failing earlier but works well with QIS flow. So they should be modified now that QIS flow is able to access those elements, do you agree?

Finally regarding FLI and VHPI failures, we already opened issues for those and are being investigated, so we are on track.
Are there any failures other than those that we are tracking?

Thanks,

@ktbarrett
Copy link
Member

@AbdouTharwat I'm going to fix #3353 then this back and forth should be moot.

@sirgajelot
Copy link

What happened to this PR? I'd quite like to use this flow and it looks as though it never got merged

@ktbarrett
Copy link
Member

@sirgajelot Looks like it was blocked by another PR that was never merged. That other PR was blocked because it requires restructuring code in the GPI which is a PITA and is not my current focus since I'm working on cocotb 2.0, which is mostly Python API changes.

@sirgajelot
Copy link

Am I right that it works ok with purely Verilog / SystemVerilog designs? I found that it produced identical results to my Modelsim runs when using this branch

@ktbarrett
Copy link
Member

If it works, feel free to use it; everything is BSD licensed. There is nothing conceptual wrong with the change, so it will eventually make it in.

Copy link
codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.17%. Comparing base (2aa4957) to head (0c3f1f0).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3306       +/-   ##
===========================================
- Coverage   77.31%   67.17%   -10.14%     
===========================================
  Files          53       53               
  Lines        8286     8262       -24     
  Branches     2026     2007       -19     
===========================================
- Hits         6406     5550      -856     
- Misses       1410     2286      +876     
+ Partials      470      426       -44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@imphil imphil force-pushed the questa-qrun-imphil branch from 19d4e7a to 89ee6d9 Compare December 27, 2024 12:25
@imphil imphil force-pushed the questa-qrun-imphil branch from 89ee6d9 to 23543a9 Compare February 2, 2025 17:36
@ktbarrett ktbarrett added this to the 2.0 milestone Feb 23, 2025
@ktbarrett ktbarrett modified the milestones: 2.0, 2.1 Mar 18, 2025
@imphil imphil force-pushed the questa-qrun-imphil branch from 23543a9 to 0c3f1f0 Compare March 24, 2025 19:44
@imphil imphil force-pushed the questa-qrun-imphil branch 4 times, most recently from ea4a390 to 070ecc4 Compare May 6, 2025 00:34
@imphil imphil modified the milestones: 2.1, 2.0 May 6, 2025
@imphil imphil removed the status:blocked further progress is blocked by a dependency, e.g. other code which must be commited first. label May 6, 2025
imphil and others added 2 commits May 7, 2025 15:38
questa_fli is only active if we're in a VHDL design; add the missing
condition. Also refactor the code slightly for consistency
Updated Makefile for Questa simulator to use the new flow QIS and qrun
instead of +acc and vlog/vsim respectively.
Also using Visualizer instead of the classic GUI for Live simulation
and adding option for Visualizer post simulation mode
By Default Questa runs in batch mode, to enable Live SIM mode set
GUI=livesim, to enable Post SIM mode set GUI=postsim

Added vis cmd for Visualizer beside vsim cmd for Post SIM mode,
and added same checks for the cmd as vsim
Changed way of invoking Questa from running .DO file into directly
invoking Questa from bash/shell terminal
VSIM_ARGS and other variables kept untouched for backward compatibility,
also SCRIPT_FILE is kept for user custom DO file
Added more variables for new design.bin and qwave.db file names
for user custom preferences

Fixes cocotb#2852
@imphil imphil force-pushed the questa-qrun-imphil branch from 070ecc4 to 1f5f878 Compare May 8, 2025 05:53
@imphil
Copy link
Member Author
imphil commented May 9, 2025

VHDL+VHPI and Verilog VPI are clean now. We are left with failures in VHDL+FLI at this point.

@AbdouTharwat, you wrote:

Finally regarding FLI and VHPI failures, we already opened issues for those and are being investigated, so we are on track.

We are now down to the VHDL/FLI failures that we already saw in the initial run of this PR (failures at test_array.test_read_write, test_array.test_discover_all and test_array.test_direct_constant_indexing), all three of them due to the inability of Questa QIS/Qrun with FLI+VHDL to access array_module.param_rec and array_module.param_cmplx (the access works just fine with Questa in the compat flow).

Can you check what came out of the issues that you reported and let us know the issue number so we have a number to reference?

Copy link
Member
@ktbarrett ktbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the big question. What about the Python runner?

Comment on lines +233 to +234
The QIS/qrun flow is chosen automatically if Questa 2023.1 or newer is detected.
Users can explicitly use the QIS/Qrun flow with :make:var:`SIM=questa-qisqrun`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause an issue where the user starts with an old Questa or selected compat and the arguments and all that not working when it magically decides to use the new flow?

GPI_EXTRA := $(shell $(PYTHON_BIN) -m cocotb_tools.config --lib-name-path $(VHDL_GPI_INTERFACE) questa):cocotb$(VHDL_GPI_INTERFACE)_entry_point
endif
# Determine the version of Questa being used.
QUESTA_VERSION := $(shell $(CMD) -version | python -c 'import re,s 10000 ys; print(re.sub(r".+vsim (\d+)\.(\d).+", "\\1 \\2", sys.stdin.read()))')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
QUESTA_VERSION := $(shell $(CMD) -version | python -c 'import re,sys; print(re.sub(r".+vsim (\d+)\.(\d).+", "\\1 \\2", sys.stdin.read()))')
QUESTA_VERSION := $(shell $(CMD) -version | $(PYTHON_BIN) -c 'import re,sys; print(re.sub(r".+vsim (\d+)\.(\d).+", "\\1 \\2", sys.stdin.read()))')

$(SIM_CMD_PREFIX) $(QRUN_CMD) $(RUN_ARGS) -outdir $(SIM_BUILD) \
$(foreach LIB, $(VHDL_LIB_ORDER), $(make_lib)) \
-makelib $(TOPLEVEL_LIBRARY) $(VERILOG_SOURCES) $(VHDL_SOURCES) $(VLOG_ARGS) $(VCOM_ARGS) -end \
$(VOPT_ARGS) $(VSIM_ARGS) $(EXTRA_ARGS) $(call deprecate,PLUSARGS,COCOTB_PLUSARGS) +define+COCOTB_SIM -sv \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COCOTB_SIM?

@@ -14,18 +14,16 @@

SIM_NAME = cocotb.SIM_NAME.lower()
SIM_VERSION = cocotb.SIM_VERSION
LANGUAGE = os.environ["TOPLEVEL_LANG"].lower().strip()
LANGUAGE = os.getenv("TOPLEVEL_LANG", "verilog").lower().strip()
VHDL_GPI_INTERFACE = os.getenv("VHDL_GPI_INTERFACE", "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you change the default for getenv in your last PR because we are always exporting it now?

return 5119
else:
# The QIS/Qrun flow additionally finds
# Found dec_viterbi_ent.#IMPLICIT# (<class 'cocotb.handle.IntegerObject'>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it.

@AbdouTharwat
Copy link

Hi @imphil, great news. Actually, we already fixed FLI issues and were looking into VHPI failure. Since you are saying that now VHPI also is clean, then I think we are done. The fix for FLI issues should be available in upcoming Questa 2025.2 which is expected to be out in mid-June 2025. However, I can get you a Questa build with the fix to try before the official release if you wish to validate the fix early

Let me know if you wish to have the build and I will have it ready by next week

@imphil
Copy link
Member Author
imphil commented May 11, 2025

@AbdouTharwat Yes, please send me a pre-release build of Questa to confirm the fix on FLI.

For VHPI, we do see slightly different behavior during discovery as mentioned at #3306 (comment). That's not super problematic, but would ideally be fixed as well. Let me know if you have a issue number for that and I'll add it to the comment to make sure we can follow up on it.

@AbdouTharwat
Copy link

Hi @imphil, I shared a pre-release with you in order to validate FLI fix. Also, regarding the VHPI issue it is tracked in our system by ticket QSIM-84124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:codebase:project-automation (makefiles and Python runner) relating to project automation code category:simulators:questa Mentor Questa
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cocotb performance is very poor when using Questa/ModelSim
5 participants
0