ibex icon indicating copy to clipboard operation
ibex copied to clipboard

Add missing casts to enums (most likely in DV code only)

Open imphil opened this issue 6 years ago • 12 comments

@danielmlynek discovered this in https://github.com/lowRISC/ibex/pull/566:

All line where illegal assignment are done is now marked with warning ie: WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 781 1

This argument will be no longer needed when explicit cast will be used on such illegal assignment ie in file : /home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv, line 201 operating_mode = core_init_mstatus[12:11]; need to be changed to: operating_mode = priv_lvl_e'(core_init_mstatus[12:11]);

@danielmlynek do you know of more cases where such a cast is missing?

@msfschaffner I suppose currently the DV code isn't running through Lint, which should have caught that. Can you think of an easy way to lint that code as well? (Either here, or in OpenTitan.)

imphil avatar Jan 28 '20 10:01 imphil

Riviera compiler returns this warning for below lines - so all of them need to be reviewed to see if needs explicit casting WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 201 1 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 781 1 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 88 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 91 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 94 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 97 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 100 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 103 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 106 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 109 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 112 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 115 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 118 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 121 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 124 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 127 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 130 32 WARNING VCP2694 "Assignment to enum variable from expression of different type." "/home/danielm/gitlab/ibex/dv/uvm/tests/core_ibex_test_lib.sv" 133 32

danielmlynek avatar Jan 28 '20 14:01 danielmlynek

Thanks for the list @danielmlynek. @udinator would you mind having a look at these warnings/errors and add an explicit cast? (Probably you can get VCS to report similar warnings.)

imphil avatar Jan 28 '20 14:01 imphil

@danielmlynek - thank you for finding out all of these instances! @imphil - Sure, I will go through the DV code and scrub all of these warnings.

udinator avatar Jan 28 '20 19:01 udinator

@danielmlynek, I've submitted a PR that hopefully address most/all of these Riviera compile warnings. Could you re-run the tool and let me know if anything else comes up?

udinator avatar Jan 28 '20 23:01 udinator

PR #572 is now merged, master should run without warnings. Please re-open this issue if some of the issues remain.

imphil avatar Jan 29 '20 09:01 imphil

It should be REOPEN - there is one more line in /ibex/dv/uvm/tests/core_ibex_test_lib.sv mem_status = signature_data_q.pop_front(); should be mem_status = core_status_t'(signature_data_q.pop_front());

danielmlynek avatar Jan 29 '20 14:01 danielmlynek

Thanks @danielmlynek! @udinator can you have another look? (Or if you like, you can also do a PR to fix this one @danielmlynek.)

imphil avatar Jan 29 '20 14:01 imphil

@danielmlynek thanks! I've opened PR #576 to fix this last issue.

udinator avatar Jan 29 '20 17:01 udinator

Thanks for cleaning this up (and sorry for being late to the party here - I was out the last two weeks). Indeed, we only run RTL through AscentLint at the moment.

msfschaffner avatar Feb 10 '20 21:02 msfschaffner

@danielmlynek - are you still seeing these issues?

udinator avatar Feb 29 '20 02:02 udinator

No. Now all looks ok reagrding this issue.

danielmlynek avatar Mar 02 '20 08:03 danielmlynek

Great, thanks for confirming @danielmlynek. Closing this then.

imphil avatar Mar 02 '20 09:03 imphil