nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
631 stars 77 forks source link

Analysis crash related to FORCE #877

Closed amb5l closed 5 months ago

amb5l commented 5 months ago

I'm seeing a crash during analysis of a testbench that is attempting to force internal signals (using aliases for external names) in the DUT (see transcript below). My NVC binary is compiled for Windows MSYS2 MINGW64 from this commit of NVC.

You can reproduce this with this commit from my repo by running make in sim/tb_mcu3/sim_nvc.

D:\work\retro_fpga\jarv\sim\tb_mcu3\sim_nvc>make
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/packages/common.vhd
touch work/common.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/packages/isa.vhd
touch work/isa.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/modules/decoder.vhd
touch work/decoder.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/modules/regfile_ad.vhd
touch work/regfile_ad.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/modules/alu.vhd
touch work/alu.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/modules/csr_m.vhd
touch work/csr_m.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/cores/mcu3.vhd
touch work/mcu3.vhd.com
nvc --std=2008 -L. --work=work -a --relaxed D:/work/retro_fpga/jarv/src/rtl/test/tb_mcu3.vhd
** Fatal: Cannot handle tree kind T_FORCE in wait expression
[00007ff71110bf1f]
[00007ff7111bfe55]
[00007ff711102162]
[00007ff71117524b]
[00007ff711175a01]
[00007ff711164415]
[00007ff71117e5ca]
[00007ff71117e718]
[00007ff7112299cf] vhpi_put_value+0x1c5bf
[00007ff71117c068]
[00007ff711107189]
[00007ff71123d773] vhpi_put_value+0x30363
[00007ff7111012ee]
[00007ff711101406]
[00007ff9c24d257d] BaseThreadInitThunk+0x1d
[00007ff9c36caa48] RtlUserThreadStart+0x28

Please report this bug at https://github.com/nickg/nvc/issues
amb5l commented 5 months ago

Note that there was a problem with my external names (ModelSim showed me this), fixed in this commit. This change doesn't affect the crash.

nickg commented 5 months ago

It happens any time there is a force (or release) in a process (all). E.g.

  INJECT: process(all)
  begin
    dut_csr_rdata <= force csr_rdata;
  end process INJECT;
nickg commented 5 months ago

Now I get:

** Error: external name CSR_EN not found
    > /home/nick/src/jarv/src/rtl/test/tb_mcu3.vhd:60
    |
 60 |   alias dut_csr_en    is << signal DUT.csr_en    : std_ulogic >>;
    |                                    ^^^ name DUT not found inside TB_MCU3
    |
    = Note: an object cannot be referenced by an external name until it has been elaborated

Which is presumably the Modelsim error you fixed above.

amb5l commented 5 months ago

Now I get:

** Error: external name CSR_EN not found
    > /home/nick/src/jarv/src/rtl/test/tb_mcu3.vhd:60
    |
 60 |   alias dut_csr_en    is << signal DUT.csr_en    : std_ulogic >>;
    |                                    ^^^ name DUT not found inside TB_MCU3
    |
    = Note: an object cannot be referenced by an external name until it has been elaborated

Which is presumably the Modelsim error you fixed above.

Correct. Can confirm that this issue is fixed for me - thankyou.