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

error: 'others' choice not allowed for an aggregate in this context #310

Open
wm2015email opened this issue Nov 22, 2024 · 0 comments
Open

Comments

@wm2015email
Copy link

wm2015email commented Nov 22, 2024

Compile in questasim, fails in ghdl:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.fixed_pkg.all;
use ieee.math_real.all;                                                                                            

use std.textio.all;

package vector_types_pkg is

  type sfixed_vector is array (natural range <>) of sfixed;
  type ufixed_vector is array (natural range <>) of ufixed;
end package;

package body vector_types_pkg is

  function to_sfixed_vector (val : std_logic_vector; format : sfixed_vector) return sfixed_vector is
	  constant elem_proto : format'element := (others => '0');
    constant wi_elem    : natural        := elem_proto'length;
    constant num_elem   : natural        := format'length;

    constant val_up : std_logic_vector(0 to val'length-1) := val;
    variable norm   : sfixed_vector(0 to num_elem-1)(elem_proto'range);
    variable result : format'subtype;
  begin
    assert val'length = wi_elem*num_elem
      report "Input vector size doesn't match format size."
      severity failure;

    for ii in 0 to num_elem-1 loop
      norm(ii) := sfixed(val_up(ii*wi_elem to (ii+1)*wi_elem-1));
    end loop;
    result := norm;
    return result;
  end function;
  
end package body;
$ ghdl.exe -a -fsynopsys --warn-no-hide --std=08 --work=work types_broken.2008.vhd

types_broken.2008.vhd:4162:45:error: 'others' choice not allowed for an aggregate in this context
    constant elem_proto : format'element := (others => '0');
                                            ^
types_broken.2008.vhd:4200:45:error: 'others' choice not allowed for an aggregate in this context
    constant elem_proto : format'element := (others => '0');
                                            ^
types_broken.2008.vhd:4256:38:error: 'others' choice not allowed for an aggregate in this context
    constant aa_elem : aa'element := (others => '0');
                                     ^
types_broken.2008.vhd:4257:38:error: 'others' choice not allowed for an aggregate in this context
    constant bb_elem : bb'element := (others => '0');
                                     ^
types_broken.2008.vhd:4266:38:error: 'others' choice not allowed for an aggregate in this context
    constant aa_elem : aa'element := (others => '0');
                                     ^
types_broken.2008.vhd:4267:38:error: 'others' choice not allowed for an aggregate in this context
    constant bb_elem : bb'element := (others => '0');
                                     ^

Here's a link to my github where the code is stored:

https://github.com/wm2015email/MISC/tree/main/ghdl_bug_2008

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