Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

** Fatal: expression cannot be folded to an integer constant when running with --dump-arrays and --wave flags #985

Closed
augustofg opened this issue Sep 19, 2024 · 2 comments

Comments

@augustofg
Copy link

Stumbled into this problem when simulating a Xilinx primitive (FIFO18E1). I've reduced to a minimal reproducible example:

library ieee;
use ieee.std_logic_1164.all;

entity folded_bug is
  generic (
    DATA_WIDTH: integer := 4;
    FIFO_SIZE: integer := 36
  );
end entity;

architecture sim of folded_bug is
  function GetWidth (
    rdwr_width : in integer
    ) return integer is
    variable func_width : integer;
  begin
    return rdwr_width;
  end;
  constant mem_width : integer := GetWidth(DATA_WIDTH);
  type Two_D_array_type is array (1 downto 0) of std_logic_vector((mem_width - 1) downto 0);
  signal mem : Two_D_array_type;
begin
  process
  begin
    mem(0) <= (others => '1');
    wait for 1 ns;
    mem(0) <= (others => '0');
    wait for 1 ns;
    std.env.finish;
  end process;
end architecture;
$ nvc --work=work --std=2008 -a folded_bug.vhd
$ nvc --std=2008 -e --no-collapse folded_bug
$ nvc -r --dump-arrays --exit-severity=error folded_bug --wave=folded_bug.fst --format=fst
** Fatal: expression cannot be folded to an integer constant
    > /tmp/nvc_folded_bug/folded_bug.vhd:20
    |
 20 |   type Two_D_array_type is array (1 downto 0) of std_logic_vector((mem_width - 1) downto 0);
    |                                                                    ^^^^^^^^^^^^^

nvc_folded_bug.zip

@nickg
Copy link
Owner

nickg commented Sep 19, 2024

Fixed in d0f7b34

@nickg nickg closed this as completed Sep 19, 2024
@augustofg
Copy link
Author

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants