clash-lang / clash-compiler

Haskell to VHDL/Verilog/SystemVerilog compiler
https://clash-lang.org/
Other
1.4k stars 149 forks source link

`IntegralTB` test fails with the SystemVerilog+Modelsim combination #2559

Open christiaanb opened 11 months ago

christiaanb commented 11 months ago

On master, using GHC 9.6.2, I'm seeing:

$ cabal run clash-testsuite -- --no-vivado -p IntegralTB.SystemVerilog
Warning: Requested index-state 2023-06-17T22:28:17Z is newer than
'head.hackage.ghc.haskell.org'! Falling back to older state ().
Resolving dependencies...
.
  tests
    shouldwork
      Numbers
        IntegralTB
          SystemVerilog
            clash (gen):        OK (29.64s)
            tools
              ModelSim
                vlib testBench: OK (0.02s)
                vlog testBench: OK (0.11s)
                sim testBench:  FAIL (0.68s)
                  Program /opt/intelFPGA_pro/22.1/questa_fse/bin/vsim failed with error-code 1.

                  Full invocation:

                    /opt/intelFPGA_pro/22.1/questa_fse/bin/vsim -voptargs=+acc=p -batch -do run -all;if {[string equal ready [runStatus]]} then {quit -f} else {quit -code 1 -f};quit -code 2 -f testBench

                  Stderr was:

                  Stdout was:

                    # vsim -voptargs="+acc=p" -batch -do "run -all;if {[string equal ready [runStatus]]} then {quit -f} else {quit -code 1 -f};quit -code 2 -f" testBench 
                    # Start time: 15:18:02 on Aug 11,2023
                    # ** Note: (vsim-3812) Design is being optimized...
                    # ** Warning: (vopt-10587) Some optimizations are turned off because the +acc switch is in effect. This will cause your simulation to run slowly. Please use -access/-debug to maintain needed visibility.
                    # ** Note: (vsim-12126) Error and warning message counts have been restored: Errors=0, Warnings=1.
                    # //  Questa Intel Starter FPGA Edition-64
                    # //  Version 2022.1 linux_x86_64 Jan 29 2022
                    # //
                    # //  Copyright 1991-2022 Mentor Graphics Corporation
                    # //  All Rights Reserved.
                    # //
                    # //  QuestaSim and its associated documentation contain trade
                    # //  secrets and commercial or financial information that are the property of
                    # //  Mentor Graphics Corporation and are privileged, confidential,
                    # //  and exempt from disclosure under the Freedom of Information Act,
                    # //  5 U.S.C. Section 552. Furthermore, this information
                    # //  is prohibited from disclosure under the Trade Secrets Act,
                    # //  18 U.S.C. Section 1905.
                    # //
                    # Loading sv_std.std
                    # Loading work.IntegralTB_testBench_types(fast)
                    # Loading work.testBench(fast)
                    # Loading work.IntegralTB_topEntity_types(fast)
                    # Loading work.topEntity(fast)
                    # Loading work.topEntity_0(fast)
                    # 
                    # run -all
                    # @1000000ns: outputVerifier, expected: 00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000100000000000000010000000000000001000000000000000100000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000010000000000000001000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000010000000000000100000000000001000000000000010000000, actual: 00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000100000000xxxxxxxx000000000000000100000000000000010000000000000000000000010000000000000000xxxxxxxxxxxxxxxx000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000010000000000000001000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000001000000000000000100000000000000010000000000000010000000000000100000000000001000000000000010000000
                    # ** Note: $stop    : /tmp/clash-test-05fe0d8a0c567aad/modelsim-testBench/IntegralTB.testBench/testBench.sv(11983)
                    #    Time: 100 ns  Iteration: 1  Instance: /testBench
                    # Break at /tmp/clash-test-05fe0d8a0c567aad/modelsim-testBench/IntegralTB.testBench/testBench.sv line 11983
                    # if {[string equal ready [runStatus]]} then {quit -f} else {quit -code 1 -f}
                    # End time: 15:18:03 on Aug 11,2023, Elapsed time: 0:00:01
                    # Errors: 0, Warnings: 1
                  Use -p '/IntegralTB.SystemVerilog/&&/ModelSim.sim testBench/' to rerun this test only.
              Verilator
                make testBench: OK (7.15s)
                sim testBench:  OK (0.15s)
leonschoorl commented 10 months ago

I can't reproduce this using 9.6.2, did you mean to write 9.8? Or it could be an modelsim version difference, I've got

$ vsim -version
Model Technology ModelSim - INTEL FPGA STARTER EDITION vsim 2020.1 Simulator 2020.02 Feb 28 2020

$ cabal run clash-testsuite -- --no-vivado -p IntegralTB.SystemVerilog
.
  tests
    shouldwork
      Numbers
        IntegralTB
          SystemVerilog
            clash (gen):        OK (20.75s)
            tools
              ModelSim
                vlib testBench: OK (0.04s)
                vlog testBench: OK (0.15s)
                sim testBench:  OK (0.28s)

If I counted the bits right, in your case there is something wrong with the SystemVerilog implementations of div @Int8 and div @Int16, they're producing xs as a result. But interestingly others like for Int32, Int64 or Int are all ok.