vunit icon indicating copy to clipboard operation
vunit copied to clipboard

check_equal hex output

Open Munken opened this issue 4 years ago • 2 comments

I'm currently writing test benches for code that handles 32 bit addresses. In my test bench I'm writing the addresses a hex string eg. X"deadbeef".

However, when a check_equal fails it will output the current and expected result in base 2 and 10.

Got 1110_0000_1101_1101_1111_0000_0000_1101 (3772641293). Expected 0001_0100_1010_1011_1111_1101_1111_1011 (346815995)

Would it be possible to either also print the result in base 16 or have the number printed in the parenthesis in a user chosen base?

Got 1110_0000_1101_1101_1111_0000_0000_1101 (3772641293/0xE0DDF00D). Expected 0001_0100_1010_1011_1111_1101_1111_1011 (346815995/0x14ABFDFB)

Munken avatar Mar 05 '21 18:03 Munken

This has been discussed before but I don't think we have a previous issue for it. The current format is a bit of a compromise between being able to have the ideal format for the data being checked and not having too long messages. The "nibble format" serves two purposes. One is to see the individual bits if that's what matters for your application (e.g. control bits in a register). The other purpose is see the hex format but it assumes that you can do the nibble to hex number in your head.

To avoid the long messages I propose that we don't add another format. We could have a configuration for the checker but the problem with that is that the format would be the same for all calls. A third approach would be to control the format in each call. Today we have the result function allowing you to control the auto generated message. Maybe we can add another parameter to that function. For example

check_equal(my_data, expected_data, result("for my_data", hex))

Any thoughts?

LarsAsplund avatar Mar 06 '21 15:03 LarsAsplund

I would agree that simply expanding the already long log message could lead to trouble. And what should be done when someone requests the next format?

I thus agree with you that expanding the arguments for the result function is the best option. This allows for maximum flexibility and can be user expanded.

This has been discussed before but I don't think we have a previous issue

for it. The current format is a bit of a compromise between being able to have the ideal format for the data being checked and not having too long messages. The "nibble format" serves two purposes. One is to see the individual bits if that's what matters for your application (e.g. control bits in a register). The other purpose is see the hex format but it assumes that you can do the nibble to hex number in your head.

To avoid the long messages I propose that we don't add another format. We could have a configuration for the checker but the problem with that is that the format would be the same for all calls. A third approach would be to control the format in each call. Today we have the result function allowing you to control the auto generated message. Maybe we can add another parameter to that function. For example

check_equal(my_data, expected_data, result("for my_data", hex))

Any thoughts?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/VUnit/vunit/issues/710#issuecomment-791970885, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF44HGMSA2QSNXSU4LEIQTTCJCDBANCNFSM4YVWT5TQ .

Munken avatar Mar 07 '21 19:03 Munken