google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.21k stars 178 forks source link

Improve mismatch message in assert_eq for arrays #1521

Open mikex-oss opened 3 months ago

mikex-oss commented 3 months ago

What's hard to do? (limit 100 words)

The change at https://github.com/google/xls/commit/f530b769e765910ac6251e403ab449fda4c6ec00 has been very useful. However, I noticed that it does not apply to array elements when comparing arrays.

E.g.

assert_eq(
    some_fn(...), 
    u32[4]:[u32:0x75312468, u32:0, ...]);

might spit out something like:

FailureError: The program being interpreted failed!
  lhs and rhs were not equal:
  [
<     u32:960064620,
>     u32:1966154856,
      u32:0,
      u32:0,
      u32:0
  ]
; first differing index: 0 :: 960064620 vs 1966154856

It would be nice if the change to use the literal base could apply to each array element as in the scalar case.

Current best alternative workaround (limit 100 words)

Open up a Python interpreter (or some online base converter) to convert the decimal values to the form in the original test.

Your view of the "best case XLS enhancement" (limit 100 words)

If the previous change could be extended to array elements, that would be great.

meheff commented 2 months ago

Not exactly a fix for this particular bug, but we should probably switch to a default format of hex rather than decimal for these messages.