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

VHDL-2008: Error when checking locally static statement #655

Closed
bpadalino opened this issue Mar 20, 2023 · 0 comments
Closed

VHDL-2008: Error when checking locally static statement #655

bpadalino opened this issue Mar 20, 2023 · 0 comments

Comments

@bpadalino
Copy link
Contributor

The following code fails with a SEVG_MAPERR:

library ieee ;
    use ieee.numeric_std.all ;

entity saturate is
  port (
    x   :   in  signed(31 downto 0) ;
    y   :   out signed(15 downto 0)
  ) ;
end entity ;

architecture ifarch of saturate is

    constant sat_high : signed := to_signed(2**(y'length-1) - 1, y'length) ;
    constant sat_low  : signed := to_signed(-(2**(y'length-1)), y'length) ;

    constant too_high : integer := to_integer(sat_high) ;
    constant too_low  : integer := to_integer(sat_low) ;

begin

    process(all)
    begin
        if( x >= too_high ) then
            y <= sat_high ;
        elsif( x <= sat_low ) then
            y <= sat_low ;
        else
            y <= resize(x, y'length) ;
        end if ;
    end process ;

end architecture ;

architecture casearch of saturate is

    subtype too_high is integer range 2**(y'length-1)-1 to integer'high ;
    subtype too_low is integer range integer'low to -(2**(y'length-1)) ;

    constant sat_high : signed := to_signed(2**y'length - 1, y'length) ;
    constant sat_low : signed := to_signed(0, y'length) - sat_high - to_signed(1, y'length) ;

begin

    process(all)
    begin
        case to_integer(x) is
            when too_high => y <= sat_high ;
            when too_low  => y <= sat_low ;
            when others   => y <= resize(x, y'length) ;
        end case ;
    end process ;

end architecture ;

The failure is:

$ nvc --std=2008 -a saturate.vhdl 

*** Caught signal 11 (SEGV_MAPERR) [address=(nil), ip=0x5619b7c6f5ac] ***

[0x5619b7c2aead] ../src/util.c:837 signal_handler
[0x7f7aa331a51f] (/usr/lib/x86_64-linux-gnu/libc.so.6) 
[0x5619b7c6f5ac] ../src/tree.c:607 tree_type
[0x5619b7c6f5ac] ../src/tree.c:4316 sem_locally_static.lto_priv.0
[0x5619b7c7795f] ../src/sem.c:4850 sem_check_case
[0x5619b7c4eab1] ../src/parse.c:9191 p_sequential_statement
[0x5619b7c4eab1] ../src/parse.c:7153 p_sequence_of_statements.lto_priv.0
[0x5619b7c537b3] ../src/parse.c:7350 p_process_statement_part
[0x5619b7c537b3] ../src/parse.c:7412 p_process_statement.lto_priv.0
[0x5619b7c5b2d7] ../src/parse.c:10609 p_concurrent_statement.lto_priv.0
[0x5619b7c5d50e] ../src/parse.c:10675 p_architecture_body
[0x5619b7c5d50e] ../src/parse.c:10916 p_secondary_unit
[0x5619b7c5e3df] ../src/parse.c:10942 p_design_unit
[0x5619b7c5e3df] ../src/parse.c:11015 parse
[0x5619b7c338a0] ../src/nvc.c:211 analyse
[0x5619b7c338a0] ../src/nvc.c:1429 process_command
[0x5619b7c275b6] ../src/nvc.c:1553 main
@nickg nickg closed this as completed in 4b9474a Mar 20, 2023
nickg added a commit that referenced this issue Mar 20, 2023
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

1 participant